Documentation
¶
Index ¶
- func AllSchemasMatch(schemas []*base.SchemaProxy, f SchemaMatchFunc) bool
- func CollectOperations(doc *libopenapi.DocumentModel[v3.Document]) []*v3.Operation
- func CollectSchemas(doc *libopenapi.DocumentModel[v3.Document]) []*base.Schema
- func Compare(aProxy *base.SchemaProxy, bProxy *base.SchemaProxy) bool
- func CompareWithVisited(aProxy, bProxy *base.SchemaProxy, visited map[schemaPair]bool) bool
- func ConvertDocument(bytes []byte, format string) ([]byte, error)
- func EmptyDocument() libopenapi.DocumentModel[v3.Document]
- func EnumToAllowedValues(s *base.Schema) (map[string]AllowedValue, error)
- func FetchSpec(format SourceType, url string) ([]byte, error)
- func HashSchema(schema *base.SchemaProxy) string
- func IsEmptySchema(schema *base.Schema) bool
- func IsEnumSchema(s *base.Schema) bool
- func IsMutable(schema *base.Schema) (bool, error)
- func IsPolymorphicSchema(s *base.Schema) bool
- func MergeSchema(result *base.Schema, override *base.Schema) (*base.Schema, error)
- func MergeSchemaProxy(baseSP *base.SchemaProxy, overwriteSP *base.SchemaProxy) (*base.Schema, error)
- func MergeSchemaProxySchema(baseSP *base.SchemaProxy, override *base.Schema) (*base.Schema, error)
- func OpenDocument(input []byte) (libopenapi.Document, error)
- func OpenDocumentFile(file string) (libopenapi.Document, error)
- func OpenDocumentWithBaseDir(input []byte, baseDir string) (libopenapi.Document, error)
- func OpenV3DocumentForTest(bytes []byte) *libopenapi.DocumentModel[v3.Document]
- func RenderDocument(doc libopenapi.Document) ([]byte, error)
- func RenderDocumentFile(doc libopenapi.Document, file string) error
- func RenderV3ModelFormat(doc *libopenapi.DocumentModel[v3.Document], format string) ([]byte, error)
- func SimplifyPolymorphism(schemaName string, schemaProxy *base.SchemaProxy, ...) (*base.SchemaProxy, error)
- func SpecTitle(doc *libopenapi.DocumentModel[v3.Document], defaultTitle string) string
- func VisitAllSchemas(doc *libopenapi.DocumentModel[v3.Document], ...)
- type AllowedValue
- type SchemaMatchFunc
- type SourceType
- type SpecType
- type WalkDocumentResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AllSchemasMatch ¶
func AllSchemasMatch(schemas []*base.SchemaProxy, f SchemaMatchFunc) bool
AllSchemasMatch returns true if the given function returns true for all input schemas
func CollectOperations ¶
func CollectOperations(doc *libopenapi.DocumentModel[v3.Document]) []*v3.Operation
func CollectSchemas ¶
func CollectSchemas(doc *libopenapi.DocumentModel[v3.Document]) []*base.Schema
CollectSchemas collects all schemas from the OpenAPI document (doesn't follow recursion, flatten should be used first).
func Compare ¶
func Compare(aProxy *base.SchemaProxy, bProxy *base.SchemaProxy) bool
func CompareWithVisited ¶
func CompareWithVisited(aProxy, bProxy *base.SchemaProxy, visited map[schemaPair]bool) bool
CompareWithVisited compares schemas and avoids infinite loops
func ConvertDocument ¶
ConvertDocument converts an OpenAPI document byte array to the specified format (yaml or json)
func EmptyDocument ¶
func EmptyDocument() libopenapi.DocumentModel[v3.Document]
func EnumToAllowedValues ¶
func EnumToAllowedValues(s *base.Schema) (map[string]AllowedValue, error)
EnumToAllowedValues converts an enum schema to a list of allowed values
func FetchSpec ¶
func FetchSpec(format SourceType, url string) ([]byte, error)
FetchSpec will download the spec from the source
func HashSchema ¶
func HashSchema(schema *base.SchemaProxy) string
func IsEmptySchema ¶
func IsEnumSchema ¶
IsEnumSchema returns true if the schema is an enum schema
func IsPolymorphicSchema ¶
IsPolymorphicSchema returns true if the schema is a polymorphic schema (allOf, oneOf, anyOf)
func MergeSchema ¶
MergeSchema merges the properties of the overwrite schema into the base schema (useful to process anyOf, oneOf, allOf)
func MergeSchemaProxy ¶
func MergeSchemaProxy(baseSP *base.SchemaProxy, overwriteSP *base.SchemaProxy) (*base.Schema, error)
func MergeSchemaProxySchema ¶
func OpenDocument ¶
func OpenDocument(input []byte) (libopenapi.Document, error)
func OpenDocumentFile ¶
func OpenDocumentFile(file string) (libopenapi.Document, error)
func OpenDocumentWithBaseDir ¶
func OpenDocumentWithBaseDir(input []byte, baseDir string) (libopenapi.Document, error)
func OpenV3DocumentForTest ¶
func OpenV3DocumentForTest(bytes []byte) *libopenapi.DocumentModel[v3.Document]
OpenV3DocumentForTest opens a document and builds a v3 model, asserting no errors (panics on error, for usage in tests only!)
func RenderDocument ¶
func RenderDocument(doc libopenapi.Document) ([]byte, error)
RenderDocument renders the document as bytes
func RenderDocumentFile ¶
func RenderDocumentFile(doc libopenapi.Document, file string) error
RenderDocumentFile writes the document into a file
func RenderV3ModelFormat ¶
func RenderV3ModelFormat(doc *libopenapi.DocumentModel[v3.Document], format string) ([]byte, error)
func SimplifyPolymorphism ¶
func SimplifyPolymorphism(schemaName string, schemaProxy *base.SchemaProxy, schemas *orderedmap.Map[string, *base.SchemaProxy], schemataMap map[string]string) (*base.SchemaProxy, error)
func SpecTitle ¶
func SpecTitle(doc *libopenapi.DocumentModel[v3.Document], defaultTitle string) string
func VisitAllSchemas ¶
func VisitAllSchemas( doc *libopenapi.DocumentModel[v3.Document], visitor func(name string, schema *base.SchemaProxy) *base.SchemaProxy, )
Types ¶
type AllowedValue ¶
type SchemaMatchFunc ¶
type SourceType ¶
type SourceType string
const ( SourceTypeSpec SourceType = "spec" SourceTypeSwaggerUI SourceType = "swagger-ui" SourceTypeRedoc SourceType = "redoc" )
type WalkDocumentResult ¶
func WalkDocument ¶
func WalkDocument(doc *libopenapi.DocumentModel[v3.Document]) WalkDocumentResult