Documentation ¶
Index ¶
- Constants
- func FixFile(input, output string, prefix, indent string, validateOutput bool) (*oas3.Swagger, []*openapi3.OperationMeta, error)
- func MapSliceIntersectionExists(haystack map[string]int, needles []string) bool
- func MoveRequestBodies(spec *oas3.Swagger, move bool) ([]*openapi3.OperationMeta, error)
- func NullToEmpty(spec *oas3.Swagger)
- func NullToEmptyPaths(spec *oas3.Swagger)
- func ParsePathParametersParens(urlPath string) []string
- func PathItemHasEndpoints(pathItem *oas3.PathItem) bool
- func PathMatchGeneric(path1, path2 string) bool
- func PathMethods(pathItem *oas3.PathItem) []string
- func PathVarsToGeneric(input string) string
- func RemoveOperationsSecurity(spec *oas3.Swagger)
- func SecuritySchemeAddBearertoken(spec *oas3.Swagger, schemeName, bearerFormat string, ...)
- func SecuritySchemeAddOperation(op *oas3.Operation, schemeName string, schemeValue []string)
- func SecuritySchemeApikeyAddDefinition(spec *oas3.Swagger, schemeName, location, name string) error
- func SecuritySchemeApikeyAddOperations(spec *oas3.Swagger, tags []string, keyName string)
- func SecuritySchemeBearertokenAddDefinition(spec *oas3.Swagger, schemeName, bearerFormat string)
- func SecuritySchemeBearertokenAddOperationsByTags(spec *oas3.Swagger, schemeName string, inclTags, skipTags []string)
- func SortParameters(sourceParams oas3.Parameters, sortOrder []string) oas3.Parameters
- func SpecAddCustomProperties(spec *oas3.Swagger, custom map[string]interface{}, ...)
- func SpecAddOperationMetas(spec *oas3.Swagger, metas map[string]openapi3.OperationMeta, overwrite bool)
- func SpecDeleteOperations(spec *oas3.Swagger, ...)
- func SpecDeleteProperties(spec *oas3.Swagger, md SpecMetadata)
- func SpecEndpoints(spec *oas3.Swagger, generic bool) []string
- func SpecMoreModifyMulti(sm *openapi3.SpecMore, opts SpecMoreModifyMultiOpts) error
- func SpecOperationIds(spec *oas3.Swagger) map[string]int
- func SpecOperationIdsFromSummaries(spec *oas3.Swagger, errorOnEmpty bool) error
- func SpecOperationsCount(spec *oas3.Swagger) uint
- func SpecOperationsFixResponseReferences(spec *oas3.Swagger) []*openapi3.OperationMeta
- func SpecOperationsSetDeprecated(spec *oas3.Swagger, newDeprecated bool)
- func SpecPathsModify(spec *oas3.Swagger, opts SpecPathsModifyOpts) error
- func SpecSchemasSetDeprecated(spec *oas3.Swagger, newDeprecated bool)
- func SpecSetDeprecatedImplicit(spec *oas3.Swagger)
- func SpecSetOperation(spec *oas3.Swagger, path, method string, op oas3.Operation) error
- func SpecSetSchemaPropertiesOptional(spec *oas3.Swagger, rxOptional *regexp.Regexp)
- func SpecTagsCondense(spec *oas3.Swagger)
- func SpecTagsModify(spec *oas3.Swagger, changeTagsRaw map[string]string)
- func SpecTagsOrder(spec *oas3.Swagger, explicitSortedTagNames []string) error
- func TagsOrder(curTags oas3.Tags, explicitSortedTagNames []string) (oas3.Tags, error)
- func ValidateFixOperationPathParameters(spec *oas3.Swagger, fix bool) ([]*openapi3.OperationMeta, error)
- func ValidateFixOperationResponseTypes(spec *oas3.Swagger, fix bool) ([]*openapi3.OperationMeta, error)
- type Endpoint
- type IntersectionData
- type OperationMore
- func (opm *OperationMore) AddExternalDocs(docURL, docDescription string, preserveIfReqEmpty bool)
- func (opm *OperationMore) AddRequestBodySchemaRef(description string, required bool, contentType string, ...) error
- func (opm *OperationMore) AddResponseBodySchemaRef(statusCode, description, contentType string, schemaRef *oas3.SchemaRef) error
- func (opm *OperationMore) HasParameter(paramNameWant string) bool
- type OperationMoreSet
- type PathMeta
- type SpecMetadata
- type SpecMoreModifyMultiOpts
- type SpecPaths
- type SpecPathsModifyOpts
- type UpdateTagsOpts
Constants ¶
const ( SecuritySchemeApikeyDefaultName = "ApiKeyAuth" SecuritySchemeBearertokenDefaultName = "BearerAuth" SchemeHTTP = "http" TokenTypeBearer = "bearer" )
Variables ¶
This section is empty.
Functions ¶
func MoveRequestBodies ¶
MoveRequestBodies moves `requestBody` `$ref` to the operation which appears to be supported by more tools.
func NullToEmpty ¶
func NullToEmptyPaths ¶
NullToEmptyPaths converts a `path` property from `null` to an empty set `{}` to satisfy OpenAPI Generator which will fail on the following error "-attribute paths is not of type `object`"
func PathItemHasEndpoints ¶
func PathMatchGeneric ¶
func PathMethods ¶
func PathVarsToGeneric ¶
func RemoveOperationsSecurity ¶
RemoveOperationsSecurity removes the security property for all operations. It is useful when building a spec to get individual specs to validate before setting the correct security property.
func SecuritySchemeAddBearertoken ¶
func SecuritySchemeAddBearertoken(spec *oas3.Swagger, schemeName, bearerFormat string, inclTags, skipTags []string)
SecuritySchemeAddBearertoken adds bearer token auth to spec and operations.
func SecuritySchemeAddOperation ¶
SecuritySchemeAddOperation adds a scheme name and value to an operation.
func SecuritySchemeApikeyAddDefinition ¶
AddAPIKey adds an API Key definition to the spec. https://swagger.io/docs/specification/authentication/api-keys/
func SortParameters ¶
func SortParameters(sourceParams oas3.Parameters, sortOrder []string) oas3.Parameters
func OperationHasParameter(paramNameWant string, op *oas3.Operation) bool { paramNameWantLc := strings.ToLower(strings.TrimSpace(paramNameWant)) for _, paramRef := range op.Parameters { if paramRef.Value == nil { continue } param := paramRef.Value param.Name = strings.TrimSpace(param.Name) paramNameTryLc := strings.ToLower(param.Name) if paramNameWantLc == paramNameTryLc { return true } } return false }
SortParameters sorts parameters according to an input name list. This used to resort parameters inline with path path parameters so they line up properly when rendered.
func SpecAddCustomProperties ¶
func SpecAddOperationMetas ¶
func SpecDeleteOperations ¶
func SpecDeleteProperties ¶
func SpecDeleteProperties(spec *oas3.Swagger, md SpecMetadata)
func SpecMoreModifyMulti ¶
func SpecMoreModifyMulti(sm *openapi3.SpecMore, opts SpecMoreModifyMultiOpts) error
SpecMoreModifyMulti is used to perform multiple updates on an OpenAPI 3 spec.
func SpecOperationsCount ¶
func SpecOperationsFixResponseReferences ¶
func SpecOperationsFixResponseReferences(spec *oas3.Swagger) []*openapi3.OperationMeta
func SpecPathsModify ¶
func SpecPathsModify(spec *oas3.Swagger, opts SpecPathsModifyOpts) error
func SpecSetOperation ¶
SpecSetOperation sets an operation in a OpenAPI Specification.
func SpecTagsCondense ¶
SpecTagsCondense removes unused tags from the top level specification by comparing with tags used in operations.
func SpecTagsOrder ¶
SpecTagsOrder sorts a specs tags based on an input set and explitcit sort order. The remaining tags are sorted alphabetically.
func TagsOrder ¶
TagsOrder creates a list of ordered tags based on an input set and explitcit sort order. The remaining tags are sorted alphabetically.
func ValidateFixOperationPathParameters ¶
func ValidateFixOperationPathParameters(spec *oas3.Swagger, fix bool) ([]*openapi3.OperationMeta, error)
ValidateFixOperationPathParameters will add missing path parameters and re-sort parameters so required path parameters are on top and sorted by their position in the path.
func ValidateFixOperationResponseTypes ¶
func ValidateFixOperationResponseTypes(spec *oas3.Swagger, fix bool) ([]*openapi3.OperationMeta, error)
ValidateFixOperationResponseTypes looks for `application/json` responses with response schema types that are not `array` or `object`. If the responses is a string or integer, it will reset the response mime type to `text/plain`.
Types ¶
type IntersectionData ¶
type IntersectionData struct { Spec1 SpecMetadata Spec2 SpecMetadata Intersection SpecMetadata }
func NewIntersectionData ¶
func NewIntersectionData() IntersectionData
func SpecsIntersection ¶
func SpecsIntersection(spec1, spec2 *oas3.Swagger) IntersectionData
func (*IntersectionData) Sort ¶
func (idata *IntersectionData) Sort()
type OperationMore ¶
OperationMore is used for two purposes: (a) to store path and method information with the operation and (b) to provide a container to organize operation related functions.
func (*OperationMore) AddExternalDocs ¶
func (opm *OperationMore) AddExternalDocs(docURL, docDescription string, preserveIfReqEmpty bool)
func (*OperationMore) AddRequestBodySchemaRef ¶
func (*OperationMore) AddResponseBodySchemaRef ¶
func (opm *OperationMore) AddResponseBodySchemaRef(statusCode, description, contentType string, schemaRef *oas3.SchemaRef) error
func (*OperationMore) HasParameter ¶
func (opm *OperationMore) HasParameter(paramNameWant string) bool
type OperationMoreSet ¶
type OperationMoreSet struct {
OperationMores []OperationMore
}
func QueryOperationsByTags ¶
func QueryOperationsByTags(spec *oas3.Swagger, tags []string) *OperationMoreSet
type SpecMetadata ¶
func NewSpecMetadata ¶
func NewSpecMetadata(spec *oas3.Swagger) SpecMetadata
func (*SpecMetadata) Intersection ¶
func (md *SpecMetadata) Intersection(md2 SpecMetadata) SpecMetadata
func (*SpecMetadata) IsEmpty ¶
func (md *SpecMetadata) IsEmpty() bool
func (*SpecMetadata) Sort ¶
func (md *SpecMetadata) Sort()
type SpecMoreModifyMultiOpts ¶
type SpecMoreModifyMultiOpts struct { OperationsDeleteFunc func(urlpath, method string, op *oas3.Operation) bool OperationsRenameIdsFunc func(string, string, *oas3.Operation) OperationsRemoveSecurity bool OperationsShowIds bool OperationsExec bool Paths SpecPathsModifyOpts PathsShow bool PathsExec bool TagsOperationFunc func(string, string, *oas3.Operation) Tags map[string]string TagsShow bool TagsExec bool }
type SpecPaths ¶
func InspectPaths ¶
type SpecPathsModifyOpts ¶
type UpdateTagsOpts ¶
type UpdateTagsOpts struct { TagURLsMap map[string][]string TagsMap map[string]string TagGroupsSet openapi3.TagGroupSet }
func (*UpdateTagsOpts) ModifyTagsOperationFunc ¶
func (uto *UpdateTagsOpts) ModifyTagsOperationFunc(path, method string, op *oas3.Operation)