Documentation
¶
Overview ¶
Package openapi3 parses and writes OpenAPI 3 specification documents.
See https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md
Index ¶
- Constants
- Variables
- func BoolPtr(value bool) *bool
- func DefineIPv4Format()
- func DefineIPv6Format()
- func DefineStringFormat(name string, pattern string)
- func DefineStringFormatCallback(name string, callback FormatCallback)
- func Float64Ptr(value float64) *float64
- func Int64Ptr(value int64) *int64
- func RegisterArrayUniqueItemsChecker(fn SliceUniqueItemsChecker)
- func Uint64Ptr(value uint64) *uint64
- func ValidateIdentifier(value string) error
- type AdditionalProperties
- type Builder
- type Callback
- func (e *Callback) AddExtensions(key string, value interface{})
- func (callback *Callback) Delete(key string)
- func (e *Callback) Export(gr int) map[string]interface{}
- func (callback *Callback) Len() int
- func (callback *Callback) Map() (m map[string]*PathItem)
- func (callback *Callback) MarshalJSON() ([]byte, error)
- func (callback *Callback) MarshalYAML() (interface{}, error)
- func (e *Callback) RemoveExtensions(key string)
- func (callback *Callback) Set(key string, value *PathItem)
- func (callback *Callback) Value(key string) *PathItem
- type CallbackRef
- type Callbacks
- type Components
- func (e *Components) AddExtensions(key string, value interface{})
- func (components *Components) AddHeaders()
- func (e *Components) Export(gr int) map[string]interface{}
- func (components *Components) MarshalJSON() ([]byte, error)
- func (components *Components) MarshalYAML() (interface{}, error)
- func (e *Components) RemoveExtensions(key string)
- type Contact
- 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
- type Discriminator
- func (e *Discriminator) AddExtensions(key string, value interface{})
- func (e *Discriminator) Export(gr int) map[string]interface{}
- func (discriminator *Discriminator) MarshalJSON() ([]byte, error)
- func (discriminator *Discriminator) MarshalYAML() (interface{}, error)
- func (e *Discriminator) RemoveExtensions(key string)
- type Encoding
- func (e *Encoding) AddExtensions(key string, value interface{})
- func (e *Encoding) Export(gr int) map[string]interface{}
- func (encoding *Encoding) MarshalJSON() ([]byte, error)
- func (encoding *Encoding) MarshalYAML() (interface{}, error)
- func (e *Encoding) RemoveExtensions(key string)
- func (encoding *Encoding) SerializationMethod() *SerializationMethod
- func (encoding *Encoding) WithHeader(name string, header *Header) *Encoding
- func (encoding *Encoding) WithHeaderRef(name string, ref *HeaderRef) *Encoding
- type Example
- type ExampleRef
- type Examples
- type ExternalDocs
- type Format
- type FormatCallback
- type Header
- type HeaderRef
- type Headers
- type IExtensions
- type Info
- type License
- type Link
- type LinkRef
- type Links
- type MediaType
- func (e *MediaType) AddExtensions(key string, value interface{})
- func (e *MediaType) Export(gr int) map[string]interface{}
- func (mediaType *MediaType) MarshalJSON() ([]byte, error)
- func (mediaType *MediaType) MarshalYAML() (interface{}, error)
- func (e *MediaType) RemoveExtensions(key string)
- func (mediaType *MediaType) WithEncoding(name string, enc *Encoding) *MediaType
- func (mediaType *MediaType) WithExample(name string, value interface{}) *MediaType
- func (mediaType *MediaType) WithSchema(schema *Schema) *MediaType
- func (mediaType *MediaType) WithSchemaRef(schema *SchemaRef) *MediaType
- type NewCallbackOption
- type NewPathsOption
- type NewResponsesOption
- type OAuthFlow
- type OAuthFlows
- type Operation
- func (e *Operation) AddExtensions(key string, value interface{})
- func (operation *Operation) AddParameter(p *Parameter)
- func (operation *Operation) AddResponse(status int, response *Response)
- func (e *Operation) Export(gr int) map[string]interface{}
- func (operation *Operation) MarshalJSON() ([]byte, error)
- func (operation *Operation) MarshalYAML() (interface{}, error)
- func (e *Operation) RemoveExtensions(key string)
- type Parameter
- func (e *Parameter) AddExtensions(key string, value interface{})
- func (e *Parameter) Export(gr int) map[string]interface{}
- func (parameter *Parameter) MarshalJSON() ([]byte, error)
- func (parameter *Parameter) MarshalYAML() (interface{}, error)
- func (e *Parameter) RemoveExtensions(key string)
- func (parameter *Parameter) WithDescription(value string) *Parameter
- func (parameter *Parameter) WithRequired(value bool) *Parameter
- func (parameter *Parameter) WithSchema(value *Schema) *Parameter
- type ParameterRef
- type Parameters
- type ParametersMap
- type PathItem
- func (e *PathItem) AddExtensions(key string, value interface{})
- func (e *PathItem) Export(gr int) map[string]interface{}
- func (pathItem *PathItem) GetOperation(method string) *Operation
- func (pathItem *PathItem) MarshalJSON() ([]byte, error)
- func (pathItem *PathItem) MarshalYAML() (interface{}, error)
- func (pathItem *PathItem) Operations() map[string]*Operation
- func (e *PathItem) RemoveExtensions(key string)
- func (pathItem *PathItem) SetOperation(method string, operation *Operation)
- type Paths
- func (e *Paths) AddExtensions(key string, value interface{})
- func (paths *Paths) Delete(key string)
- func (e *Paths) Export(gr int) map[string]interface{}
- 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 (e *Paths) RemoveExtensions(key string)
- func (paths *Paths) Set(key string, value *PathItem)
- func (paths *Paths) Value(key string) *PathItem
- type Ref
- type RefValue
- type Refs
- type RequestBodies
- type RequestBody
- func (e *RequestBody) AddExtensions(key string, value interface{})
- func (e *RequestBody) Export(gr int) map[string]interface{}
- func (requestBody *RequestBody) GetMediaType(mediaType string) *MediaType
- func (requestBody *RequestBody) MarshalJSON() ([]byte, error)
- func (requestBody *RequestBody) MarshalYAML() (interface{}, error)
- func (e *RequestBody) RemoveExtensions(key string)
- 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
- type Response
- func (e *Response) AddExtensions(key string, value interface{})
- func (e *Response) Export(gr int) map[string]interface{}
- func (response *Response) MarshalJSON() ([]byte, error)
- func (e *Response) RemoveExtensions(key string)
- 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
- type ResponseRef
- type Responses
- func (e *Responses) AddExtensions(key string, value interface{})
- func (responses *Responses) Default() *ResponseRef
- func (responses *Responses) Delete(key string)
- func (e *Responses) Export(gr int) map[string]interface{}
- func (responses *Responses) Len() int
- func (responses *Responses) Map() (m map[string]*ResponseRef)
- func (responses *Responses) MarshalJSON() ([]byte, error)
- func (responses *Responses) MarshalYAML() (interface{}, error)
- func (e *Responses) RemoveExtensions(key string)
- func (responses *Responses) Set(key string, value *ResponseRef)
- func (responses *Responses) Status(status int) *ResponseRef
- 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 (e *Schema) AddExtensions(key string, value interface{})
- func (e *Schema) Export(gr int) map[string]interface{}
- func (schema *Schema) IsEmpty() bool
- func (schema *Schema) MarshalJSON() ([]byte, error)
- func (schema *Schema) NewRef() *SchemaRef
- func (schema *Schema) PermitsNull() bool
- func (e *Schema) RemoveExtensions(key string)
- func (schema *Schema) WithAdditionalProperties(v *Schema) *Schema
- func (schema *Schema) WithAnyAdditionalProperties() *Schema
- func (schema *Schema) WithDefault(defaultValue interface{}) *Schema
- func (schema *Schema) WithEnum(values ...interface{}) *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
- type SchemaRef
- 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 VisitAsRequest() SchemaValidationOption
- func VisitAsResponse() SchemaValidationOption
- type Schemas
- type SecurityRequirement
- type SecurityRequirements
- type SecurityScheme
- func (e *SecurityScheme) AddExtensions(key string, value interface{})
- func (e *SecurityScheme) Export(gr int) map[string]interface{}
- func (ss *SecurityScheme) MarshalJSON() ([]byte, error)
- func (e *SecurityScheme) RemoveExtensions(key string)
- 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
- type SecuritySchemes
- type SerializationMethod
- type Server
- type ServerVariable
- func (e *ServerVariable) AddExtensions(key string, value interface{})
- func (e *ServerVariable) Export(gr int) map[string]interface{}
- func (serverVariable *ServerVariable) MarshalJSON() ([]byte, error)
- func (serverVariable *ServerVariable) MarshalYAML() (interface{}, error)
- func (e *ServerVariable) RemoveExtensions(key string)
- type Servers
- type SliceUniqueItemsChecker
- type T
- func (e *T) AddExtensions(key string, value interface{})
- func (doc *T) AddOperation(path string, method string, operation *Operation)
- func (doc *T) AddServer(server *Server)
- func (doc *T) AddServers(servers ...*Server)
- func (e *T) Export(gr int) map[string]interface{}
- func (doc *T) MarshalJSON() ([]byte, error)
- func (doc *T) MarshalYAML() (interface{}, error)
- func (e *T) RemoveExtensions(key string)
- type Tag
- type Tags
- type Types
- type XML
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 is an optional predefined format for UUID v1-v5 as specified by RFC4122 FormatOfStringForUUIDOfRFC4122 = `` /* 131-byte string literal not displayed */ // FormatOfStringForEmail pattern catches only some suspiciously wrong-looking email addresses. // Use DefineStringFormat(...) if you need something stricter. FormatOfStringForEmail = `^[^@]+@[^@<>",\s]+$` )
const ( SerializationSimple = "simple" SerializationLabel = "label" SerializationMatrix = "matrix" SerializationForm = "form" SerializationSpaceDelimited = "spaceDelimited" SerializationPipeDelimited = "pipeDelimited" SerializationDeepObject = "deepObject" )
Variables ¶
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 IdentifierRegExp = regexp.MustCompile(identifierPattern)
IdentifierRegExp verifies whether Component object key matches 'identifierPattern' pattern, according to OpenAPI v3.x. 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 SchemaStringFormats = make(map[string]Format, 4)
SchemaStringFormats allows for validating string formats
Functions ¶
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 DefineStringFormat ¶
DefineStringFormat defines a new regexp pattern for a given format
func DefineStringFormatCallback ¶
func DefineStringFormatCallback(name string, callback FormatCallback)
DefineStringFormatCallback adds a validation function for a specific schema format entry
func Float64Ptr ¶
Float64Ptr is a helper for defining OpenAPI schemas.
func RegisterArrayUniqueItemsChecker ¶
func RegisterArrayUniqueItemsChecker(fn SliceUniqueItemsChecker)
RegisterArrayUniqueItemsChecker is used to register a customized function used to check if JSON array have unique items.
func ValidateIdentifier ¶
ValidateIdentifier returns an error if the given component name does not match IdentifierRegExp.
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() (interface{}, error)
MarshalYAML returns the YAML encoding of AdditionalProperties.
type Callback ¶
type Callback struct {
// 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) AddExtensions ¶
func (e *Callback) AddExtensions(key string, value interface{})
func (*Callback) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Callback.
func (*Callback) MarshalYAML ¶
func (*Callback) RemoveExtensions ¶
func (e *Callback) RemoveExtensions(key string)
type CallbackRef ¶
CallbackRef represents either a Callback or a $ref to a Callback. When serializing and both fields are set, Ref is preferred over Value.
type Components ¶
type Components struct {
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"`
// contains filtered or unexported fields
}
Components are 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) AddExtensions ¶
func (e *Components) AddExtensions(key string, value interface{})
func (*Components) AddHeaders ¶
func (components *Components) AddHeaders()
func (*Components) MarshalJSON ¶
func (components *Components) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of Components.
func (*Components) MarshalYAML ¶
func (components *Components) MarshalYAML() (interface{}, error)
func (*Components) RemoveExtensions ¶
func (e *Components) RemoveExtensions(key string)
type Contact ¶
type Contact struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
URL string `json:"url,omitempty" yaml:"url,omitempty"`
Email string `json:"email,omitempty" yaml:"email,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Contact) AddExtensions(key string, value interface{})
func (*Contact) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Contact.
func (*Contact) MarshalYAML ¶
func (*Contact) RemoveExtensions ¶
func (e *Contact) RemoveExtensions(key string)
type Content ¶
Content is specified by OpenAPI/Swagger 3.0 standard.
func NewContent ¶
func NewContent() Content
func NewContentWithSchema ¶
func NewContentWithSchemaRef ¶
type Discriminator ¶
type Discriminator struct {
PropertyName string `json:"propertyName" yaml:"propertyName"` // required
Mapping map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Discriminator) AddExtensions(key string, value interface{})
func (*Discriminator) MarshalJSON ¶
func (discriminator *Discriminator) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of Discriminator.
func (*Discriminator) MarshalYAML ¶
func (discriminator *Discriminator) MarshalYAML() (interface{}, error)
func (*Discriminator) RemoveExtensions ¶
func (e *Discriminator) RemoveExtensions(key string)
type Encoding ¶
type Encoding struct {
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"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Encoding) AddExtensions(key string, value interface{})
func (*Encoding) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Encoding.
func (*Encoding) MarshalYAML ¶
func (*Encoding) RemoveExtensions ¶
func (e *Encoding) RemoveExtensions(key string)
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) WithHeader ¶
type Example ¶
type Example struct {
Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Value interface{} `json:"value,omitempty" yaml:"value,omitempty"`
ExternalValue string `json:"externalValue,omitempty" yaml:"externalValue,omitempty"`
// contains filtered or unexported fields
}
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 NewExample(value interface{}) *Example
func (*Example) AddExtensions ¶
func (e *Example) AddExtensions(key string, value interface{})
func (*Example) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Example.
func (*Example) MarshalYAML ¶
func (*Example) RemoveExtensions ¶
func (e *Example) RemoveExtensions(key string)
type ExampleRef ¶
ExampleRef represents either an Example or a $ref to an Example. When serializing and both fields are set, Ref is preferred over Value.
type ExternalDocs ¶
type ExternalDocs struct {
Description string `json:"description,omitempty" yaml:"description,omitempty"`
URL string `json:"url,omitempty" yaml:"url,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *ExternalDocs) AddExtensions(key string, value interface{})
func (*ExternalDocs) MarshalJSON ¶
func (e *ExternalDocs) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of ExternalDocs.
func (*ExternalDocs) MarshalYAML ¶
func (e *ExternalDocs) MarshalYAML() (interface{}, error)
func (*ExternalDocs) RemoveExtensions ¶
func (e *ExternalDocs) RemoveExtensions(key string)
type Format ¶
type Format struct {
// contains filtered or unexported fields
}
Format represents a format validator registered by either DefineStringFormat or DefineStringFormatCallback
type FormatCallback ¶
FormatCallback performs custom checks on exotic formats
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) AddExtensions ¶
func (e *Header) AddExtensions(key string, value interface{})
func (*Header) RemoveExtensions ¶
func (e *Header) RemoveExtensions(key string)
type HeaderRef ¶
HeaderRef represents either a Header or a $ref to a Header. When serializing and both fields are set, Ref is preferred over Value.
type IExtensions ¶
type Info ¶
type Info struct {
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
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Info) AddExtensions(key string, value interface{})
func (*Info) MarshalJSON ¶
func (*Info) MarshalYAML ¶
func (*Info) RemoveExtensions ¶
func (e *Info) RemoveExtensions(key string)
type License ¶
type License struct {
Name string `json:"name" yaml:"name"` // Required
URL string `json:"url,omitempty" yaml:"url,omitempty"`
// contains filtered or unexported fields
}
The 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) AddExtensions ¶
func (e *License) AddExtensions(key string, value interface{})
func (*License) MarshalJSON ¶
MarshalJSON returns the JSON encoding of License.
func (*License) MarshalYAML ¶
func (*License) RemoveExtensions ¶
func (e *License) RemoveExtensions(key string)
type Link ¶
type Link struct {
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]interface{} `json:"parameters,omitempty" yaml:"parameters,omitempty"`
Server *Server `json:"server,omitempty" yaml:"server,omitempty"`
RequestBody interface{} `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
// contains filtered or unexported fields
}
The 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) AddExtensions ¶
func (e *Link) AddExtensions(key string, value interface{})
func (*Link) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Link.
func (*Link) MarshalYAML ¶
func (*Link) RemoveExtensions ¶
func (e *Link) RemoveExtensions(key string)
type LinkRef ¶
LinkRef represents either a Link or a $ref to a Link. When serializing and both fields are set, Ref is preferred over Value.
type MediaType ¶
type MediaType struct {
Schema *SchemaRef `json:"schema,omitempty" yaml:"schema,omitempty"`
Example interface{} `json:"example,omitempty" yaml:"example,omitempty"`
Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"`
Encoding map[string]*Encoding `json:"encoding,omitempty" yaml:"encoding,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *MediaType) AddExtensions(key string, value interface{})
func (*MediaType) MarshalJSON ¶
func (*MediaType) MarshalYAML ¶
func (*MediaType) RemoveExtensions ¶
func (e *MediaType) RemoveExtensions(key string)
func (*MediaType) WithEncoding ¶
func (*MediaType) WithExample ¶
func (*MediaType) WithSchema ¶
func (*MediaType) WithSchemaRef ¶
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 OAuthFlow ¶
type OAuthFlow struct {
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 map[string]string `json:"scopes" yaml:"scopes"` // required
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *OAuthFlow) AddExtensions(key string, value interface{})
func (*OAuthFlow) MarshalJSON ¶
MarshalJSON returns the JSON encoding of OAuthFlow.
func (*OAuthFlow) MarshalYAML ¶
func (*OAuthFlow) RemoveExtensions ¶
func (e *OAuthFlow) RemoveExtensions(key string)
type OAuthFlows ¶
type OAuthFlows struct {
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"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *OAuthFlows) AddExtensions(key string, value interface{})
func (*OAuthFlows) MarshalJSON ¶
func (flows *OAuthFlows) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of OAuthFlows.
func (*OAuthFlows) MarshalYAML ¶
func (flows *OAuthFlows) MarshalYAML() (interface{}, error)
func (*OAuthFlows) RemoveExtensions ¶
func (e *OAuthFlows) RemoveExtensions(key string)
type Operation ¶
type Operation struct {
// 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 override top-level security.
Security *SecurityRequirements `json:"security,omitempty" yaml:"security,omitempty"`
// Optional servers that override top-level servers.
Servers *Servers `json:"servers,omitempty" yaml:"servers,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Operation) AddExtensions(key string, value interface{})
func (*Operation) AddParameter ¶
func (*Operation) AddResponse ¶
func (*Operation) MarshalJSON ¶
func (*Operation) MarshalYAML ¶
func (*Operation) RemoveExtensions ¶
func (e *Operation) RemoveExtensions(key string)
type Parameter ¶
type Parameter struct {
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 interface{} `json:"example,omitempty" yaml:"example,omitempty"`
Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"`
Content Content `json:"content,omitempty" yaml:"content,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Parameter) AddExtensions(key string, value interface{})
func (*Parameter) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Parameter.
func (*Parameter) MarshalYAML ¶
func (*Parameter) RemoveExtensions ¶
func (e *Parameter) RemoveExtensions(key string)
func (*Parameter) WithDescription ¶
func (*Parameter) WithRequired ¶
func (*Parameter) WithSchema ¶
type ParameterRef ¶
ParameterRef represents either a Parameter or a $ref to a Parameter. When serializing and both fields are set, Ref is preferred over Value.
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
type ParametersMap ¶
type PathItem ¶
type PathItem struct {
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"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *PathItem) AddExtensions(key string, value interface{})
func (*PathItem) GetOperation ¶
func (*PathItem) MarshalJSON ¶
func (*PathItem) MarshalYAML ¶
func (*PathItem) Operations ¶
func (*PathItem) RemoveExtensions ¶
func (e *PathItem) RemoveExtensions(key string)
func (*PathItem) SetOperation ¶
type Paths ¶
type Paths struct {
// 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) AddExtensions ¶
func (e *Paths) AddExtensions(key string, value interface{})
func (*Paths) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Paths.
func (*Paths) MarshalYAML ¶
Support YAML Marshaler interface for gopkg.in/yaml
func (*Paths) RemoveExtensions ¶
func (e *Paths) RemoveExtensions(key string)
type Ref ¶
type Ref struct {
Ref string `json:"$ref" yaml:"$ref"`
}
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 RefValue ¶
type RefValue[T marshaller] struct {
Ref string
Value T
}
func (*RefValue[T]) MarshalJSON ¶
MarshalJSON returns the JSON encoding of CallbackRef.
func (*RefValue[T]) MarshalYAML ¶
MarshalYAML returns the YAML encoding of CallbackRef.
type RequestBodies ¶
type RequestBodies Refs[*RequestBody]
type RequestBody ¶
type RequestBody struct {
Description string `json:"description,omitempty" yaml:"description,omitempty"`
Required bool `json:"required,omitempty" yaml:"required,omitempty"`
Content Content `json:"content" yaml:"content"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *RequestBody) AddExtensions(key string, value interface{})
func (*RequestBody) GetMediaType ¶
func (requestBody *RequestBody) GetMediaType(mediaType string) *MediaType
func (*RequestBody) MarshalJSON ¶
func (requestBody *RequestBody) MarshalJSON() ([]byte, error)
func (*RequestBody) MarshalYAML ¶
func (requestBody *RequestBody) MarshalYAML() (interface{}, error)
func (*RequestBody) RemoveExtensions ¶
func (e *RequestBody) RemoveExtensions(key string)
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 = RefValue[*RequestBody]
RequestBodyRef represents either a RequestBody or a $ref to a RequestBody. When serializing and both fields are set, Ref is preferred over Value.
type Response ¶
type Response struct {
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"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Response) AddExtensions(key string, value interface{})
func (*Response) MarshalJSON ¶
func (*Response) RemoveExtensions ¶
func (e *Response) RemoveExtensions(key string)
func (*Response) WithContent ¶
func (*Response) WithDescription ¶
func (*Response) WithJSONSchema ¶
func (*Response) WithJSONSchemaRef ¶
type ResponseBodies ¶
type ResponseRef ¶
ResponseRef represents either a Response or a $ref to a Response. When serializing and both fields are set, Ref is preferred over Value.
type Responses ¶
type Responses struct {
// 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) AddExtensions ¶
func (e *Responses) AddExtensions(key string, value interface{})
func (*Responses) Default ¶
func (responses *Responses) Default() *ResponseRef
Default returns the default response
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 ¶
func (*Responses) MarshalYAML ¶
func (*Responses) RemoveExtensions ¶
func (e *Responses) RemoveExtensions(key string)
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) Value ¶
func (responses *Responses) Value(key string) *ResponseRef
Value returns the responses for key or nil
type Schema ¶
type Schema struct {
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 []interface{} `json:"enum,omitempty" yaml:"enum,omitempty"`
Default interface{} `json:"default,omitempty" yaml:"default,omitempty"`
Example interface{} `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"`
// contains filtered or unexported fields
}
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 NewStringSchema ¶
func NewStringSchema() *Schema
func NewUUIDSchema ¶
func NewUUIDSchema() *Schema
func (*Schema) AddExtensions ¶
func (e *Schema) AddExtensions(key string, value interface{})
func (*Schema) MarshalJSON ¶
MarshalJSON returns the JSON encoding of Schema.
func (*Schema) PermitsNull ¶
func (*Schema) RemoveExtensions ¶
func (e *Schema) RemoveExtensions(key string)
func (*Schema) WithAdditionalProperties ¶
func (*Schema) WithAnyAdditionalProperties ¶
func (*Schema) WithDefault ¶
func (*Schema) WithExclusiveMax ¶
func (*Schema) WithExclusiveMin ¶
func (*Schema) WithFormat ¶
func (*Schema) WithLength ¶
func (*Schema) WithLengthDecodedBase64 ¶
func (*Schema) WithMaxItems ¶
func (*Schema) WithMaxLength ¶
func (*Schema) WithMaxLengthDecodedBase64 ¶
func (*Schema) WithMaxProperties ¶
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 interface{}
// 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 ¶
SchemaRef represents either a Schema or a $ref to a Schema. When serializing and both fields are set, Ref is preferred over Value.
func (*SchemaRef) MarshalJSON ¶
由于存在循环定义, 不能用别名,需要重新实现 marshaller
func (*SchemaRef) MarshalYAML ¶
type SchemaRefs ¶
type SchemaRefs []*SchemaRef
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.
func VisitAsRequest ¶
func VisitAsRequest() SchemaValidationOption
func VisitAsResponse ¶
func VisitAsResponse() SchemaValidationOption
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
type SecurityRequirements ¶
type SecurityRequirements []SecurityRequirement
func NewSecurityRequirements ¶
func NewSecurityRequirements() *SecurityRequirements
func (*SecurityRequirements) With ¶
func (srs *SecurityRequirements) With(securityRequirement SecurityRequirement) *SecurityRequirements
type SecurityScheme ¶
type SecurityScheme struct {
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"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *SecurityScheme) AddExtensions(key string, value interface{})
func (*SecurityScheme) MarshalJSON ¶
func (ss *SecurityScheme) MarshalJSON() ([]byte, error)
func (*SecurityScheme) RemoveExtensions ¶
func (e *SecurityScheme) RemoveExtensions(key string)
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 = RefValue[*SecurityScheme]
SecuritySchemeRef represents either a SecurityScheme or a $ref to a SecurityScheme. When serializing and both fields are set, Ref is preferred over Value.
type SecuritySchemes ¶
type SecuritySchemes Refs[*SecurityScheme]
type SerializationMethod ¶
SerializationMethod describes a serialization method of HTTP request's parameters and body.
type Server ¶
type Server struct {
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"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Server) AddExtensions(key string, value interface{})
func (*Server) MarshalJSON ¶
func (*Server) MarshalYAML ¶
func (*Server) RemoveExtensions ¶
func (e *Server) RemoveExtensions(key string)
type ServerVariable ¶
type ServerVariable struct {
Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"`
Default string `json:"default,omitempty" yaml:"default,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *ServerVariable) AddExtensions(key string, value interface{})
func (*ServerVariable) MarshalJSON ¶
func (serverVariable *ServerVariable) MarshalJSON() ([]byte, error)
MarshalJSON returns the JSON encoding of ServerVariable.
func (*ServerVariable) MarshalYAML ¶
func (serverVariable *ServerVariable) MarshalYAML() (interface{}, error)
func (*ServerVariable) RemoveExtensions ¶
func (e *ServerVariable) RemoveExtensions(key string)
type SliceUniqueItemsChecker ¶
type SliceUniqueItemsChecker func(items []interface{}) bool
SliceUniqueItemsChecker is a function used to check if a given slice have unique items.
type T ¶
type T struct {
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) AddExtensions ¶
func (e *T) AddExtensions(key string, value interface{})
func (*T) AddOperation ¶
func (*T) AddServers ¶
func (*T) MarshalJSON ¶
MarshalJSON returns the JSON encoding of T.
func (*T) MarshalYAML ¶
func (*T) RemoveExtensions ¶
func (e *T) RemoveExtensions(key string)
type Tag ¶
type Tag struct {
Name string `json:"name,omitempty" yaml:"name,omitempty"`
Description string `json:"description,omitempty" yaml:"description,omitempty"`
ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *Tag) AddExtensions(key string, value interface{})
func (*Tag) MarshalJSON ¶
func (*Tag) MarshalYAML ¶
func (*Tag) RemoveExtensions ¶
func (e *Tag) RemoveExtensions(key string)
type XML ¶
type XML struct {
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"`
// contains filtered or unexported fields
}
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) AddExtensions ¶
func (e *XML) AddExtensions(key string, value interface{})
func (*XML) MarshalJSON ¶
func (*XML) MarshalYAML ¶
func (*XML) RemoveExtensions ¶
func (e *XML) RemoveExtensions(key string)
Source Files
¶
- builder.go
- callback.go
- components.go
- contact.go
- content.go
- discriminator.go
- doc.go
- encoding.go
- example.go
- extension.go
- external_docs.go
- header.go
- helpers.go
- info.go
- license.go
- link.go
- maplike.go
- marsh.go
- marshal.go
- media_type.go
- openapi.go
- operation.go
- parameter.go
- path_item.go
- paths.go
- ref-name.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
- tag.go
- xml.go