openapidocument

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 23 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

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 CollectSchemaProxies

func CollectSchemaProxies(doc *libopenapi.DocumentModel[v3.Document]) map[string]*base.SchemaProxy

CollectSchemaProxies collects all schema proxies from the OpenAPI document.

func CollectSchemas

func CollectSchemas(doc *libopenapi.DocumentModel[v3.Document]) map[string]*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

func ConvertDocument(bytes []byte, format string) ([]byte, error)

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 IsEmptySchema(schema *base.Schema) bool

func IsEnumSchema

func IsEnumSchema(s *base.Schema) bool

IsEnumSchema returns true if the schema is an enum schema

func IsMutable

func IsMutable(schema *base.Schema) (bool, error)

func IsPolymorphicSchema

func IsPolymorphicSchema(s *base.Schema) bool

IsPolymorphicSchema returns true if the schema is a polymorphic schema (allOf, oneOf, anyOf)

func MergeSchema

func MergeSchema(result *base.Schema, override *base.Schema) (*base.Schema, error)

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 MergeSchemaProxySchema(baseSP *base.SchemaProxy, override *base.Schema) (*base.Schema, error)

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 AllowedValue struct {
	Value       string `yaml:"value"`
	Description string `yaml:"description,omitempty"`
	Name        string `yaml:"name,omitempty"`
}

type SchemaMatchFunc

type SchemaMatchFunc func(schema *base.Schema) bool

type SourceType

type SourceType string
const (
	SourceTypeSpec      SourceType = "spec"
	SourceTypeSwaggerUI SourceType = "swagger-ui"
	SourceTypeRedoc     SourceType = "redoc"
)

type SpecType

type SpecType string
const (
	SpecTypeOpenAPI3 SpecType = "openapi3"
	SpecTypeSwagger2 SpecType = "swagger2"
)

type WalkDocumentResult

type WalkDocumentResult struct {
	Schemas []*base.Schema
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL