package openapi3
import "github.com/getkin/kin-openapi/openapi3"
Package openapi3 parses and writes OpenAPI 3 specification documents.
See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md
Code generated by go generate; DO NOT EDIT.
Code:play
Output:Example¶
//go:build go1.16
// +build go1.16
package main
import (
"embed"
"fmt"
"net/url"
"github.com/getkin/kin-openapi/openapi3"
)
//go:embed testdata/recursiveRef/*
var fs embed.FS
func main() {
loader := openapi3.NewLoader()
loader.IsExternalRefsAllowed = true
loader.ReadFromURIFunc = func(loader *openapi3.Loader, uri *url.URL) ([]byte, error) {
return fs.ReadFile(uri.Path)
}
doc, err := loader.LoadFromFile("testdata/recursiveRef/openapi.yml")
if err != nil {
panic(err)
}
if err = doc.Validate(loader.Context); err != nil {
panic(err)
}
fmt.Println(doc.
Paths.Value("/foo").
Get.Responses.Value("200").Value.
Content["application/json"].
Schema.Value.
Properties["foo2"].Value.
Properties["foo"].Value.
Properties["bar"].Value.
Type,
)
}
&[string]
Index ¶
- Constants
- Variables
- func BoolPtr(value bool) *bool
- func DefaultRefNameResolver(doc *T, ref ComponentRef) string
- func DefineIPv4Format()
- func DefineIPv6Format()
- func DefineIntegerFormatValidator(name string, validator IntegerFormatValidator)
- func DefineNumberFormatValidator(name string, validator NumberFormatValidator)
- func DefineStringFormat(name string, pattern string)
- func DefineStringFormatCallback(name string, callback func(string) error)
- func DefineStringFormatValidator(name string, validator StringFormatValidator)
- func Float64Ptr(value float64) *float64
- func Int64Ptr(value int64) *int64
- func ReadFromFile(loader *Loader, location *url.URL) ([]byte, error)
- func ReferencesComponentInRootDocument(doc *T, ref ComponentRef) (string, bool)
- func RegisterArrayUniqueItemsChecker(fn SliceUniqueItemsChecker)
- func Uint64Ptr(value uint64) *uint64
- func ValidateIdentifier(value string) error
- func WithValidationOptions(ctx context.Context, opts ...ValidationOption) context.Context
- type AdditionalProperties
- func (addProps AdditionalProperties) MarshalJSON() ([]byte, error)
- func (addProps AdditionalProperties) MarshalYAML() (any, error)
- func (addProps *AdditionalProperties) UnmarshalJSON(data []byte) error
- type Callback
- func NewCallback(opts ...NewCallbackOption) *Callback
- func NewCallbackWithCapacity(cap int) *Callback
- func (callback *Callback) Delete(key string)
- func (callback Callback) JSONLookup(token string) (any, error)
- func (callback *Callback) Len() int
- func (callback *Callback) Map() (m map[string]*PathItem)
- func (callback *Callback) MarshalJSON() ([]byte, error)
- func (callback *Callback) MarshalYAML() (any, error)
- func (callback *Callback) Set(key string, value *PathItem)
- func (callback *Callback) UnmarshalJSON(data []byte) (err error)
- func (callback *Callback) Validate(ctx context.Context, opts ...ValidationOption) error
- func (callback *Callback) Value(key string) *PathItem
- type CallbackRef
- func (x *CallbackRef) CollectionName() string
- func (x *CallbackRef) JSONLookup(token string) (any, error)
- func (x CallbackRef) MarshalJSON() ([]byte, error)
- func (x CallbackRef) MarshalYAML() (any, error)
- func (x *CallbackRef) RefPath() *url.URL
- func (x *CallbackRef) RefString() string
- func (x *CallbackRef) UnmarshalJSON(data []byte) error
- func (x *CallbackRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type Callbacks
- func (m Callbacks) JSONLookup(token string) (any, error)
- func (callbacks *Callbacks) UnmarshalJSON(data []byte) (err error)
- type ComponentRef
- type Components
- func NewComponents() Components
- func (components Components) MarshalJSON() ([]byte, error)
- func (components Components) MarshalYAML() (any, error)
- func (components *Components) UnmarshalJSON(data []byte) error
- func (components *Components) Validate(ctx context.Context, opts ...ValidationOption) (err error)
- type Contact
- func (contact Contact) MarshalJSON() ([]byte, error)
- func (contact Contact) MarshalYAML() (any, error)
- func (contact *Contact) UnmarshalJSON(data []byte) error
- func (contact *Contact) Validate(ctx context.Context, opts ...ValidationOption) error
- type Content
- func NewContent() Content
- func NewContentWithFormDataSchema(schema *Schema) Content
- func NewContentWithFormDataSchemaRef(schema *SchemaRef) Content
- func NewContentWithJSONSchema(schema *Schema) Content
- func NewContentWithJSONSchemaRef(schema *SchemaRef) Content
- func NewContentWithSchema(schema *Schema, consumes []string) Content
- func NewContentWithSchemaRef(schema *SchemaRef, consumes []string) Content
- func (content Content) Get(mime string) *MediaType
- func (content *Content) UnmarshalJSON(data []byte) (err error)
- func (content Content) Validate(ctx context.Context, opts ...ValidationOption) error
- type Discriminator
- func (discriminator Discriminator) MarshalJSON() ([]byte, error)
- func (discriminator Discriminator) MarshalYAML() (any, error)
- func (discriminator *Discriminator) UnmarshalJSON(data []byte) error
- func (discriminator *Discriminator) Validate(ctx context.Context, opts ...ValidationOption) error
- type Encoding
- func NewEncoding() *Encoding
- func (encoding Encoding) MarshalJSON() ([]byte, error)
- func (encoding Encoding) MarshalYAML() (any, error)
- func (encoding *Encoding) SerializationMethod() *SerializationMethod
- func (encoding *Encoding) UnmarshalJSON(data []byte) error
- func (encoding *Encoding) Validate(ctx context.Context, opts ...ValidationOption) error
- func (encoding *Encoding) WithHeader(name string, header *Header) *Encoding
- func (encoding *Encoding) WithHeaderRef(name string, ref *HeaderRef) *Encoding
- type Example
- func NewExample(value any) *Example
- func (example Example) MarshalJSON() ([]byte, error)
- func (example Example) MarshalYAML() (any, error)
- func (example *Example) UnmarshalJSON(data []byte) error
- func (example *Example) Validate(ctx context.Context, opts ...ValidationOption) error
- type ExampleRef
- func (x *ExampleRef) CollectionName() string
- func (x *ExampleRef) JSONLookup(token string) (any, error)
- func (x ExampleRef) MarshalJSON() ([]byte, error)
- func (x ExampleRef) MarshalYAML() (any, error)
- func (x *ExampleRef) RefPath() *url.URL
- func (x *ExampleRef) RefString() string
- func (x *ExampleRef) UnmarshalJSON(data []byte) error
- func (x *ExampleRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type Examples
- func (m Examples) JSONLookup(token string) (any, error)
- func (examples *Examples) UnmarshalJSON(data []byte) (err error)
- type ExternalDocs
- func (e ExternalDocs) MarshalJSON() ([]byte, error)
- func (e ExternalDocs) MarshalYAML() (any, error)
- func (e *ExternalDocs) UnmarshalJSON(data []byte) error
- func (e *ExternalDocs) Validate(ctx context.Context, opts ...ValidationOption) error
- type FormatValidator
- func NewCallbackValidator[T any](fn func(T) error) FormatValidator[T]
- func NewIPValidator(isIPv4 bool) FormatValidator[string]
- func NewRangeFormatValidator[T int64 | float64](min, max T) FormatValidator[T]
- type Header
- func (header Header) JSONLookup(token string) (any, error)
- func (header Header) MarshalJSON() ([]byte, error)
- func (header Header) MarshalYAML() (any, error)
- func (header *Header) SerializationMethod() (*SerializationMethod, error)
- func (header *Header) UnmarshalJSON(data []byte) error
- func (header *Header) Validate(ctx context.Context, opts ...ValidationOption) error
- type HeaderRef
- func (x *HeaderRef) CollectionName() string
- func (x *HeaderRef) JSONLookup(token string) (any, error)
- func (x HeaderRef) MarshalJSON() ([]byte, error)
- func (x HeaderRef) MarshalYAML() (any, error)
- func (x *HeaderRef) RefPath() *url.URL
- func (x *HeaderRef) RefString() string
- func (x *HeaderRef) UnmarshalJSON(data []byte) error
- func (x *HeaderRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type Headers
- func (m Headers) JSONLookup(token string) (any, error)
- func (headers *Headers) UnmarshalJSON(data []byte) (err error)
- type Info
- func (info Info) MarshalJSON() ([]byte, error)
- func (info *Info) MarshalYAML() (any, error)
- func (info *Info) UnmarshalJSON(data []byte) error
- func (info *Info) Validate(ctx context.Context, opts ...ValidationOption) error
- type IntegerFormatValidator
- type License
- func (license License) MarshalJSON() ([]byte, error)
- func (license License) MarshalYAML() (any, error)
- func (license *License) UnmarshalJSON(data []byte) error
- func (license *License) Validate(ctx context.Context, opts ...ValidationOption) error
- type Link
- func (link Link) MarshalJSON() ([]byte, error)
- func (link Link) MarshalYAML() (any, error)
- func (link *Link) UnmarshalJSON(data []byte) error
- func (link *Link) Validate(ctx context.Context, opts ...ValidationOption) error
- type LinkRef
- func (x *LinkRef) CollectionName() string
- func (x *LinkRef) JSONLookup(token string) (any, error)
- func (x LinkRef) MarshalJSON() ([]byte, error)
- func (x LinkRef) MarshalYAML() (any, error)
- func (x *LinkRef) RefPath() *url.URL
- func (x *LinkRef) RefString() string
- func (x *LinkRef) UnmarshalJSON(data []byte) error
- func (x *LinkRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type Links
- func (m Links) JSONLookup(token string) (any, error)
- func (links *Links) UnmarshalJSON(data []byte) (err error)
- type Loader
- func NewLoader() *Loader
- func (loader *Loader) LoadFromData(data []byte) (*T, error)
- func (loader *Loader) LoadFromDataWithPath(data []byte, location *url.URL) (*T, error)
- func (loader *Loader) LoadFromFile(location string) (*T, error)
- func (loader *Loader) LoadFromIoReader(reader io.Reader) (*T, error)
- func (loader *Loader) LoadFromStdin() (*T, error)
- func (loader *Loader) LoadFromURI(location *url.URL) (*T, error)
- func (loader *Loader) ResolveRefsIn(doc *T, location *url.URL) (err error)
- type Location
- type MediaType
- func NewMediaType() *MediaType
- func (mediaType MediaType) JSONLookup(token string) (any, error)
- func (mediaType MediaType) MarshalJSON() ([]byte, error)
- func (mediaType MediaType) MarshalYAML() (any, error)
- func (mediaType *MediaType) UnmarshalJSON(data []byte) error
- func (mediaType *MediaType) Validate(ctx context.Context, opts ...ValidationOption) error
- func (mediaType *MediaType) WithEncoding(name string, enc *Encoding) *MediaType
- func (mediaType *MediaType) WithExample(name string, value any) *MediaType
- func (mediaType *MediaType) WithSchema(schema *Schema) *MediaType
- func (mediaType *MediaType) WithSchemaRef(schema *SchemaRef) *MediaType
- type MultiError
- func (me MultiError) As(target any) bool
- func (me MultiError) Error() string
- func (me MultiError) Is(target error) bool
- type NewCallbackOption
- type NewPathsOption
- type NewResponsesOption
- func WithName(name string, response *Response) NewResponsesOption
- func WithStatus(status int, responseRef *ResponseRef) NewResponsesOption
- type NumberFormatValidator
- type OAuthFlow
- func (flow OAuthFlow) MarshalJSON() ([]byte, error)
- func (flow OAuthFlow) MarshalYAML() (any, error)
- func (flow *OAuthFlow) UnmarshalJSON(data []byte) error
- func (flow *OAuthFlow) Validate(ctx context.Context, opts ...ValidationOption) error
- type OAuthFlows
- func (flows OAuthFlows) MarshalJSON() ([]byte, error)
- func (flows OAuthFlows) MarshalYAML() (any, error)
- func (flows *OAuthFlows) UnmarshalJSON(data []byte) error
- func (flows *OAuthFlows) Validate(ctx context.Context, opts ...ValidationOption) error
- type Operation
- func NewOperation() *Operation
- func (operation *Operation) AddParameter(p *Parameter)
- func (operation *Operation) AddResponse(status int, response *Response)
- func (operation Operation) JSONLookup(token string) (any, error)
- func (operation Operation) MarshalJSON() ([]byte, error)
- func (operation Operation) MarshalYAML() (any, error)
- func (operation *Operation) UnmarshalJSON(data []byte) error
- func (operation *Operation) Validate(ctx context.Context, opts ...ValidationOption) error
- type Origin
- type Parameter
- func NewCookieParameter(name string) *Parameter
- func NewHeaderParameter(name string) *Parameter
- func NewPathParameter(name string) *Parameter
- func NewQueryParameter(name string) *Parameter
- func (parameter Parameter) JSONLookup(token string) (any, error)
- func (parameter Parameter) MarshalJSON() ([]byte, error)
- func (parameter Parameter) MarshalYAML() (any, error)
- func (parameter *Parameter) SerializationMethod() (*SerializationMethod, error)
- func (parameter *Parameter) UnmarshalJSON(data []byte) error
- func (parameter *Parameter) Validate(ctx context.Context, opts ...ValidationOption) error
- func (parameter *Parameter) WithDescription(value string) *Parameter
- func (parameter *Parameter) WithRequired(value bool) *Parameter
- func (parameter *Parameter) WithSchema(value *Schema) *Parameter
- type ParameterRef
- func (x *ParameterRef) CollectionName() string
- func (x *ParameterRef) JSONLookup(token string) (any, error)
- func (x ParameterRef) MarshalJSON() ([]byte, error)
- func (x ParameterRef) MarshalYAML() (any, error)
- func (x *ParameterRef) RefPath() *url.URL
- func (x *ParameterRef) RefString() string
- func (x *ParameterRef) UnmarshalJSON(data []byte) error
- func (x *ParameterRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type Parameters
- func NewParameters() Parameters
- func (parameters Parameters) GetByInAndName(in string, name string) *Parameter
- func (p Parameters) JSONLookup(token string) (any, error)
- func (parameters Parameters) Validate(ctx context.Context, opts ...ValidationOption) error
- type ParametersMap
- func (m ParametersMap) JSONLookup(token string) (any, error)
- func (parametersMap *ParametersMap) UnmarshalJSON(data []byte) (err error)
- type PathItem
- func (pathItem *PathItem) GetOperation(method string) *Operation
- func (pathItem PathItem) MarshalJSON() ([]byte, error)
- func (pathItem PathItem) MarshalYAML() (any, error)
- func (pathItem *PathItem) Operations() map[string]*Operation
- func (pathItem *PathItem) SetOperation(method string, operation *Operation)
- func (pathItem *PathItem) UnmarshalJSON(data []byte) error
- func (pathItem *PathItem) Validate(ctx context.Context, opts ...ValidationOption) error
- type Paths
- func NewPaths(opts ...NewPathsOption) *Paths
- func NewPathsWithCapacity(cap int) *Paths
- func (paths *Paths) Delete(key string)
- func (paths *Paths) Find(key string) *PathItem
- func (paths *Paths) InMatchingOrder() []string
- func (paths Paths) JSONLookup(token string) (any, error)
- func (paths *Paths) Len() int
- func (paths *Paths) Map() (m map[string]*PathItem)
- func (paths *Paths) MarshalJSON() ([]byte, error)
- func (paths *Paths) MarshalYAML() (any, error)
- func (paths *Paths) Set(key string, value *PathItem)
- func (paths *Paths) UnmarshalJSON(data []byte) (err error)
- func (paths *Paths) Validate(ctx context.Context, opts ...ValidationOption) error
- func (paths *Paths) Value(key string) *PathItem
- type ReadFromURIFunc
- func ReadFromHTTP(cl *http.Client) ReadFromURIFunc
- func ReadFromURIs(readers ...ReadFromURIFunc) ReadFromURIFunc
- func URIMapCache(reader ReadFromURIFunc) ReadFromURIFunc
- type Ref
- type RefNameResolver
- type RegexCompilerFunc
- type RegexMatcher
- type RequestBodies
- func (m RequestBodies) JSONLookup(token string) (any, error)
- func (requestBodies *RequestBodies) UnmarshalJSON(data []byte) (err error)
- type RequestBody
- func NewRequestBody() *RequestBody
- func (requestBody *RequestBody) GetMediaType(mediaType string) *MediaType
- func (requestBody RequestBody) MarshalJSON() ([]byte, error)
- func (requestBody RequestBody) MarshalYAML() (any, error)
- func (requestBody *RequestBody) UnmarshalJSON(data []byte) error
- func (requestBody *RequestBody) Validate(ctx context.Context, opts ...ValidationOption) error
- func (requestBody *RequestBody) WithContent(content Content) *RequestBody
- func (requestBody *RequestBody) WithDescription(value string) *RequestBody
- func (requestBody *RequestBody) WithFormDataSchema(value *Schema) *RequestBody
- func (requestBody *RequestBody) WithFormDataSchemaRef(value *SchemaRef) *RequestBody
- func (requestBody *RequestBody) WithJSONSchema(value *Schema) *RequestBody
- func (requestBody *RequestBody) WithJSONSchemaRef(value *SchemaRef) *RequestBody
- func (requestBody *RequestBody) WithRequired(value bool) *RequestBody
- func (requestBody *RequestBody) WithSchema(value *Schema, consumes []string) *RequestBody
- func (requestBody *RequestBody) WithSchemaRef(value *SchemaRef, consumes []string) *RequestBody
- type RequestBodyRef
- func (x *RequestBodyRef) CollectionName() string
- func (x *RequestBodyRef) JSONLookup(token string) (any, error)
- func (x RequestBodyRef) MarshalJSON() ([]byte, error)
- func (x RequestBodyRef) MarshalYAML() (any, error)
- func (x *RequestBodyRef) RefPath() *url.URL
- func (x *RequestBodyRef) RefString() string
- func (x *RequestBodyRef) UnmarshalJSON(data []byte) error
- func (x *RequestBodyRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type Response
- func NewResponse() *Response
- func (response Response) MarshalJSON() ([]byte, error)
- func (response Response) MarshalYAML() (any, error)
- func (response *Response) UnmarshalJSON(data []byte) error
- func (response *Response) Validate(ctx context.Context, opts ...ValidationOption) error
- func (response *Response) WithContent(content Content) *Response
- func (response *Response) WithDescription(value string) *Response
- func (response *Response) WithJSONSchema(schema *Schema) *Response
- func (response *Response) WithJSONSchemaRef(schema *SchemaRef) *Response
- type ResponseBodies
- func (m ResponseBodies) JSONLookup(token string) (any, error)
- func (responseBodies *ResponseBodies) UnmarshalJSON(data []byte) (err error)
- type ResponseRef
- func (x *ResponseRef) CollectionName() string
- func (x *ResponseRef) JSONLookup(token string) (any, error)
- func (x ResponseRef) MarshalJSON() ([]byte, error)
- func (x ResponseRef) MarshalYAML() (any, error)
- func (x *ResponseRef) RefPath() *url.URL
- func (x *ResponseRef) RefString() string
- func (x *ResponseRef) UnmarshalJSON(data []byte) error
- func (x *ResponseRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type Responses
- func NewResponses(opts ...NewResponsesOption) *Responses
- func NewResponsesWithCapacity(cap int) *Responses
- func (responses *Responses) Default() *ResponseRef
- func (responses *Responses) Delete(key string)
- func (responses Responses) JSONLookup(token string) (any, error)
- func (responses *Responses) Len() int
- func (responses *Responses) Map() (m map[string]*ResponseRef)
- func (responses *Responses) MarshalJSON() ([]byte, error)
- func (responses *Responses) MarshalYAML() (any, error)
- func (responses *Responses) Set(key string, value *ResponseRef)
- func (responses *Responses) Status(status int) *ResponseRef
- func (responses *Responses) UnmarshalJSON(data []byte) (err error)
- func (responses *Responses) Validate(ctx context.Context, opts ...ValidationOption) error
- func (responses *Responses) Value(key string) *ResponseRef
- type Schema
- func NewAllOfSchema(schemas ...*Schema) *Schema
- func NewAnyOfSchema(schemas ...*Schema) *Schema
- func NewArraySchema() *Schema
- func NewBoolSchema() *Schema
- func NewBytesSchema() *Schema
- func NewDateTimeSchema() *Schema
- func NewFloat64Schema() *Schema
- func NewInt32Schema() *Schema
- func NewInt64Schema() *Schema
- func NewIntegerSchema() *Schema
- func NewObjectSchema() *Schema
- func NewOneOfSchema(schemas ...*Schema) *Schema
- func NewSchema() *Schema
- func NewStringSchema() *Schema
- func NewUUIDSchema() *Schema
- func (schema *Schema) IsEmpty() bool
- func (schema *Schema) IsMatching(value any) bool
- func (schema *Schema) IsMatchingJSONArray(value []any) bool
- func (schema *Schema) IsMatchingJSONBoolean(value bool) bool
- func (schema *Schema) IsMatchingJSONNumber(value float64) bool
- func (schema *Schema) IsMatchingJSONObject(value map[string]any) bool
- func (schema *Schema) IsMatchingJSONString(value string) bool
- func (schema Schema) JSONLookup(token string) (any, error)
- func (schema Schema) MarshalJSON() ([]byte, error)
- func (schema Schema) MarshalYAML() (any, error)
- func (schema *Schema) NewRef() *SchemaRef
- func (schema *Schema) PermitsNull() bool
- func (schema *Schema) UnmarshalJSON(data []byte) error
- func (schema *Schema) Validate(ctx context.Context, opts ...ValidationOption) error
- func (schema *Schema) VisitJSON(value any, opts ...SchemaValidationOption) error
- func (schema *Schema) VisitJSONArray(value []any) error
- func (schema *Schema) VisitJSONBoolean(value bool) error
- func (schema *Schema) VisitJSONNumber(value float64) error
- func (schema *Schema) VisitJSONObject(value map[string]any) error
- func (schema *Schema) VisitJSONString(value string) error
- func (schema *Schema) WithAdditionalProperties(v *Schema) *Schema
- func (schema *Schema) WithAnyAdditionalProperties() *Schema
- func (schema *Schema) WithDefault(defaultValue any) *Schema
- func (schema *Schema) WithEnum(values ...any) *Schema
- func (schema *Schema) WithExclusiveMax(value bool) *Schema
- func (schema *Schema) WithExclusiveMin(value bool) *Schema
- func (schema *Schema) WithFormat(value string) *Schema
- func (schema *Schema) WithItems(value *Schema) *Schema
- func (schema *Schema) WithLength(i int64) *Schema
- func (schema *Schema) WithLengthDecodedBase64(i int64) *Schema
- func (schema *Schema) WithMax(value float64) *Schema
- func (schema *Schema) WithMaxItems(i int64) *Schema
- func (schema *Schema) WithMaxLength(i int64) *Schema
- func (schema *Schema) WithMaxLengthDecodedBase64(i int64) *Schema
- func (schema *Schema) WithMaxProperties(i int64) *Schema
- func (schema *Schema) WithMin(value float64) *Schema
- func (schema *Schema) WithMinItems(i int64) *Schema
- func (schema *Schema) WithMinLength(i int64) *Schema
- func (schema *Schema) WithMinLengthDecodedBase64(i int64) *Schema
- func (schema *Schema) WithMinProperties(i int64) *Schema
- func (schema *Schema) WithNullable() *Schema
- func (schema *Schema) WithPattern(pattern string) *Schema
- func (schema *Schema) WithProperties(properties map[string]*Schema) *Schema
- func (schema *Schema) WithProperty(name string, propertySchema *Schema) *Schema
- func (schema *Schema) WithPropertyRef(name string, ref *SchemaRef) *Schema
- func (schema *Schema) WithRequired(required []string) *Schema
- func (schema *Schema) WithUniqueItems(unique bool) *Schema
- func (schema *Schema) WithoutAdditionalProperties() *Schema
- type SchemaError
- func (err *SchemaError) Error() string
- func (err *SchemaError) JSONPointer() []string
- func (err SchemaError) Unwrap() error
- type SchemaRef
- func NewSchemaRef(ref string, value *Schema) *SchemaRef
- func (x *SchemaRef) CollectionName() string
- func (x *SchemaRef) JSONLookup(token string) (any, error)
- func (x SchemaRef) MarshalJSON() ([]byte, error)
- func (x SchemaRef) MarshalYAML() (any, error)
- func (x *SchemaRef) RefPath() *url.URL
- func (x *SchemaRef) RefString() string
- func (x *SchemaRef) UnmarshalJSON(data []byte) error
- func (x *SchemaRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type SchemaRefs
- type SchemaValidationOption
- func DefaultsSet(f func()) SchemaValidationOption
- func DisablePatternValidation() SchemaValidationOption
- func DisableReadOnlyValidation() SchemaValidationOption
- func DisableWriteOnlyValidation() SchemaValidationOption
- func EnableFormatValidation() SchemaValidationOption
- func FailFast() SchemaValidationOption
- func MultiErrors() SchemaValidationOption
- func SetSchemaErrorMessageCustomizer(f func(err *SchemaError) string) SchemaValidationOption
- func SetSchemaRegexCompiler(c RegexCompilerFunc) SchemaValidationOption
- func VisitAsRequest() SchemaValidationOption
- func VisitAsResponse() SchemaValidationOption
- type Schemas
- func (m Schemas) JSONLookup(token string) (any, error)
- func (schemas *Schemas) UnmarshalJSON(data []byte) (err error)
- type SecurityRequirement
- func NewSecurityRequirement() SecurityRequirement
- func (security SecurityRequirement) Authenticate(provider string, scopes ...string) SecurityRequirement
- func (security *SecurityRequirement) UnmarshalJSON(data []byte) (err error)
- func (security *SecurityRequirement) Validate(ctx context.Context, opts ...ValidationOption) error
- type SecurityRequirements
- func NewSecurityRequirements() *SecurityRequirements
- func (srs SecurityRequirements) Validate(ctx context.Context, opts ...ValidationOption) error
- func (srs *SecurityRequirements) With(securityRequirement SecurityRequirement) *SecurityRequirements
- type SecurityScheme
- func NewCSRFSecurityScheme() *SecurityScheme
- func NewJWTSecurityScheme() *SecurityScheme
- func NewOIDCSecurityScheme(oidcUrl string) *SecurityScheme
- func NewSecurityScheme() *SecurityScheme
- func (ss SecurityScheme) MarshalJSON() ([]byte, error)
- func (ss SecurityScheme) MarshalYAML() (any, error)
- func (ss *SecurityScheme) UnmarshalJSON(data []byte) error
- func (ss *SecurityScheme) Validate(ctx context.Context, opts ...ValidationOption) error
- func (ss *SecurityScheme) WithBearerFormat(value string) *SecurityScheme
- func (ss *SecurityScheme) WithDescription(value string) *SecurityScheme
- func (ss *SecurityScheme) WithIn(value string) *SecurityScheme
- func (ss *SecurityScheme) WithName(value string) *SecurityScheme
- func (ss *SecurityScheme) WithScheme(value string) *SecurityScheme
- func (ss *SecurityScheme) WithType(value string) *SecurityScheme
- type SecuritySchemeRef
- func (x *SecuritySchemeRef) CollectionName() string
- func (x *SecuritySchemeRef) JSONLookup(token string) (any, error)
- func (x SecuritySchemeRef) MarshalJSON() ([]byte, error)
- func (x SecuritySchemeRef) MarshalYAML() (any, error)
- func (x *SecuritySchemeRef) RefPath() *url.URL
- func (x *SecuritySchemeRef) RefString() string
- func (x *SecuritySchemeRef) UnmarshalJSON(data []byte) error
- func (x *SecuritySchemeRef) Validate(ctx context.Context, opts ...ValidationOption) error
- type SecuritySchemes
- func (m SecuritySchemes) JSONLookup(token string) (any, error)
- func (securitySchemes *SecuritySchemes) UnmarshalJSON(data []byte) (err error)
- type SerializationMethod
- type Server
- func (server *Server) BasePath() (string, error)
- func (server Server) MarshalJSON() ([]byte, error)
- func (server Server) MarshalYAML() (any, error)
- func (server Server) MatchRawURL(input string) ([]string, string, bool)
- func (server Server) ParameterNames() ([]string, error)
- func (server *Server) UnmarshalJSON(data []byte) error
- func (server *Server) Validate(ctx context.Context, opts ...ValidationOption) (err error)
- type ServerVariable
- func (serverVariable ServerVariable) MarshalJSON() ([]byte, error)
- func (serverVariable ServerVariable) MarshalYAML() (any, error)
- func (serverVariable *ServerVariable) UnmarshalJSON(data []byte) error
- func (serverVariable *ServerVariable) Validate(ctx context.Context, opts ...ValidationOption) error
- type Servers
- func (servers Servers) BasePath() (string, error)
- func (servers Servers) MatchURL(parsedURL *url.URL) (*Server, []string, string)
- func (servers Servers) Validate(ctx context.Context, opts ...ValidationOption) error
- type SliceUniqueItemsChecker
- type StringFormatValidator
- type StringMap
- type T
- func (doc *T) AddOperation(path string, method string, operation *Operation)
- func (doc *T) AddServer(server *Server)
- func (doc *T) AddServers(servers ...*Server)
- func (doc *T) InternalizeRefs(ctx context.Context, refNameResolver func(*T, ComponentRef) string)
- func (doc *T) JSONLookup(token string) (any, error)
- func (doc *T) MarshalJSON() ([]byte, error)
- func (doc *T) MarshalYAML() (any, error)
- func (doc *T) UnmarshalJSON(data []byte) error
- func (doc *T) Validate(ctx context.Context, opts ...ValidationOption) error
- type Tag
- func (t Tag) MarshalJSON() ([]byte, error)
- func (t Tag) MarshalYAML() (any, error)
- func (t *Tag) UnmarshalJSON(data []byte) error
- func (t *Tag) Validate(ctx context.Context, opts ...ValidationOption) error
- type Tags
- func (tags Tags) Get(name string) *Tag
- func (tags Tags) Validate(ctx context.Context, opts ...ValidationOption) error
- type Types
- func (pTypes *Types) Includes(typ string) bool
- func (types *Types) Is(typ string) bool
- func (pTypes *Types) MarshalJSON() ([]byte, error)
- func (pTypes *Types) MarshalYAML() (any, error)
- func (types *Types) Permits(typ string) bool
- func (types *Types) Slice() []string
- func (types *Types) UnmarshalJSON(data []byte) error
- type ValidationOption
- func AllowExtensionsWithRef() ValidationOption
- func AllowExtraSiblingFields(fields ...string) ValidationOption
- func DisableExamplesValidation() ValidationOption
- func DisableSchemaDefaultsValidation() ValidationOption
- func DisableSchemaFormatValidation() ValidationOption
- func DisableSchemaPatternValidation() ValidationOption
- func EnableExamplesValidation() ValidationOption
- func EnableSchemaDefaultsValidation() ValidationOption
- func EnableSchemaFormatValidation() ValidationOption
- func EnableSchemaPatternValidation() ValidationOption
- func ProhibitExtensionsWithRef() ValidationOption
- func SetRegexCompiler(c RegexCompilerFunc) ValidationOption
- type ValidationOptions
- type XML
Examples ¶
Constants ¶
const ( ParameterInPath = "path" ParameterInQuery = "query" ParameterInHeader = "header" ParameterInCookie = "cookie" )
const ( TypeArray = "array" TypeBoolean = "boolean" TypeInteger = "integer" TypeNumber = "number" TypeObject = "object" TypeString = "string" TypeNull = "null" )
const ( FormatOfStringForUUIDOfRFC4122 = "" /* 133 byte string literal not displayed */ FormatOfStringForEmail = `^[^@]+@[^@<>",\s]+$` FormatOfStringByte = `(^$|^[a-zA-Z0-9+/\-_]*=*$)` FormatOfStringDate = `^[0-9]{4}-(0[1-9]|10|11|12)-(0[1-9]|[12][0-9]|3[01])$` FormatOfStringDateTime = "" /* 141 byte string literal not displayed */ )
const ( SerializationSimple = "simple" SerializationLabel = "label" SerializationMatrix = "matrix" SerializationForm = "form" SerializationSpaceDelimited = "spaceDelimited" SerializationPipeDelimited = "pipeDelimited" SerializationDeepObject = "deepObject" )
Variables ¶
var ( IdentifierRegExp = regexp.MustCompile(`^[` + identifierChars + `]+$`) InvalidIdentifierCharRegExp = regexp.MustCompile(`[^` + identifierChars + `]`) )
IdentifierRegExp verifies whether Component object key matches contains just 'identifierChars', according to OpenAPI v3.x. InvalidIdentifierCharRegExp matches all characters not contained in 'identifierChars'. However, to be able supporting legacy OpenAPI v2.x, there is a need to customize above pattern in order not to fail converted v2-v3 validation
var ( // SchemaErrorDetailsDisabled disables printing of details about schema errors. SchemaErrorDetailsDisabled = false // ErrOneOfConflict is the SchemaError Origin when data matches more than one oneOf schema ErrOneOfConflict = errors.New("input matches more than one oneOf schemas") // ErrSchemaInputNaN may be returned when validating a number ErrSchemaInputNaN = errors.New("floating point NaN is not allowed") // ErrSchemaInputInf may be returned when validating a number ErrSchemaInputInf = errors.New("floating point Inf is not allowed") )
var ( // SchemaStringFormats is a map of custom string format validators. SchemaStringFormats = make(map[string]StringFormatValidator) // SchemaNumberFormats is a map of custom number format validators. SchemaNumberFormats = make(map[string]NumberFormatValidator) // SchemaIntegerFormats is a map of custom integer format validators. SchemaIntegerFormats = make(map[string]IntegerFormatValidator) )
var DefaultReadFromURI = URIMapCache(ReadFromURIs(ReadFromHTTP(http.DefaultClient), ReadFromFile))
DefaultReadFromURI returns a caching ReadFromURIFunc which can read remote HTTP URIs and local file URIs.
ErrURINotSupported indicates the ReadFromURIFunc does not know how to handle a given URI.
Functions ¶
func BoolPtr ¶
BoolPtr is a helper for defining OpenAPI schemas.
func DefaultRefNameResolver ¶
func DefaultRefNameResolver(doc *T, ref ComponentRef) string
DefaultRefResolver is a default implementation of refNameResolver for the InternalizeRefs function.
The external reference is internalized to (hopefully) a unique name. If the external reference matches (by path) to another reference in the root document then the name of that component is used.
The transformation involves:
- Cutting the "#/components/<type>" part.
- Cutting the file extensions (.yaml/.json) from documents.
- Trimming the common directory with the root spec.
- Replace invalid characters with with underscores.
This is an injective mapping over a "reasonable" amount of the possible openapi spec domain space but is not perfect. There might be edge cases.
func DefineIPv4Format ¶
func DefineIPv4Format()
DefineIPv4Format opts in ipv4 format validation on top of OAS 3 spec
func DefineIPv6Format ¶
func DefineIPv6Format()
DefineIPv6Format opts in ipv6 format validation on top of OAS 3 spec
func DefineIntegerFormatValidator ¶
func DefineIntegerFormatValidator(name string, validator IntegerFormatValidator)
DefineIntegerFormatValidator defines a custom format validator for a given integer format.
func DefineNumberFormatValidator ¶
func DefineNumberFormatValidator(name string, validator NumberFormatValidator)
DefineNumberFormatValidator defines a custom format validator for a given number format.
func DefineStringFormat ¶
DefineStringFormat defines a regexp pattern for a given string format
Deprecated: Use openapi3.DefineStringFormatValidator(name, NewRegexpFormatValidator(pattern)) instead.
func DefineStringFormatCallback ¶
DefineStringFormatCallback defines a callback function for a given string format
Deprecated: Use openapi3.DefineStringFormatValidator(name, NewCallbackValidator(fn)) instead.
func DefineStringFormatValidator ¶
func DefineStringFormatValidator(name string, validator StringFormatValidator)
DefineStringFormatValidator defines a custom format validator for a given string format.
func Float64Ptr ¶
Float64Ptr is a helper for defining OpenAPI schemas.
func Int64Ptr ¶
Int64Ptr is a helper for defining OpenAPI schemas.
func ReadFromFile ¶
ReadFromFile is a ReadFromURIFunc which reads local file URIs.
func ReferencesComponentInRootDocument ¶
func ReferencesComponentInRootDocument(doc *T, ref ComponentRef) (string, bool)
ReferencesComponentInRootDocument returns if the given component reference references the same document or element as another component reference in the root document's '#/components/<type>'. If it does, it returns the name of it in the form '#/components/<type>/NameXXX'
Of course given a component from the root document will always match itself.
https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#reference-object https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#relative-references-in-urls
Example. Take the spec with directory structure:
openapi.yaml schemas/ ├─ record.yaml ├─ records.yaml
In openapi.yaml we have:
components: schemas: Record: $ref: schemas/record.yaml
Case 1: records.yml references a component in the root document
$ref: ../openapi.yaml#/components/schemas/Record
This would return...
#/components/schemas/Record
Case 2: records.yml indirectly refers to the same schema as a schema the root document's '#/components/schemas'.
$ref: ./record.yaml
This would also return...
#/components/schemas/Record
func RegisterArrayUniqueItemsChecker ¶
func RegisterArrayUniqueItemsChecker(fn SliceUniqueItemsChecker)
RegisterArrayUniqueItemsChecker is used to register a customized function used to check if JSON array have unique items.
func Uint64Ptr ¶
Uint64Ptr is a helper for defining OpenAPI schemas.
func ValidateIdentifier ¶
ValidateIdentifier returns an error if the given component name does not match IdentifierRegExp.
func WithValidationOptions ¶
func WithValidationOptions(ctx context.Context, opts ...ValidationOption) context.Context
WithValidationOptions allows adding validation options to a context object that can be used when validating any OpenAPI type.
Types ¶
type AdditionalProperties ¶
func (AdditionalProperties) MarshalJSON ¶
func (addProps AdditionalProperties) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of AdditionalProperties.
func (AdditionalProperties) MarshalYAML ¶
func (addProps AdditionalProperties) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of AdditionalProperties.
func (*AdditionalProperties) UnmarshalJSON ¶
func (addProps *AdditionalProperties) UnmarshalJSON(data []byte) error
UnmarshalJSON sets AdditionalProperties to a copy of data.
type Callback ¶
type Callback struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` // contains filtered or unexported fields }
Callback is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object
func NewCallback ¶
func NewCallback(opts ...NewCallbackOption) *Callback
NewCallback builds a Callback object with path items in insertion order.
func NewCallbackWithCapacity ¶
NewCallbackWithCapacity builds a callback object of the given capacity.
func (*Callback) Delete ¶
Delete removes the entry associated with key 'key' from 'callback'.
func (Callback) JSONLookup ¶
JSONLookup implements https://github.com/go-openapi/jsonpointer#JSONPointable
func (*Callback) Len ¶
Len returns the amount of keys in callback excluding callback.Extensions.
func (*Callback) Map ¶
Map returns callback as a 'map'. Note: iteration on Go maps is not ordered.
func (*Callback) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Callback.
func (*Callback) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Callback.
func (*Callback) Set ¶
Set adds or replaces key 'key' of 'callback' with 'value'. Note: 'callback' MUST be non-nil
func (*Callback) UnmarshalJSON ¶
UnmarshalJSON sets Callback to a copy of data.
func (*Callback) Validate ¶
func (callback *Callback) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Callback does not comply with the OpenAPI spec.
func (*Callback) Value ¶
Value returns the callback for key or nil
type CallbackRef ¶
type CallbackRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *Callback // contains filtered or unexported fields }
CallbackRef represents either a Callback or a $ref to a Callback. When serializing and both fields are set, Ref is preferred over Value.
func (*CallbackRef) CollectionName ¶
func (x *CallbackRef) CollectionName() string
CollectionName returns the JSON string used for a collection of these components.
func (*CallbackRef) JSONLookup ¶
func (x *CallbackRef) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (CallbackRef) MarshalJSON ¶
func (x CallbackRef) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of CallbackRef.
func (CallbackRef) MarshalYAML ¶
func (x CallbackRef) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of CallbackRef.
func (*CallbackRef) RefPath ¶
func (x *CallbackRef) RefPath() *url.URL
RefPath returns the path of the $ref relative to the root document.
func (*CallbackRef) RefString ¶
func (x *CallbackRef) RefString() string
RefString returns the $ref value.
func (*CallbackRef) UnmarshalJSON ¶
func (x *CallbackRef) UnmarshalJSON(data []byte) error
UnmarshalJSON sets CallbackRef to a copy of data.
func (*CallbackRef) Validate ¶
func (x *CallbackRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if CallbackRef does not comply with the OpenAPI spec.
type Callbacks ¶
type Callbacks map[string]*CallbackRef
func (Callbacks) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*Callbacks) UnmarshalJSON ¶
UnmarshalJSON sets Callbacks to a copy of data.
type ComponentRef ¶
type Components ¶
type Components struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Schemas Schemas `json:"schemas,omitempty" yaml:"schemas,omitempty"` Parameters ParametersMap `json:"parameters,omitempty" yaml:"parameters,omitempty"` Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"` RequestBodies RequestBodies `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"` Responses ResponseBodies `json:"responses,omitempty" yaml:"responses,omitempty"` SecuritySchemes SecuritySchemes `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"` Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"` Links Links `json:"links,omitempty" yaml:"links,omitempty"` Callbacks Callbacks `json:"callbacks,omitempty" yaml:"callbacks,omitempty"` }
Components is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#components-object
func NewComponents ¶
func NewComponents() Components
func (Components) MarshalJSON ¶
func (components Components) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of Components.
func (Components) MarshalYAML ¶
func (components Components) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of Components.
func (*Components) UnmarshalJSON ¶
func (components *Components) UnmarshalJSON(data []byte) error
UnmarshalJSON sets Components to a copy of data.
func (*Components) Validate ¶
func (components *Components) Validate(ctx context.Context, opts ...ValidationOption) (err error)
Validate returns an error if Components does not comply with the OpenAPI spec.
type Contact ¶
type Contact struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` Email string `json:"email,omitempty" yaml:"email,omitempty"` }
Contact is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#contact-object
func (Contact) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Contact.
func (Contact) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Contact.
func (*Contact) UnmarshalJSON ¶
UnmarshalJSON sets Contact to a copy of data.
func (*Contact) Validate ¶
func (contact *Contact) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Contact does not comply with the OpenAPI spec.
type Content ¶
Content is specified by OpenAPI/Swagger 3.0 standard.
func NewContent ¶
func NewContent() Content
func NewContentWithFormDataSchema ¶
func NewContentWithFormDataSchemaRef ¶
func NewContentWithJSONSchema ¶
func NewContentWithJSONSchemaRef ¶
func NewContentWithSchema ¶
func NewContentWithSchemaRef ¶
func (Content) Get ¶
func (*Content) UnmarshalJSON ¶
UnmarshalJSON sets Content to a copy of data.
func (Content) Validate ¶
func (content Content) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Content does not comply with the OpenAPI spec.
type Discriminator ¶
type Discriminator struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` PropertyName string `json:"propertyName" yaml:"propertyName"` // required Mapping StringMap `json:"mapping,omitempty" yaml:"mapping,omitempty"` }
Discriminator is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminator-object
func (Discriminator) MarshalJSON ¶
func (discriminator Discriminator) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of Discriminator.
func (Discriminator) MarshalYAML ¶
func (discriminator Discriminator) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of Discriminator.
func (*Discriminator) UnmarshalJSON ¶
func (discriminator *Discriminator) UnmarshalJSON(data []byte) error
UnmarshalJSON sets Discriminator to a copy of data.
func (*Discriminator) Validate ¶
func (discriminator *Discriminator) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Discriminator does not comply with the OpenAPI spec.
type Encoding ¶
type Encoding struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` ContentType string `json:"contentType,omitempty" yaml:"contentType,omitempty"` Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"` Style string `json:"style,omitempty" yaml:"style,omitempty"` Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"` AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"` }
Encoding is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#encoding-object
func NewEncoding ¶
func NewEncoding() *Encoding
func (Encoding) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Encoding.
func (Encoding) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Encoding.
func (*Encoding) SerializationMethod ¶
func (encoding *Encoding) SerializationMethod() *SerializationMethod
SerializationMethod returns a serialization method of request body. When serialization method is not defined the method returns the default serialization method.
func (*Encoding) UnmarshalJSON ¶
UnmarshalJSON sets Encoding to a copy of data.
func (*Encoding) Validate ¶
func (encoding *Encoding) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Encoding does not comply with the OpenAPI spec.
func (*Encoding) WithHeader ¶
func (*Encoding) WithHeaderRef ¶
type Example ¶
type Example struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Value any `json:"value,omitempty" yaml:"value,omitempty"` ExternalValue string `json:"externalValue,omitempty" yaml:"externalValue,omitempty"` }
Example is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#example-object
func NewExample ¶
func (Example) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Example.
func (Example) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Example.
func (*Example) UnmarshalJSON ¶
UnmarshalJSON sets Example to a copy of data.
func (*Example) Validate ¶
func (example *Example) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Example does not comply with the OpenAPI spec.
type ExampleRef ¶
type ExampleRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *Example // contains filtered or unexported fields }
ExampleRef represents either a Example or a $ref to a Example. When serializing and both fields are set, Ref is preferred over Value.
func (*ExampleRef) CollectionName ¶
func (x *ExampleRef) CollectionName() string
CollectionName returns the JSON string used for a collection of these components.
func (*ExampleRef) JSONLookup ¶
func (x *ExampleRef) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (ExampleRef) MarshalJSON ¶
func (x ExampleRef) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of ExampleRef.
func (ExampleRef) MarshalYAML ¶
func (x ExampleRef) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of ExampleRef.
func (*ExampleRef) RefPath ¶
func (x *ExampleRef) RefPath() *url.URL
RefPath returns the path of the $ref relative to the root document.
func (*ExampleRef) RefString ¶
func (x *ExampleRef) RefString() string
RefString returns the $ref value.
func (*ExampleRef) UnmarshalJSON ¶
func (x *ExampleRef) UnmarshalJSON(data []byte) error
UnmarshalJSON sets ExampleRef to a copy of data.
func (*ExampleRef) Validate ¶
func (x *ExampleRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if ExampleRef does not comply with the OpenAPI spec.
type Examples ¶
type Examples map[string]*ExampleRef
func (Examples) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*Examples) UnmarshalJSON ¶
UnmarshalJSON sets Examples to a copy of data.
type ExternalDocs ¶
type ExternalDocs struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` URL string `json:"url,omitempty" yaml:"url,omitempty"` }
ExternalDocs is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#external-documentation-object
func (ExternalDocs) MarshalJSON ¶
func (e ExternalDocs) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of ExternalDocs.
func (ExternalDocs) MarshalYAML ¶
func (e ExternalDocs) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of ExternalDocs.
func (*ExternalDocs) UnmarshalJSON ¶
func (e *ExternalDocs) UnmarshalJSON(data []byte) error
UnmarshalJSON sets ExternalDocs to a copy of data.
func (*ExternalDocs) Validate ¶
func (e *ExternalDocs) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if ExternalDocs does not comply with the OpenAPI spec.
type FormatValidator ¶
FormatValidator is an interface for custom format validators.
func NewCallbackValidator ¶
func NewCallbackValidator[T any](fn func(T) error) FormatValidator[T]
NewCallbackValidator creates a new FormatValidator that uses a callback function to validate the value.
func NewIPValidator ¶
func NewIPValidator(isIPv4 bool) FormatValidator[string]
NewIPValidator creates a new FormatValidator that validates the value is an IP address.
func NewRangeFormatValidator ¶
func NewRangeFormatValidator[T int64 | float64](min, max T) FormatValidator[T]
NewRangeFormatValidator creates a new FormatValidator that validates the value is within a given range.
type Header ¶
type Header struct { Parameter }
Header is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#header-object
func (Header) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (Header) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Header.
func (Header) MarshalYAML ¶
MarshalYAML returns the JSON encoding of Header.
func (*Header) SerializationMethod ¶
func (header *Header) SerializationMethod() (*SerializationMethod, error)
SerializationMethod returns a header's serialization method.
func (*Header) UnmarshalJSON ¶
UnmarshalJSON sets Header to a copy of data.
func (*Header) Validate ¶
func (header *Header) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Header does not comply with the OpenAPI spec.
type HeaderRef ¶
type HeaderRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *Header // contains filtered or unexported fields }
HeaderRef represents either a Header or a $ref to a Header. When serializing and both fields are set, Ref is preferred over Value.
func (*HeaderRef) CollectionName ¶
CollectionName returns the JSON string used for a collection of these components.
func (*HeaderRef) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (HeaderRef) MarshalJSON ¶
MarshalJSON returns the JSON encoding of HeaderRef.
func (HeaderRef) MarshalYAML ¶
MarshalYAML returns the YAML encoding of HeaderRef.
func (*HeaderRef) RefPath ¶
RefPath returns the path of the $ref relative to the root document.
func (*HeaderRef) RefString ¶
RefString returns the $ref value.
func (*HeaderRef) UnmarshalJSON ¶
UnmarshalJSON sets HeaderRef to a copy of data.
func (*HeaderRef) Validate ¶
func (x *HeaderRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if HeaderRef does not comply with the OpenAPI spec.
type Headers ¶
func (Headers) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*Headers) UnmarshalJSON ¶
UnmarshalJSON sets Headers to a copy of data.
type Info ¶
type Info struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Title string `json:"title" yaml:"title"` // Required Description string `json:"description,omitempty" yaml:"description,omitempty"` TermsOfService string `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"` Contact *Contact `json:"contact,omitempty" yaml:"contact,omitempty"` License *License `json:"license,omitempty" yaml:"license,omitempty"` Version string `json:"version" yaml:"version"` // Required }
Info is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#info-object
func (Info) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Info.
func (*Info) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Info.
func (*Info) UnmarshalJSON ¶
UnmarshalJSON sets Info to a copy of data.
func (*Info) Validate ¶
func (info *Info) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Info does not comply with the OpenAPI spec.
type IntegerFormatValidator ¶
type IntegerFormatValidator = FormatValidator[int64]
IntegerFormatValidator is a type alias for FormatValidator[int64]
type License ¶
type License struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Name string `json:"name" yaml:"name"` // Required URL string `json:"url,omitempty" yaml:"url,omitempty"` }
License is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#license-object
func (License) MarshalJSON ¶
MarshalJSON returns the JSON encoding of License.
func (License) MarshalYAML ¶
MarshalYAML returns the YAML encoding of License.
func (*License) UnmarshalJSON ¶
UnmarshalJSON sets License to a copy of data.
func (*License) Validate ¶
func (license *License) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if License does not comply with the OpenAPI spec.
type Link ¶
type Link struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` OperationRef string `json:"operationRef,omitempty" yaml:"operationRef,omitempty"` OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Parameters map[string]any `json:"parameters,omitempty" yaml:"parameters,omitempty"` Server *Server `json:"server,omitempty" yaml:"server,omitempty"` RequestBody any `json:"requestBody,omitempty" yaml:"requestBody,omitempty"` }
Link is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#link-object
func (Link) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Link.
func (Link) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Link.
func (*Link) UnmarshalJSON ¶
UnmarshalJSON sets Link to a copy of data.
func (*Link) Validate ¶
func (link *Link) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Link does not comply with the OpenAPI spec.
type LinkRef ¶
type LinkRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *Link // contains filtered or unexported fields }
LinkRef represents either a Link or a $ref to a Link. When serializing and both fields are set, Ref is preferred over Value.
func (*LinkRef) CollectionName ¶
CollectionName returns the JSON string used for a collection of these components.
func (*LinkRef) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (LinkRef) MarshalJSON ¶
MarshalJSON returns the JSON encoding of LinkRef.
func (LinkRef) MarshalYAML ¶
MarshalYAML returns the YAML encoding of LinkRef.
func (*LinkRef) RefPath ¶
RefPath returns the path of the $ref relative to the root document.
func (*LinkRef) RefString ¶
RefString returns the $ref value.
func (*LinkRef) UnmarshalJSON ¶
UnmarshalJSON sets LinkRef to a copy of data.
func (*LinkRef) Validate ¶
func (x *LinkRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if LinkRef does not comply with the OpenAPI spec.
type Links ¶
func (Links) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*Links) UnmarshalJSON ¶
UnmarshalJSON sets Links to a copy of data.
type Loader ¶
type Loader struct { // IsExternalRefsAllowed enables visiting other files IsExternalRefsAllowed bool // IncludeOrigin specifies whether to include the origin of the OpenAPI elements IncludeOrigin bool // ReadFromURIFunc allows overriding the any file/URL reading func ReadFromURIFunc ReadFromURIFunc Context context.Context // contains filtered or unexported fields }
Loader helps deserialize an OpenAPIv3 document
Code:
Output:Example¶
{
spec := []byte(`
openapi: 3.0.1
paths: {}
info:
version: 1.1.1
title: title
description: An API
`[1:])
loader := NewLoader()
doc, err := loader.LoadFromData(spec)
if err != nil {
panic(err)
}
if err := doc.Validate(loader.Context); err != nil {
panic(err)
}
fmt.Print(doc.Info.Description)
// Output: An API
}
An API
func NewLoader ¶
func NewLoader() *Loader
NewLoader returns an empty Loader
func (*Loader) LoadFromData ¶
LoadFromData loads a spec from a byte array
func (*Loader) LoadFromDataWithPath ¶
LoadFromDataWithPath takes the OpenAPI document data in bytes and a path where the resolver can find referred elements and returns a *T with all resolved data or an error if unable to load data or resolve refs.
func (*Loader) LoadFromFile ¶
LoadFromFile loads a spec from a local file path
func (*Loader) LoadFromIoReader ¶
LoadFromStdin loads a spec from io.Reader
func (*Loader) LoadFromStdin ¶
LoadFromStdin loads a spec from stdin
func (*Loader) LoadFromURI ¶
LoadFromURI loads a spec from a remote URL
func (*Loader) ResolveRefsIn ¶
ResolveRefsIn expands references if for instance spec was just unmarshaled
type Location ¶
type Location struct { Line int `json:"line,omitempty" yaml:"line,omitempty"` Column int `json:"column,omitempty" yaml:"column,omitempty"` }
Location is a struct that contains the location of a field.
type MediaType ¶
type MediaType struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"` Example any `json:"example,omitempty" yaml:"example,omitempty"` Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"` Encoding map[string]*Encoding `json:"encoding,omitempty" yaml:"encoding,omitempty"` }
MediaType is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#media-type-object
func NewMediaType ¶
func NewMediaType() *MediaType
func (MediaType) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (MediaType) MarshalJSON ¶
MarshalJSON returns the JSON encoding of MediaType.
func (MediaType) MarshalYAML ¶
MarshalYAML returns the YAML encoding of MediaType.
func (*MediaType) UnmarshalJSON ¶
UnmarshalJSON sets MediaType to a copy of data.
func (*MediaType) Validate ¶
func (mediaType *MediaType) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if MediaType does not comply with the OpenAPI spec.
func (*MediaType) WithEncoding ¶
func (*MediaType) WithExample ¶
func (*MediaType) WithSchema ¶
func (*MediaType) WithSchemaRef ¶
type MultiError ¶
type MultiError []error
MultiError is a collection of errors, intended for when multiple issues need to be reported upstream
func (MultiError) As ¶
func (me MultiError) As(target any) bool
As allows you to use `errors.As()` to set target to the first error within the multi error that matches the target type
func (MultiError) Error ¶
func (me MultiError) Error() string
func (MultiError) Is ¶
func (me MultiError) Is(target error) bool
Is allows you to determine if a generic error is in fact a MultiError using `errors.Is()` It will also return true if any of the contained errors match target
type NewCallbackOption ¶
type NewCallbackOption func(*Callback)
NewCallbackOption describes options to NewCallback func
func WithCallback ¶
func WithCallback(cb string, pathItem *PathItem) NewCallbackOption
WithCallback adds Callback as an option to NewCallback
type NewPathsOption ¶
type NewPathsOption func(*Paths)
NewPathsOption describes options to NewPaths func
func WithPath ¶
func WithPath(path string, pathItem *PathItem) NewPathsOption
WithPath adds a named path item
type NewResponsesOption ¶
type NewResponsesOption func(*Responses)
NewResponsesOption describes options to NewResponses func
func WithName ¶
func WithName(name string, response *Response) NewResponsesOption
WithName adds a name-keyed Response
func WithStatus ¶
func WithStatus(status int, responseRef *ResponseRef) NewResponsesOption
WithStatus adds a status code keyed ResponseRef
type NumberFormatValidator ¶
type NumberFormatValidator = FormatValidator[float64]
NumberFormatValidator is a type alias for FormatValidator[float64]
type OAuthFlow ¶
type OAuthFlow struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` AuthorizationURL string `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"` TokenURL string `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"` RefreshURL string `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"` Scopes StringMap `json:"scopes" yaml:"scopes"` // required }
OAuthFlow is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauth-flow-object
func (OAuthFlow) MarshalJSON ¶
MarshalJSON returns the JSON encoding of OAuthFlow.
func (OAuthFlow) MarshalYAML ¶
MarshalYAML returns the YAML encoding of OAuthFlow.
func (*OAuthFlow) UnmarshalJSON ¶
UnmarshalJSON sets OAuthFlow to a copy of data.
func (*OAuthFlow) Validate ¶
func (flow *OAuthFlow) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if OAuthFlows does not comply with the OpenAPI spec.
type OAuthFlows ¶
type OAuthFlows struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Implicit *OAuthFlow `json:"implicit,omitempty" yaml:"implicit,omitempty"` Password *OAuthFlow `json:"password,omitempty" yaml:"password,omitempty"` ClientCredentials *OAuthFlow `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"` AuthorizationCode *OAuthFlow `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty"` }
OAuthFlows is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#oauth-flows-object
func (OAuthFlows) MarshalJSON ¶
func (flows OAuthFlows) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of OAuthFlows.
func (OAuthFlows) MarshalYAML ¶
func (flows OAuthFlows) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of OAuthFlows.
func (*OAuthFlows) UnmarshalJSON ¶
func (flows *OAuthFlows) UnmarshalJSON(data []byte) error
UnmarshalJSON sets OAuthFlows to a copy of data.
func (*OAuthFlows) Validate ¶
func (flows *OAuthFlows) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if OAuthFlows does not comply with the OpenAPI spec.
type Operation ¶
type Operation struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` // Optional tags for documentation. Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"` // Optional short summary. Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` // Optional description. Should use CommonMark syntax. Description string `json:"description,omitempty" yaml:"description,omitempty"` // Optional operation ID. OperationID string `json:"operationId,omitempty" yaml:"operationId,omitempty"` // Optional parameters. Parameters Parameters `json:"parameters,omitempty" yaml:"parameters,omitempty"` // Optional body parameter. RequestBody *RequestBodyRef `json:"requestBody,omitempty" yaml:"requestBody,omitempty"` // Responses. Responses *Responses `json:"responses" yaml:"responses"` // Required // Optional callbacks Callbacks Callbacks `json:"callbacks,omitempty" yaml:"callbacks,omitempty"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` // Optional security requirements that overrides top-level security. Security *SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"` // Optional servers that overrides top-level servers. Servers *Servers `json:"servers,omitempty" yaml:"servers,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` }
Operation represents "operation" specified by" OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object
func NewOperation ¶
func NewOperation() *Operation
func (*Operation) AddParameter ¶
func (*Operation) AddResponse ¶
func (Operation) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (Operation) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Operation.
func (Operation) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Operation.
func (*Operation) UnmarshalJSON ¶
UnmarshalJSON sets Operation to a copy of data.
func (*Operation) Validate ¶
func (operation *Operation) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Operation does not comply with the OpenAPI spec.
type Origin ¶
type Origin struct { Key *Location `json:"key,omitempty" yaml:"key,omitempty"` Fields map[string]Location `json:"fields,omitempty" yaml:"fields,omitempty"` }
Origin contains the origin of a collection. Key is the location of the collection itself. Fields is a map of the location of each field in the collection.
type Parameter ¶
type Parameter struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` In string `json:"in,omitempty" yaml:"in,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Style string `json:"style,omitempty" yaml:"style,omitempty"` Explode *bool `json:"explode,omitempty" yaml:"explode,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"` AllowReserved bool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` Required bool `json:"required,omitempty" yaml:"required,omitempty"` Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"` Example any `json:"example,omitempty" yaml:"example,omitempty"` Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"` Content Content `json:"content,omitempty" yaml:"content,omitempty"` }
Parameter is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameter-object
func NewCookieParameter ¶
func NewHeaderParameter ¶
func NewPathParameter ¶
func NewQueryParameter ¶
func (Parameter) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (Parameter) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Parameter.
func (Parameter) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Parameter.
func (*Parameter) SerializationMethod ¶
func (parameter *Parameter) SerializationMethod() (*SerializationMethod, error)
SerializationMethod returns a parameter's serialization method. When a parameter's serialization method is not defined the method returns the default serialization method corresponding to a parameter's location.
func (*Parameter) UnmarshalJSON ¶
UnmarshalJSON sets Parameter to a copy of data.
func (*Parameter) Validate ¶
func (parameter *Parameter) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Parameter does not comply with the OpenAPI spec.
func (*Parameter) WithDescription ¶
func (*Parameter) WithRequired ¶
func (*Parameter) WithSchema ¶
type ParameterRef ¶
type ParameterRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *Parameter // contains filtered or unexported fields }
ParameterRef represents either a Parameter or a $ref to a Parameter. When serializing and both fields are set, Ref is preferred over Value.
func (*ParameterRef) CollectionName ¶
func (x *ParameterRef) CollectionName() string
CollectionName returns the JSON string used for a collection of these components.
func (*ParameterRef) JSONLookup ¶
func (x *ParameterRef) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (ParameterRef) MarshalJSON ¶
func (x ParameterRef) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of ParameterRef.
func (ParameterRef) MarshalYAML ¶
func (x ParameterRef) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of ParameterRef.
func (*ParameterRef) RefPath ¶
func (x *ParameterRef) RefPath() *url.URL
RefPath returns the path of the $ref relative to the root document.
func (*ParameterRef) RefString ¶
func (x *ParameterRef) RefString() string
RefString returns the $ref value.
func (*ParameterRef) UnmarshalJSON ¶
func (x *ParameterRef) UnmarshalJSON(data []byte) error
UnmarshalJSON sets ParameterRef to a copy of data.
func (*ParameterRef) Validate ¶
func (x *ParameterRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if ParameterRef does not comply with the OpenAPI spec.
type Parameters ¶
type Parameters []*ParameterRef
Parameters is specified by OpenAPI/Swagger 3.0 standard.
func NewParameters ¶
func NewParameters() Parameters
func (Parameters) GetByInAndName ¶
func (parameters Parameters) GetByInAndName(in string, name string) *Parameter
func (Parameters) JSONLookup ¶
func (p Parameters) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (Parameters) Validate ¶
func (parameters Parameters) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Parameters does not comply with the OpenAPI spec.
type ParametersMap ¶
type ParametersMap map[string]*ParameterRef
func (ParametersMap) JSONLookup ¶
func (m ParametersMap) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*ParametersMap) UnmarshalJSON ¶
func (parametersMap *ParametersMap) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON sets ParametersMap to a copy of data.
type PathItem ¶
type PathItem struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Ref string `json:"$ref,omitempty" yaml:"$ref,omitempty"` Summary string `json:"summary,omitempty" yaml:"summary,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Connect *Operation `json:"connect,omitempty" yaml:"connect,omitempty"` Delete *Operation `json:"delete,omitempty" yaml:"delete,omitempty"` Get *Operation `json:"get,omitempty" yaml:"get,omitempty"` Head *Operation `json:"head,omitempty" yaml:"head,omitempty"` Options *Operation `json:"options,omitempty" yaml:"options,omitempty"` Patch *Operation `json:"patch,omitempty" yaml:"patch,omitempty"` Post *Operation `json:"post,omitempty" yaml:"post,omitempty"` Put *Operation `json:"put,omitempty" yaml:"put,omitempty"` Trace *Operation `json:"trace,omitempty" yaml:"trace,omitempty"` Servers Servers `json:"servers,omitempty" yaml:"servers,omitempty"` Parameters Parameters `json:"parameters,omitempty" yaml:"parameters,omitempty"` }
PathItem is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#path-item-object
func (*PathItem) GetOperation ¶
func (PathItem) MarshalJSON ¶
MarshalJSON returns the JSON encoding of PathItem.
func (PathItem) MarshalYAML ¶
MarshalYAML returns the YAML encoding of PathItem.
func (*PathItem) Operations ¶
func (*PathItem) SetOperation ¶
func (*PathItem) UnmarshalJSON ¶
UnmarshalJSON sets PathItem to a copy of data.
func (*PathItem) Validate ¶
func (pathItem *PathItem) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if PathItem does not comply with the OpenAPI spec.
type Paths ¶
type Paths struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` // contains filtered or unexported fields }
Paths is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#paths-object
func NewPaths ¶
func NewPaths(opts ...NewPathsOption) *Paths
NewPaths builds a paths object with path items in insertion order.
func NewPathsWithCapacity ¶
NewPathsWithCapacity builds a paths object of the given capacity.
func (*Paths) Delete ¶
Delete removes the entry associated with key 'key' from 'paths'.
func (*Paths) Find ¶
Find returns a path that matches the key.
The method ignores differences in template variable names (except possible "*" suffix).
For example:
paths := openapi3.Paths { "/person/{personName}": &openapi3.PathItem{}, } pathItem := path.Find("/person/{name}")
would return the correct path item.
func (*Paths) InMatchingOrder ¶
InMatchingOrder returns paths in the order they are matched against URLs. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#paths-object When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.
func (Paths) JSONLookup ¶
JSONLookup implements https://github.com/go-openapi/jsonpointer#JSONPointable
func (*Paths) Len ¶
Len returns the amount of keys in paths excluding paths.Extensions.
func (*Paths) Map ¶
Map returns paths as a 'map'. Note: iteration on Go maps is not ordered.
func (*Paths) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Paths.
func (*Paths) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Paths.
func (*Paths) Set ¶
Set adds or replaces key 'key' of 'paths' with 'value'. Note: 'paths' MUST be non-nil
func (*Paths) UnmarshalJSON ¶
UnmarshalJSON sets Paths to a copy of data.
func (*Paths) Validate ¶
func (paths *Paths) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Paths does not comply with the OpenAPI spec.
func (*Paths) Value ¶
Value returns the paths for key or nil
type ReadFromURIFunc ¶
ReadFromURIFunc defines a function which reads the contents of a resource located at a URI.
func ReadFromHTTP ¶
func ReadFromHTTP(cl *http.Client) ReadFromURIFunc
ReadFromHTTP returns a ReadFromURIFunc which uses the given http.Client to read the contents from a remote HTTP URI. This client may be customized to implement timeouts, RFC 7234 caching, etc.
func ReadFromURIs ¶
func ReadFromURIs(readers ...ReadFromURIFunc) ReadFromURIFunc
ReadFromURIs returns a ReadFromURIFunc which tries to read a URI using the given reader functions, in the same order. If a reader function does not support the URI and returns ErrURINotSupported, the next function is checked until a match is found, or the URI is not supported by any.
func URIMapCache ¶
func URIMapCache(reader ReadFromURIFunc) ReadFromURIFunc
URIMapCache returns a ReadFromURIFunc that caches the contents read from URI locations in a simple map. This cache implementation is suitable for short-lived processes such as command-line tools which process OpenAPI documents.
type Ref ¶
type Ref struct { Ref string `json:"$ref" yaml:"$ref"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` }
Ref is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#reference-object
type RefNameResolver ¶
type RefNameResolver func(*T, ComponentRef) string
RefNameResolver maps a component to an name that is used as it's internalized name.
The function should avoid name collisions (i.e. be a injective mapping). It must only contain characters valid for fixed field names: IdentifierRegExp.
type RegexCompilerFunc ¶
type RegexCompilerFunc func(expr string) (RegexMatcher, error)
type RegexMatcher ¶
type RequestBodies ¶
type RequestBodies map[string]*RequestBodyRef
func (RequestBodies) JSONLookup ¶
func (m RequestBodies) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*RequestBodies) UnmarshalJSON ¶
func (requestBodies *RequestBodies) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON sets RequestBodies to a copy of data.
type RequestBody ¶
type RequestBody struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Required bool `json:"required,omitempty" yaml:"required,omitempty"` Content Content `json:"content" yaml:"content"` }
RequestBody is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#request-body-object
func NewRequestBody ¶
func NewRequestBody() *RequestBody
func (*RequestBody) GetMediaType ¶
func (requestBody *RequestBody) GetMediaType(mediaType string) *MediaType
func (RequestBody) MarshalJSON ¶
func (requestBody RequestBody) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of RequestBody.
func (RequestBody) MarshalYAML ¶
func (requestBody RequestBody) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of RequestBody.
func (*RequestBody) UnmarshalJSON ¶
func (requestBody *RequestBody) UnmarshalJSON(data []byte) error
UnmarshalJSON sets RequestBody to a copy of data.
func (*RequestBody) Validate ¶
func (requestBody *RequestBody) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if RequestBody does not comply with the OpenAPI spec.
func (*RequestBody) WithContent ¶
func (requestBody *RequestBody) WithContent(content Content) *RequestBody
func (*RequestBody) WithDescription ¶
func (requestBody *RequestBody) WithDescription(value string) *RequestBody
func (*RequestBody) WithFormDataSchema ¶
func (requestBody *RequestBody) WithFormDataSchema(value *Schema) *RequestBody
func (*RequestBody) WithFormDataSchemaRef ¶
func (requestBody *RequestBody) WithFormDataSchemaRef(value *SchemaRef) *RequestBody
func (*RequestBody) WithJSONSchema ¶
func (requestBody *RequestBody) WithJSONSchema(value *Schema) *RequestBody
func (*RequestBody) WithJSONSchemaRef ¶
func (requestBody *RequestBody) WithJSONSchemaRef(value *SchemaRef) *RequestBody
func (*RequestBody) WithRequired ¶
func (requestBody *RequestBody) WithRequired(value bool) *RequestBody
func (*RequestBody) WithSchema ¶
func (requestBody *RequestBody) WithSchema(value *Schema, consumes []string) *RequestBody
func (*RequestBody) WithSchemaRef ¶
func (requestBody *RequestBody) WithSchemaRef(value *SchemaRef, consumes []string) *RequestBody
type RequestBodyRef ¶
type RequestBodyRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *RequestBody // contains filtered or unexported fields }
RequestBodyRef represents either a RequestBody or a $ref to a RequestBody. When serializing and both fields are set, Ref is preferred over Value.
func (*RequestBodyRef) CollectionName ¶
func (x *RequestBodyRef) CollectionName() string
CollectionName returns the JSON string used for a collection of these components.
func (*RequestBodyRef) JSONLookup ¶
func (x *RequestBodyRef) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (RequestBodyRef) MarshalJSON ¶
func (x RequestBodyRef) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of RequestBodyRef.
func (RequestBodyRef) MarshalYAML ¶
func (x RequestBodyRef) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of RequestBodyRef.
func (*RequestBodyRef) RefPath ¶
func (x *RequestBodyRef) RefPath() *url.URL
RefPath returns the path of the $ref relative to the root document.
func (*RequestBodyRef) RefString ¶
func (x *RequestBodyRef) RefString() string
RefString returns the $ref value.
func (*RequestBodyRef) UnmarshalJSON ¶
func (x *RequestBodyRef) UnmarshalJSON(data []byte) error
UnmarshalJSON sets RequestBodyRef to a copy of data.
func (*RequestBodyRef) Validate ¶
func (x *RequestBodyRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if RequestBodyRef does not comply with the OpenAPI spec.
type Response ¶
type Response struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Description *string `json:"description,omitempty" yaml:"description,omitempty"` Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"` Content Content `json:"content,omitempty" yaml:"content,omitempty"` Links Links `json:"links,omitempty" yaml:"links,omitempty"` }
Response is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object
func NewResponse ¶
func NewResponse() *Response
func (Response) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Response.
func (Response) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Response.
func (*Response) UnmarshalJSON ¶
UnmarshalJSON sets Response to a copy of data.
func (*Response) Validate ¶
func (response *Response) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Response does not comply with the OpenAPI spec.
func (*Response) WithContent ¶
func (*Response) WithDescription ¶
func (*Response) WithJSONSchema ¶
func (*Response) WithJSONSchemaRef ¶
type ResponseBodies ¶
type ResponseBodies map[string]*ResponseRef
func (ResponseBodies) JSONLookup ¶
func (m ResponseBodies) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*ResponseBodies) UnmarshalJSON ¶
func (responseBodies *ResponseBodies) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON sets ResponseBodies to a copy of data.
type ResponseRef ¶
type ResponseRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *Response // contains filtered or unexported fields }
ResponseRef represents either a Response or a $ref to a Response. When serializing and both fields are set, Ref is preferred over Value.
func (*ResponseRef) CollectionName ¶
func (x *ResponseRef) CollectionName() string
CollectionName returns the JSON string used for a collection of these components.
func (*ResponseRef) JSONLookup ¶
func (x *ResponseRef) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (ResponseRef) MarshalJSON ¶
func (x ResponseRef) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of ResponseRef.
func (ResponseRef) MarshalYAML ¶
func (x ResponseRef) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of ResponseRef.
func (*ResponseRef) RefPath ¶
func (x *ResponseRef) RefPath() *url.URL
RefPath returns the path of the $ref relative to the root document.
func (*ResponseRef) RefString ¶
func (x *ResponseRef) RefString() string
RefString returns the $ref value.
func (*ResponseRef) UnmarshalJSON ¶
func (x *ResponseRef) UnmarshalJSON(data []byte) error
UnmarshalJSON sets ResponseRef to a copy of data.
func (*ResponseRef) Validate ¶
func (x *ResponseRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if ResponseRef does not comply with the OpenAPI spec.
type Responses ¶
type Responses struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"-" yaml:"-"` // contains filtered or unexported fields }
Responses is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#responses-object
func NewResponses ¶
func NewResponses(opts ...NewResponsesOption) *Responses
NewResponses builds a responses object with response objects in insertion order. Given no arguments, NewResponses returns a valid responses object containing a default match-all reponse.
func NewResponsesWithCapacity ¶
NewResponsesWithCapacity builds a responses object of the given capacity.
func (*Responses) Default ¶
func (responses *Responses) Default() *ResponseRef
Default returns the default response
func (*Responses) Delete ¶
Delete removes the entry associated with key 'key' from 'responses'.
func (Responses) JSONLookup ¶
JSONLookup implements https://github.com/go-openapi/jsonpointer#JSONPointable
func (*Responses) Len ¶
Len returns the amount of keys in responses excluding responses.Extensions.
func (*Responses) Map ¶
func (responses *Responses) Map() (m map[string]*ResponseRef)
Map returns responses as a 'map'. Note: iteration on Go maps is not ordered.
func (*Responses) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Responses.
func (*Responses) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Responses.
func (*Responses) Set ¶
func (responses *Responses) Set(key string, value *ResponseRef)
Set adds or replaces key 'key' of 'responses' with 'value'. Note: 'responses' MUST be non-nil
func (*Responses) Status ¶
func (responses *Responses) Status(status int) *ResponseRef
Status returns a ResponseRef for the given status If an exact match isn't initially found a patterned field is checked using the first digit to determine the range (eg: 201 to 2XX) See https://spec.openapis.org/oas/v3.0.3#patterned-fields-0
func (*Responses) UnmarshalJSON ¶
UnmarshalJSON sets Responses to a copy of data.
func (*Responses) Validate ¶
func (responses *Responses) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Responses does not comply with the OpenAPI spec.
func (*Responses) Value ¶
func (responses *Responses) Value(key string) *ResponseRef
Value returns the responses for key or nil
type Schema ¶
type Schema struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` OneOf SchemaRefs `json:"oneOf,omitempty" yaml:"oneOf,omitempty"` AnyOf SchemaRefs `json:"anyOf,omitempty" yaml:"anyOf,omitempty"` AllOf SchemaRefs `json:"allOf,omitempty" yaml:"allOf,omitempty"` Not *SchemaRef `json:"not,omitempty" yaml:"not,omitempty"` Type *Types `json:"type,omitempty" yaml:"type,omitempty"` Title string `json:"title,omitempty" yaml:"title,omitempty"` Format string `json:"format,omitempty" yaml:"format,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Enum []any `json:"enum,omitempty" yaml:"enum,omitempty"` Default any `json:"default,omitempty" yaml:"default,omitempty"` Example any `json:"example,omitempty" yaml:"example,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` // Array-related, here for struct compactness UniqueItems bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"` // Number-related, here for struct compactness ExclusiveMin bool `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"` ExclusiveMax bool `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"` // Properties Nullable bool `json:"nullable,omitempty" yaml:"nullable,omitempty"` ReadOnly bool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"` WriteOnly bool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"` AllowEmptyValue bool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"` Deprecated bool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"` XML *XML `json:"xml,omitempty" yaml:"xml,omitempty"` // Number Min *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"` Max *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"` MultipleOf *float64 `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"` // String MinLength uint64 `json:"minLength,omitempty" yaml:"minLength,omitempty"` MaxLength *uint64 `json:"maxLength,omitempty" yaml:"maxLength,omitempty"` Pattern string `json:"pattern,omitempty" yaml:"pattern,omitempty"` // Array MinItems uint64 `json:"minItems,omitempty" yaml:"minItems,omitempty"` MaxItems *uint64 `json:"maxItems,omitempty" yaml:"maxItems,omitempty"` Items *SchemaRef `json:"items,omitempty" yaml:"items,omitempty"` // Object Required []string `json:"required,omitempty" yaml:"required,omitempty"` Properties Schemas `json:"properties,omitempty" yaml:"properties,omitempty"` MinProps uint64 `json:"minProperties,omitempty" yaml:"minProperties,omitempty"` MaxProps *uint64 `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"` AdditionalProperties AdditionalProperties `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"` Discriminator *Discriminator `json:"discriminator,omitempty" yaml:"discriminator,omitempty"` }
Schema is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schema-object
func NewAllOfSchema ¶
func NewAnyOfSchema ¶
func NewArraySchema ¶
func NewArraySchema() *Schema
func NewBoolSchema ¶
func NewBoolSchema() *Schema
func NewBytesSchema ¶
func NewBytesSchema() *Schema
func NewDateTimeSchema ¶
func NewDateTimeSchema() *Schema
func NewFloat64Schema ¶
func NewFloat64Schema() *Schema
func NewInt32Schema ¶
func NewInt32Schema() *Schema
func NewInt64Schema ¶
func NewInt64Schema() *Schema
func NewIntegerSchema ¶
func NewIntegerSchema() *Schema
func NewObjectSchema ¶
func NewObjectSchema() *Schema
func NewOneOfSchema ¶
func NewSchema ¶
func NewSchema() *Schema
func NewStringSchema ¶
func NewStringSchema() *Schema
func NewUUIDSchema ¶
func NewUUIDSchema() *Schema
func (*Schema) IsEmpty ¶
IsEmpty tells whether schema is equivalent to the empty schema `{}`.
func (*Schema) IsMatching ¶
func (*Schema) IsMatchingJSONArray ¶
func (*Schema) IsMatchingJSONBoolean ¶
func (*Schema) IsMatchingJSONNumber ¶
func (*Schema) IsMatchingJSONObject ¶
func (*Schema) IsMatchingJSONString ¶
func (Schema) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (Schema) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Schema.
func (Schema) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Schema.
func (*Schema) NewRef ¶
func (*Schema) PermitsNull ¶
func (*Schema) UnmarshalJSON ¶
UnmarshalJSON sets Schema to a copy of data.
func (*Schema) Validate ¶
func (schema *Schema) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Schema does not comply with the OpenAPI spec.
func (*Schema) VisitJSON ¶
func (schema *Schema) VisitJSON(value any, opts ...SchemaValidationOption) error
func (*Schema) VisitJSONArray ¶
func (*Schema) VisitJSONBoolean ¶
func (*Schema) VisitJSONNumber ¶
func (*Schema) VisitJSONObject ¶
func (*Schema) VisitJSONString ¶
func (*Schema) WithAdditionalProperties ¶
func (*Schema) WithAnyAdditionalProperties ¶
func (*Schema) WithDefault ¶
func (*Schema) WithEnum ¶
func (*Schema) WithExclusiveMax ¶
func (*Schema) WithExclusiveMin ¶
func (*Schema) WithFormat ¶
func (*Schema) WithItems ¶
func (*Schema) WithLength ¶
func (*Schema) WithLengthDecodedBase64 ¶
func (*Schema) WithMax ¶
func (*Schema) WithMaxItems ¶
func (*Schema) WithMaxLength ¶
func (*Schema) WithMaxLengthDecodedBase64 ¶
func (*Schema) WithMaxProperties ¶
func (*Schema) WithMin ¶
func (*Schema) WithMinItems ¶
func (*Schema) WithMinLength ¶
func (*Schema) WithMinLengthDecodedBase64 ¶
func (*Schema) WithMinProperties ¶
func (*Schema) WithNullable ¶
func (*Schema) WithPattern ¶
func (*Schema) WithProperties ¶
func (*Schema) WithProperty ¶
func (*Schema) WithPropertyRef ¶
func (*Schema) WithRequired ¶
func (*Schema) WithUniqueItems ¶
func (*Schema) WithoutAdditionalProperties ¶
type SchemaError ¶
type SchemaError struct { // Value is the value that failed validation. Value any // Schema is the schema that failed validation. Schema *Schema // SchemaField is the field of the schema that failed validation. SchemaField string // Reason is a human-readable message describing the error. // The message should never include the original value to prevent leakage of potentially sensitive inputs in error messages. Reason string // Origin is the original error that caused this error. Origin error // contains filtered or unexported fields }
SchemaError is an error that occurs during schema validation.
func (*SchemaError) Error ¶
func (err *SchemaError) Error() string
func (*SchemaError) JSONPointer ¶
func (err *SchemaError) JSONPointer() []string
func (SchemaError) Unwrap ¶
func (err SchemaError) Unwrap() error
type SchemaRef ¶
type SchemaRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *Schema // contains filtered or unexported fields }
SchemaRef represents either a Schema or a $ref to a Schema. When serializing and both fields are set, Ref is preferred over Value.
func NewSchemaRef ¶
NewSchemaRef simply builds a SchemaRef
func (*SchemaRef) CollectionName ¶
CollectionName returns the JSON string used for a collection of these components.
func (*SchemaRef) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (SchemaRef) MarshalJSON ¶
MarshalJSON returns the JSON encoding of SchemaRef.
func (SchemaRef) MarshalYAML ¶
MarshalYAML returns the YAML encoding of SchemaRef.
func (*SchemaRef) RefPath ¶
RefPath returns the path of the $ref relative to the root document.
func (*SchemaRef) RefString ¶
RefString returns the $ref value.
func (*SchemaRef) UnmarshalJSON ¶
UnmarshalJSON sets SchemaRef to a copy of data.
func (*SchemaRef) Validate ¶
func (x *SchemaRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if SchemaRef does not comply with the OpenAPI spec.
type SchemaRefs ¶
type SchemaRefs []*SchemaRef
func (SchemaRefs) JSONLookup ¶
func (s SchemaRefs) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
type SchemaValidationOption ¶
type SchemaValidationOption func(*schemaValidationSettings)
SchemaValidationOption describes options a user has when validating request / response bodies.
func DefaultsSet ¶
func DefaultsSet(f func()) SchemaValidationOption
DefaultsSet executes the given callback (once) IFF schema validation set default values.
func DisablePatternValidation ¶
func DisablePatternValidation() SchemaValidationOption
DisablePatternValidation setting makes Validate not return an error when validating patterns that are not supported by the Go regexp engine.
func DisableReadOnlyValidation ¶
func DisableReadOnlyValidation() SchemaValidationOption
DisableReadOnlyValidation setting makes Validate not return an error when validating properties marked as read-only
func DisableWriteOnlyValidation ¶
func DisableWriteOnlyValidation() SchemaValidationOption
DisableWriteOnlyValidation setting makes Validate not return an error when validating properties marked as write-only
func EnableFormatValidation ¶
func EnableFormatValidation() SchemaValidationOption
EnableFormatValidation setting makes Validate not return an error when validating documents that mention schema formats that are not defined by the OpenAPIv3 specification.
func FailFast ¶
func FailFast() SchemaValidationOption
FailFast returns schema validation errors quicker.
func MultiErrors ¶
func MultiErrors() SchemaValidationOption
func SetSchemaErrorMessageCustomizer ¶
func SetSchemaErrorMessageCustomizer(f func(err *SchemaError) string) SchemaValidationOption
SetSchemaErrorMessageCustomizer allows to override the schema error message.
If the passed function returns an empty string, it returns to the previous Error() implementation.
Code:play
Output:Example¶
package main
import (
"fmt"
"github.com/getkin/kin-openapi/openapi3"
)
func main() {
loader := openapi3.NewLoader()
spc := `
components:
schemas:
Something:
type: object
properties:
field:
title: Some field
type: string
`[1:]
doc, err := loader.LoadFromData([]byte(spc))
if err != nil {
panic(err)
}
opt := openapi3.SetSchemaErrorMessageCustomizer(func(err *openapi3.SchemaError) string {
return fmt.Sprintf(`field "%s" should be string`, err.Schema.Title)
})
err = doc.Components.Schemas["Something"].Value.Properties["field"].Value.VisitJSON(123, opt)
fmt.Println(err.Error())
}
field "Some field" should be string
func SetSchemaRegexCompiler ¶
func SetSchemaRegexCompiler(c RegexCompilerFunc) SchemaValidationOption
SetSchemaRegexCompiler allows to override the regex implementation used to validate field "pattern".
func VisitAsRequest ¶
func VisitAsRequest() SchemaValidationOption
func VisitAsResponse ¶
func VisitAsResponse() SchemaValidationOption
type Schemas ¶
func (Schemas) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*Schemas) UnmarshalJSON ¶
UnmarshalJSON sets Schemas to a copy of data.
type SecurityRequirement ¶
SecurityRequirement is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object
func NewSecurityRequirement ¶
func NewSecurityRequirement() SecurityRequirement
func (SecurityRequirement) Authenticate ¶
func (security SecurityRequirement) Authenticate(provider string, scopes ...string) SecurityRequirement
func (*SecurityRequirement) UnmarshalJSON ¶
func (security *SecurityRequirement) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON sets SecurityRequirement to a copy of data.
func (*SecurityRequirement) Validate ¶
func (security *SecurityRequirement) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if SecurityRequirement does not comply with the OpenAPI spec.
type SecurityRequirements ¶
type SecurityRequirements []SecurityRequirement
func NewSecurityRequirements ¶
func NewSecurityRequirements() *SecurityRequirements
func (SecurityRequirements) Validate ¶
func (srs SecurityRequirements) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if SecurityRequirements does not comply with the OpenAPI spec.
func (*SecurityRequirements) With ¶
func (srs *SecurityRequirements) With(securityRequirement SecurityRequirement) *SecurityRequirements
type SecurityScheme ¶
type SecurityScheme struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` In string `json:"in,omitempty" yaml:"in,omitempty"` Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"` BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"` Flows *OAuthFlows `json:"flows,omitempty" yaml:"flows,omitempty"` OpenIdConnectUrl string `json:"openIdConnectUrl,omitempty" yaml:"openIdConnectUrl,omitempty"` }
SecurityScheme is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-scheme-object
func NewCSRFSecurityScheme ¶
func NewCSRFSecurityScheme() *SecurityScheme
func NewJWTSecurityScheme ¶
func NewJWTSecurityScheme() *SecurityScheme
func NewOIDCSecurityScheme ¶
func NewOIDCSecurityScheme(oidcUrl string) *SecurityScheme
func NewSecurityScheme ¶
func NewSecurityScheme() *SecurityScheme
func (SecurityScheme) MarshalJSON ¶
func (ss SecurityScheme) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of SecurityScheme.
func (SecurityScheme) MarshalYAML ¶
func (ss SecurityScheme) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of SecurityScheme.
func (*SecurityScheme) UnmarshalJSON ¶
func (ss *SecurityScheme) UnmarshalJSON(data []byte) error
UnmarshalJSON sets SecurityScheme to a copy of data.
func (*SecurityScheme) Validate ¶
func (ss *SecurityScheme) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if SecurityScheme does not comply with the OpenAPI spec.
func (*SecurityScheme) WithBearerFormat ¶
func (ss *SecurityScheme) WithBearerFormat(value string) *SecurityScheme
func (*SecurityScheme) WithDescription ¶
func (ss *SecurityScheme) WithDescription(value string) *SecurityScheme
func (*SecurityScheme) WithIn ¶
func (ss *SecurityScheme) WithIn(value string) *SecurityScheme
func (*SecurityScheme) WithName ¶
func (ss *SecurityScheme) WithName(value string) *SecurityScheme
func (*SecurityScheme) WithScheme ¶
func (ss *SecurityScheme) WithScheme(value string) *SecurityScheme
func (*SecurityScheme) WithType ¶
func (ss *SecurityScheme) WithType(value string) *SecurityScheme
type SecuritySchemeRef ¶
type SecuritySchemeRef struct { // Extensions only captures fields starting with 'x-' as no other fields // are allowed by the openapi spec. Extensions map[string]any Origin *Origin Ref string Value *SecurityScheme // contains filtered or unexported fields }
SecuritySchemeRef represents either a SecurityScheme or a $ref to a SecurityScheme. When serializing and both fields are set, Ref is preferred over Value.
func (*SecuritySchemeRef) CollectionName ¶
func (x *SecuritySchemeRef) CollectionName() string
CollectionName returns the JSON string used for a collection of these components.
func (*SecuritySchemeRef) JSONLookup ¶
func (x *SecuritySchemeRef) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (SecuritySchemeRef) MarshalJSON ¶
func (x SecuritySchemeRef) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of SecuritySchemeRef.
func (SecuritySchemeRef) MarshalYAML ¶
func (x SecuritySchemeRef) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of SecuritySchemeRef.
func (*SecuritySchemeRef) RefPath ¶
func (x *SecuritySchemeRef) RefPath() *url.URL
RefPath returns the path of the $ref relative to the root document.
func (*SecuritySchemeRef) RefString ¶
func (x *SecuritySchemeRef) RefString() string
RefString returns the $ref value.
func (*SecuritySchemeRef) UnmarshalJSON ¶
func (x *SecuritySchemeRef) UnmarshalJSON(data []byte) error
UnmarshalJSON sets SecuritySchemeRef to a copy of data.
func (*SecuritySchemeRef) Validate ¶
func (x *SecuritySchemeRef) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if SecuritySchemeRef does not comply with the OpenAPI spec.
type SecuritySchemes ¶
type SecuritySchemes map[string]*SecuritySchemeRef
func (SecuritySchemes) JSONLookup ¶
func (m SecuritySchemes) JSONLookup(token string) (any, error)
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*SecuritySchemes) UnmarshalJSON ¶
func (securitySchemes *SecuritySchemes) UnmarshalJSON(data []byte) (err error)
UnmarshalJSON sets SecuritySchemes to a copy of data.
type SerializationMethod ¶
SerializationMethod describes a serialization method of HTTP request's parameters and body.
type Server ¶
type Server struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` URL string `json:"url" yaml:"url"` // Required Description string `json:"description,omitempty" yaml:"description,omitempty"` Variables map[string]*ServerVariable `json:"variables,omitempty" yaml:"variables,omitempty"` }
Server is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#server-object
func (*Server) BasePath ¶
BasePath returns the base path extracted from the default values of variables, if any. Assumes a valid struct (per Validate()).
func (Server) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Server.
func (Server) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Server.
func (Server) MatchRawURL ¶
func (Server) ParameterNames ¶
func (*Server) UnmarshalJSON ¶
UnmarshalJSON sets Server to a copy of data.
func (*Server) Validate ¶
func (server *Server) Validate(ctx context.Context, opts ...ValidationOption) (err error)
Validate returns an error if Server does not comply with the OpenAPI spec.
type ServerVariable ¶
type ServerVariable struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"` Default string `json:"default,omitempty" yaml:"default,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` }
ServerVariable is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#server-variable-object
func (ServerVariable) MarshalJSON ¶
func (serverVariable ServerVariable) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of ServerVariable.
func (ServerVariable) MarshalYAML ¶
func (serverVariable ServerVariable) MarshalYAML() (any, error)
MarshalYAML returns the YAML encoding of ServerVariable.
func (*ServerVariable) UnmarshalJSON ¶
func (serverVariable *ServerVariable) UnmarshalJSON(data []byte) error
UnmarshalJSON sets ServerVariable to a copy of data.
func (*ServerVariable) Validate ¶
func (serverVariable *ServerVariable) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if ServerVariable does not comply with the OpenAPI spec.
type Servers ¶
type Servers []*Server
Servers is specified by OpenAPI/Swagger standard version 3.
func (Servers) BasePath ¶
BasePath returns the base path of the first server in the list, or /.
func (Servers) MatchURL ¶
func (Servers) Validate ¶
func (servers Servers) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Servers does not comply with the OpenAPI spec.
type SliceUniqueItemsChecker ¶
SliceUniqueItemsChecker is an function used to check if an given slice have unique items.
type StringFormatValidator ¶
type StringFormatValidator = FormatValidator[string]
StringFormatValidator is a type alias for FormatValidator[string]
func NewRegexpFormatValidator ¶
func NewRegexpFormatValidator(pattern string) StringFormatValidator
NewRegexpFormatValidator creates a new FormatValidator that uses a regular expression to validate the value.
type StringMap ¶
StringMap is a map[string]string that ignores the origin in the underlying json representation.
func (*StringMap) UnmarshalJSON ¶
UnmarshalJSON sets StringMap to a copy of data.
type T ¶
type T struct { Extensions map[string]any `json:"-" yaml:"-"` OpenAPI string `json:"openapi" yaml:"openapi"` // Required Components *Components `json:"components,omitempty" yaml:"components,omitempty"` Info *Info `json:"info" yaml:"info"` // Required Paths *Paths `json:"paths" yaml:"paths"` // Required Security SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"` Servers Servers `json:"servers,omitempty" yaml:"servers,omitempty"` Tags Tags `json:"tags,omitempty" yaml:"tags,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` // contains filtered or unexported fields }
T is the root of an OpenAPI v3 document See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-object
func (*T) AddOperation ¶
func (*T) AddServer ¶
func (*T) AddServers ¶
func (*T) InternalizeRefs ¶
InternalizeRefs removes all references to external files from the spec and moves them to the components section.
refNameResolver takes in references to returns a name to store the reference under locally. It MUST return a unique name for each reference type. A default implementation is provided that will suffice for most use cases. See the function documentation for more details.
Example:
doc.InternalizeRefs(context.Background(), nil)
func (*T) JSONLookup ¶
JSONLookup implements https://pkg.go.dev/github.com/go-openapi/jsonpointer#JSONPointable
func (*T) MarshalJSON ¶
MarshalJSON returns the JSON encoding of T.
func (*T) MarshalYAML ¶
MarshalYAML returns the YAML encoding of T.
func (*T) UnmarshalJSON ¶
UnmarshalJSON sets T to a copy of data.
func (*T) Validate ¶
func (doc *T) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if T does not comply with the OpenAPI spec. Validations Options can be provided to modify the validation behavior.
type Tag ¶
type Tag struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"` }
Tag is specified by OpenAPI/Swagger 3.0 standard. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#tag-object
func (Tag) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Tag.
func (Tag) MarshalYAML ¶
MarshalYAML returns the YAML encoding of Tag.
func (*Tag) UnmarshalJSON ¶
UnmarshalJSON sets Tag to a copy of data.
func (*Tag) Validate ¶
func (t *Tag) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Tag does not comply with the OpenAPI spec.
type Tags ¶
type Tags []*Tag
Tags is specified by OpenAPI/Swagger 3.0 standard.
func (Tags) Get ¶
func (Tags) Validate ¶
func (tags Tags) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if Tags does not comply with the OpenAPI spec.
type Types ¶
type Types []string
func (*Types) Includes ¶
func (*Types) Is ¶
func (*Types) MarshalJSON ¶
func (*Types) MarshalYAML ¶
func (*Types) Permits ¶
func (*Types) Slice ¶
func (*Types) UnmarshalJSON ¶
type ValidationOption ¶
type ValidationOption func(options *ValidationOptions)
ValidationOption allows the modification of how the OpenAPI document is validated.
func AllowExtensionsWithRef ¶
func AllowExtensionsWithRef() ValidationOption
AllowExtensionsWithRef allows extensions (fields starting with 'x-') as siblings for $ref fields. This is the default. Non-extension fields are prohibited unless allowed explicitly with the AllowExtraSiblingFields option.
func AllowExtraSiblingFields ¶
func AllowExtraSiblingFields(fields ...string) ValidationOption
AllowExtraSiblingFields called as AllowExtraSiblingFields("description") makes Validate not return an error when said field appears next to a $ref.
func DisableExamplesValidation ¶
func DisableExamplesValidation() ValidationOption
DisableExamplesValidation disables all example schema validation. By default, all schema examples are validated.
func DisableSchemaDefaultsValidation ¶
func DisableSchemaDefaultsValidation() ValidationOption
DisableSchemaDefaultsValidation disables schemas' default field validation. By default, schema default values are validated against their schema.
func DisableSchemaFormatValidation ¶
func DisableSchemaFormatValidation() ValidationOption
DisableSchemaFormatValidation does the opposite of EnableSchemaFormatValidation. By default, schema format validation is disabled.
func DisableSchemaPatternValidation ¶
func DisableSchemaPatternValidation() ValidationOption
DisableSchemaPatternValidation makes Validate not return an error when validating patterns that are not supported by the Go regexp engine.
func EnableExamplesValidation ¶
func EnableExamplesValidation() ValidationOption
EnableExamplesValidation does the opposite of DisableExamplesValidation. By default, all schema examples are validated.
func EnableSchemaDefaultsValidation ¶
func EnableSchemaDefaultsValidation() ValidationOption
EnableSchemaDefaultsValidation does the opposite of DisableSchemaDefaultsValidation. By default, schema default values are validated against their schema.
func EnableSchemaFormatValidation ¶
func EnableSchemaFormatValidation() ValidationOption
EnableSchemaFormatValidation makes Validate not return an error when validating documents that mention schema formats that are not defined by the OpenAPIv3 specification. By default, schema format validation is disabled.
func EnableSchemaPatternValidation ¶
func EnableSchemaPatternValidation() ValidationOption
EnableSchemaPatternValidation does the opposite of DisableSchemaPatternValidation. By default, schema pattern validation is enabled.
func ProhibitExtensionsWithRef ¶
func ProhibitExtensionsWithRef() ValidationOption
ProhibitExtensionsWithRef causes the validation to return an error if extensions (fields starting with 'x-') are found as siblings for $ref fields. Non-extension fields are prohibited unless allowed explicitly with the AllowExtraSiblingFields option.
func SetRegexCompiler ¶
func SetRegexCompiler(c RegexCompilerFunc) ValidationOption
SetRegexCompiler allows to override the regex implementation used to validate field "pattern".
type ValidationOptions ¶
type ValidationOptions struct {
// contains filtered or unexported fields
}
ValidationOptions provides configuration for validating OpenAPI documents.
type XML ¶
type XML struct { Extensions map[string]any `json:"-" yaml:"-"` Origin *Origin `json:"origin,omitempty" yaml:"origin,omitempty"` Name string `json:"name,omitempty" yaml:"name,omitempty"` Namespace string `json:"namespace,omitempty" yaml:"namespace,omitempty"` Prefix string `json:"prefix,omitempty" yaml:"prefix,omitempty"` Attribute bool `json:"attribute,omitempty" yaml:"attribute,omitempty"` Wrapped bool `json:"wrapped,omitempty" yaml:"wrapped,omitempty"` }
XML is specified by OpenAPI/Swagger standard version 3. See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#xml-object
func (XML) MarshalJSON ¶
MarshalJSON returns the JSON encoding of XML.
func (XML) MarshalYAML ¶
MarshalYAML returns the YAML encoding of XML.
func (*XML) UnmarshalJSON ¶
UnmarshalJSON sets XML to a copy of data.
func (*XML) Validate ¶
func (xml *XML) Validate(ctx context.Context, opts ...ValidationOption) error
Validate returns an error if XML does not comply with the OpenAPI spec.
Source Files ¶
callback.go components.go contact.go content.go discriminator.go doc.go encoding.go errors.go example.go example_validation.go extension.go external_docs.go header.go helpers.go info.go internalize_refs.go license.go link.go loader.go loader_uri_reader.go maplike.go marsh.go media_type.go openapi3.go operation.go origin.go parameter.go path_item.go paths.go ref.go refs.go request_body.go response.go schema.go schema_formats.go schema_pattern.go schema_validation_settings.go security_requirements.go security_scheme.go serialization_method.go server.go stringmap.go tag.go validation_options.go visited.go xml.go
- Version
- v0.129.0 (latest)
- Published
- Dec 24, 2024
- Platform
- linux/amd64
- Imports
- 25 packages
- Last checked
- 1 day ago –
Tools for package owners.