Documentation ¶
Index ¶
- Constants
- func BuildApiUrlOAS(specServerURL, overrideServerURL, specPath string) string
- func CopySchemaStandard(schema oas3.Schema) (oas3.Schema, error)
- func GetExtensionPropString(xprops oas3.ExtensionProps, key string) (string, error)
- func GetExtensionPropStringOrEmpty(xprops oas3.ExtensionProps, key string) string
- func GetOperationExtensionPropStringOrEmpty(op oas3.Operation, key string) string
- func OpTableColumnsDefault(inclDocsURL bool) *tabulator.ColumnSet
- func OpTableColumnsRingCentral() *tabulator.ColumnSet
- func OperationRequestMediaTypes(op *oas3.Operation) []string
- func OperationResponseMediaTypes(op *oas3.Operation) []string
- func OperationSecurityScopes(op *oas3.Operation, fullyQualified bool) []string
- func OperationSetRequestBodySchemaRef(op *oas3.Operation, mediaType string, schemaRef *oas3.SchemaRef)
- func OperationSetResponseBodySchemaRef(op *oas3.Operation, status, description, mediaType string, ...) error
- func SchemaPointerExpand(prefix, schemaName string) string
- func SecurityRequirementsToRaw(secReqs oas3.SecurityRequirements) []map[string][]string
- func TagsWithoutGroups(spec *Spec, tagGroupSet TagGroupSet) []string
- func VisitOperations(spec *Spec, visitOp func(path, method string, op *oas3.Operation))
- func VisitOperationsPathItem(path string, pathItem *oas3.PathItem, ...)
- func VisitTypesFormats(spec *Spec, visitTypeFormat func(jsonPointerRoot, oasType, oasFormat string))
- func WriteFileDirMerge(outfile, inputDir string, perm os.FileMode, mergeOpts *MergeOptions) (int, error)
- type CollisionCheckResult
- type ExtensionPropsParent
- type MergeOptions
- type Operation
- type OperationMeta
- type Spec
- func Copy(spec *Spec) (*Spec, error)
- func Merge(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
- func MergeDirectory(dir string, mergeOpts *MergeOptions) (*Spec, int, error)
- func MergeFiles(filepaths []string, mergeOpts *MergeOptions) (*Spec, error)
- func MergeParameters(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
- func MergePaths(specMaster, specExtra *Spec) (*Spec, error)
- func MergeRequestBodies(specMaster, specExtra *Spec, specExtraNote string) (*Spec, error)
- func MergeResponses(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
- func MergeSchemas(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
- func MergeTags(specMaster, specExtra *Spec) *Spec
- func MergeWithTables(spec1, spec2 *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, []*table.Table, error)
- func NewSpec(oasVersion, apiTitle, apiVersion string) *Spec
- func Parse(oas3Bytes []byte) (*Spec, error)
- func ReadAndValidateFile(oas3file string) (*Spec, error)
- func ReadFile(oas3file string, validate bool) (*Spec, error)
- func ReadURL(oas3url string) (*Spec, error)
- type SpecMeta
- type SpecMetas
- type SpecMore
- func (sm *SpecMore) ComponentRequestBody(componentPath string) *oas3.RequestBodyRef
- func (sm *SpecMore) ExtensionNames() map[string]int
- func (sm *SpecMore) HasComponentSchema(componentSchemaName string, lowerCaseMatch bool) bool
- func (sm *SpecMore) MarshalJSON(prefix, indent string) ([]byte, error)
- func (sm *SpecMore) OperationByID(wantOperationID string) (path, method string, op *oas3.Operation, err error)
- func (sm *SpecMore) OperationCountsByTag() *histogram.Histogram
- func (sm *SpecMore) OperationMetas() []OperationMeta
- func (sm *SpecMore) OperationParametersDescriptionStatus() maputil.MapStringMapStringInt
- func (sm *SpecMore) OperationParametersDescriptionStatusCounts() (with, without, all int)
- func (sm *SpecMore) OperationParametersWithoutDescriptionsWriteFile(filename string) error
- func (sm *SpecMore) OperationsCount() int
- func (sm *SpecMore) OperationsIDs() []string
- func (sm *SpecMore) OperationsTable(columns *tabulator.ColumnSet, ...) (*table.Table, error)
- func (sm *SpecMore) PrintJSON(prefix, indent string) error
- func (sm *SpecMore) SchemaNameExists(schemaName string, includeNil bool) bool
- func (sm *SpecMore) SchemaNames() []string
- func (sm *SpecMore) SchemaNamesStatus() (schemaNoReference, both, referenceNoSchema []string, err error)
- func (sm *SpecMore) SchemaPointers(dedupe bool) ([]string, []string, error)
- func (sm *SpecMore) SchemaPropertiesDescriptionStatus() maputil.MapStringMapStringInt
- func (sm *SpecMore) SchemaPropertiesDescriptionStatusCounts() (with, without, all int)
- func (sm *SpecMore) SchemaPropertiesWithoutDescriptionsWriteFile(filename string) error
- func (sm *SpecMore) SchemaRef(schemaName string) *oas3.SchemaRef
- func (sm *SpecMore) SchemasCount() int
- func (sm *SpecMore) ServerURL(index uint) string
- func (sm *SpecMore) ServerURLBasePath(index uint) (string, error)
- func (sm *SpecMore) SetOperation(path, method string, op *oas3.Operation)
- func (sm *SpecMore) SetSchemaRef(schemaName string, schemaRef *oas3.SchemaRef) error
- func (sm *SpecMore) Stats() SpecStats
- func (sm *SpecMore) StatusCodesHistogram() *histogram.HistogramSets
- func (sm *SpecMore) TagGroups() (TagGroupSet, error)
- func (sm *SpecMore) Tags(inclTop, inclOps bool) []string
- func (sm *SpecMore) TagsMap(inclTop, inclOps bool) map[string]int
- func (sm *SpecMore) WriteFileCSV(filename string) error
- func (sm *SpecMore) WriteFileJSON(filename string, perm os.FileMode, prefix, indent string) error
- func (sm *SpecMore) WriteFileXLSX(filename string, columns *tabulator.ColumnSet, ...) error
- func (sm *SpecMore) WriteFileXLSXOperationStatusCodes(filename string) error
- type SpecStats
- type TagGroup
- type TagGroupSet
- type TagsMore
- type ValidationStatus
Constants ¶
const ( TypeArray = "array" TypeBoolean = "boolean" TypeInteger = "integer" TypeObject = "object" TypeString = "string" FormatDate = "date" FormatDateTime = "date-time" FormatInt32 = "int32" FormatInt64 = "int64" PropertyOperationID = "operationId" PropertySummary = "summary" PropertyTags = "tags" )
const ( DescStatusIsEmpty = 0 DescStatusIsNotEmpty = 1 DescStatusDefaultSep = " ~~~ " )
const ( XTagGroups = "x-tag-groups" XThrottlingGroup = "x-throttling-group" )
const (
OASVersionLatest = "3.1.0"
)
const PointerComponentsSchemas = "#/components/schemas"
const XTagGroupsPropertyName = "x-tag-groups"
Variables ¶
This section is empty.
Functions ¶
func BuildApiUrlOAS ¶
func GetExtensionPropString ¶
func GetExtensionPropString(xprops oas3.ExtensionProps, key string) (string, error)
GetExtensionPropString converts extension prop value from `json.RawMessage` to `string`.
func GetExtensionPropStringOrEmpty ¶
func GetExtensionPropStringOrEmpty(xprops oas3.ExtensionProps, key string) string
GetExtensionPropStringOrEmpty converts extension prop value from `json.RawMessage` to `string`.
func GetOperationExtensionPropStringOrEmpty ¶
GetOperationExtensionPropStringOrEmpty converts extension prop value from `json.RawMessage` to `string`.
func OpTableColumnsDefault ¶
func OperationRequestMediaTypes ¶
func MediaTypesToSlice(typesMap map[string]*oas3.MediaType) []string { slice := []string{} for thisType := range typesMap { slice = append(slides, thisType) } return slice }
OperationRequestMediaTypes returns a sorted slice of request media types.
func OperationResponseMediaTypes ¶
OperationResponseMediaTypes returns a sorted slice of response media types.
func OperationSecurityScopes ¶
OperationSecurityScopes retrieves a flat list of security scopes for an operation.
func SchemaPointerExpand ¶
func SecurityRequirementsToRaw ¶
func SecurityRequirementsToRaw(secReqs oas3.SecurityRequirements) []map[string][]string
SecurityRequirementsToRaw returns a raw SecurityRequirements slice to be used for iterating over elements.
func TagsWithoutGroups ¶
func TagsWithoutGroups(spec *Spec, tagGroupSet TagGroupSet) []string
func VisitOperations ¶
func VisitOperationsPathItem ¶ added in v1.8.2
func VisitTypesFormats ¶
func WriteFileDirMerge ¶
Types ¶
type CollisionCheckResult ¶
type CollisionCheckResult int
const ( CollisionCheckSame CollisionCheckResult = iota CollisionCheckOverwrite CollisionCheckError CollisionCheckSkip )
func SchemaCheckCollisionDefault ¶
func SchemaCheckCollisionDefault(schemaName string, item1, item2 interface{}, item2Note string) CollisionCheckResult
func SchemaCheckCollisionSkip ¶
func SchemaCheckCollisionSkip(schemaName string, item1, item2 interface{}, item2Note string) CollisionCheckResult
type ExtensionPropsParent ¶
type ExtensionPropsParent interface{}
type MergeOptions ¶
type MergeOptions struct { FileRx *regexp.Regexp SchemaFunc func(schemaName string, sch1, sch2 interface{}, hint2 string) CollisionCheckResult CollisionCheckResult CollisionCheckResult ValidateEach bool ValidateFinal bool TableColumns *tabulator.ColumnSet TableOpFilterFunc func(path, method string, op *oas3.Operation) bool }
func NewMergeOptionsSkip ¶
func NewMergeOptionsSkip() *MergeOptions
func (*MergeOptions) CheckSchemaCollision ¶
func (mo *MergeOptions) CheckSchemaCollision(schemaName string, sch1, sch2 interface{}, hint2 string) CollisionCheckResult
type OperationMeta ¶
type OperationMeta struct { OperationID string DocsDescription string DocsURL string Method string Path string SecurityScopes []string Summary string Tags []string MetaNotes []string XThrottlingGroup string }
OperationMeta is used to hold additional information for a spec operation.
func OperationToMeta ¶
func OperationToMeta(url, method string, op *oas3.Operation) OperationMeta
func (*OperationMeta) TrimSpace ¶
func (om *OperationMeta) TrimSpace()
type Spec ¶ added in v1.9.0
func Merge ¶
func Merge(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
func MergeDirectory ¶
func MergeDirectory(dir string, mergeOpts *MergeOptions) (*Spec, int, error)
func MergeFiles ¶
func MergeFiles(filepaths []string, mergeOpts *MergeOptions) (*Spec, error)
func MergeParameters ¶
func MergeParameters(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
func MergePaths ¶
func MergeRequestBodies ¶
func MergeResponses ¶
func MergeResponses(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
func MergeSchemas ¶
func MergeSchemas(specMaster, specExtra *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, error)
func MergeWithTables ¶
func MergeWithTables(spec1, spec2 *Spec, specExtraNote string, mergeOpts *MergeOptions) (*Spec, []*table.Table, error)
MergeWithTables performs a spec merge and returns comparison tables. This is useful to combine with github.com/grokify/gocharts/data/table WriteXLSX() to write out comparison tables for debugging.
func NewSpec ¶
NewSpec returns a new OpenAPI 3 spec that will validate. Specifically, it includes an OAS version, sets `info` to be an empty object instead of null and sets apiVersion.
func Parse ¶
Parse will parse a byte array to an `*oas3.Swagger` struct. It will use JSON first. If unsuccessful, it will attempt to parse it as YAML.
func ReadAndValidateFile ¶
type SpecMore ¶
type SpecMore struct {
Spec *Spec
}
func MergeSpecMetas ¶
func MergeSpecMetas(metas *SpecMetas, validatesOnly bool, mergeOpts *MergeOptions) (SpecMore, error)
func (*SpecMore) ComponentRequestBody ¶
func (sm *SpecMore) ComponentRequestBody(componentPath string) *oas3.RequestBodyRef
func (*SpecMore) ExtensionNames ¶
ExtensionNames is not complete yet.
func (*SpecMore) HasComponentSchema ¶
func (*SpecMore) MarshalJSON ¶
func (*SpecMore) OperationByID ¶
func (*SpecMore) OperationCountsByTag ¶
OperationCountsByTag returns a histogram for operations by tag.
func (*SpecMore) OperationMetas ¶
func (sm *SpecMore) OperationMetas() []OperationMeta
func (*SpecMore) OperationParametersDescriptionStatus ¶
func (sm *SpecMore) OperationParametersDescriptionStatus() maputil.MapStringMapStringInt
OperationParametersDescriptionStatus returns a set of operationIds and parameters with description status where `1` indicates a description and `0` indicates no descriptions. Descriptions for references aren't processed so they aren't analyzed and reported on. This returns a `MapStringMapStringInt` where the first key is the operationIds and the second key is the parameter name.
func (*SpecMore) OperationParametersDescriptionStatusCounts ¶
OperationParametersDescriptionStatusCounts returns operation parameter counts with descriptions, without descriptions, and total counts.
func (*SpecMore) OperationParametersWithoutDescriptionsWriteFile ¶
func (*SpecMore) OperationsCount ¶
func (*SpecMore) OperationsIDs ¶
func (*SpecMore) OperationsTable ¶
func (*SpecMore) SchemaNameExists ¶
func (*SpecMore) SchemaNames ¶
func (*SpecMore) SchemaNamesStatus ¶ added in v1.7.0
func (*SpecMore) SchemaPointers ¶ added in v1.7.0
func (*SpecMore) SchemaPropertiesDescriptionStatus ¶
func (sm *SpecMore) SchemaPropertiesDescriptionStatus() maputil.MapStringMapStringInt
SchemaPropertiesDescriptionStatus returns a set of schema names and properties with description status where `1` indicates a description and `0` indicates no descriptions. Descriptions for references aren't processed so they aren't analyzed and reported on. This returns a `MapStringMapStringInt` where the first key is the component name and the second key is the property name.
func (*SpecMore) SchemaPropertiesDescriptionStatusCounts ¶
SchemaPropertiesDescriptionStatusCounts returns schema property counts with descriptions, without descriptions, and total counts.
func (*SpecMore) SchemaPropertiesWithoutDescriptionsWriteFile ¶
func (*SpecMore) SchemasCount ¶
func (*SpecMore) ServerURLBasePath ¶
ServerURLBasePath extracts the base path from a OAS URL which can include variables.
func (*SpecMore) SetOperation ¶
func (*SpecMore) SetSchemaRef ¶
func (*SpecMore) StatusCodesHistogram ¶ added in v1.10.0
func (sm *SpecMore) StatusCodesHistogram() *histogram.HistogramSets
func (*SpecMore) TagGroups ¶
func (sm *SpecMore) TagGroups() (TagGroupSet, error)
TagGroups parses a TagGroupSet from an OpenAPI3 spec.
func (*SpecMore) WriteFileCSV ¶
func (*SpecMore) WriteFileJSON ¶
func (*SpecMore) WriteFileXLSX ¶
func (*SpecMore) WriteFileXLSXOperationStatusCodes ¶ added in v1.10.0
type TagGroupSet ¶
type TagGroupSet struct {
TagGroups []TagGroup
}
func NewTagGroupSet ¶
func NewTagGroupSet() TagGroupSet
func (*TagGroupSet) AddToSpec ¶
func (set *TagGroupSet) AddToSpec(spec *Spec) error
func (*TagGroupSet) Exists ¶
func (set *TagGroupSet) Exists(tagName string) bool
func (*TagGroupSet) GetTagGroupNamesForTagNames ¶
func (set *TagGroupSet) GetTagGroupNamesForTagNames(wantTagNames ...string) []string
type ValidationStatus ¶
func ValidateMore ¶
func ValidateMore(spec *Spec) (ValidationStatus, error)