openapi3

package module
v0.0.0-...-c6dd166 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: GPL-3.0 Imports: 12 Imported by: 1

README

go-openapi

a tool for building and documenting Go RESTful APIs 基于 github.com/getkin/kin-openapi 下 openapi3 包, 在写法上使用泛型合并了各类操作, 移除了 Unmarshal和Validate相关的代码,仅保留数据结构与 MarshalJSON 和 MarshalYAML, 专注于生成openapi3的文档结构

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

View Source
const (
	ParameterInPath   = "path"
	ParameterInQuery  = "query"
	ParameterInHeader = "header"
	ParameterInCookie = "cookie"
)
View Source
const (
	TypeArray   = "array"
	TypeBoolean = "boolean"
	TypeInteger = "integer"
	TypeNumber  = "number"
	TypeObject  = "object"
	TypeString  = "string"
	TypeNull    = "null"
)
View Source
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]+$`
)
View Source
const (
	SerializationSimple         = "simple"
	SerializationLabel          = "label"
	SerializationMatrix         = "matrix"
	SerializationForm           = "form"
	SerializationSpaceDelimited = "spaceDelimited"
	SerializationPipeDelimited  = "pipeDelimited"
	SerializationDeepObject     = "deepObject"
)

Variables

View Source
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")
)
View Source
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

View Source
var SchemaStringFormats = make(map[string]Format, 4)

SchemaStringFormats allows for validating string formats

Functions

func BoolPtr

func BoolPtr(value bool) *bool

BoolPtr is a helper for defining OpenAPI schemas.

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

func DefineStringFormat(name string, pattern string)

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

func Float64Ptr(value float64) *float64

Float64Ptr is a helper for defining OpenAPI schemas.

func Int64Ptr

func Int64Ptr(value int64) *int64

Int64Ptr 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 Uint64Ptr

func Uint64Ptr(value uint64) *uint64

Uint64Ptr is a helper for defining OpenAPI schemas.

func ValidateIdentifier

func ValidateIdentifier(value string) error

ValidateIdentifier returns an error if the given component name does not match IdentifierRegExp.

Types

type AdditionalProperties

type AdditionalProperties struct {
	Has    *bool
	Schema *SchemaRef
}

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 Builder

type Builder interface {
}

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

func NewCallbackWithCapacity(cap int) *Callback

NewCallbackWithCapacity builds a callback object of the given capacity.

func (*Callback) AddExtensions

func (e *Callback) AddExtensions(key string, value interface{})

func (*Callback) Delete

func (callback *Callback) Delete(key string)

Delete removes the entry associated with key 'key' from 'callback'.

func (*Callback) Export

func (e *Callback) Export(gr int) map[string]interface{}

func (*Callback) Len

func (callback *Callback) Len() int

Len returns the amount of keys in callback excluding callback.extensions.

func (*Callback) Map

func (callback *Callback) Map() (m map[string]*PathItem)

Map returns callback as a 'map'. Note: iteration on Go maps is not ordered.

func (*Callback) MarshalJSON

func (callback *Callback) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Callback.

func (*Callback) MarshalYAML

func (callback *Callback) MarshalYAML() (interface{}, error)

func (*Callback) RemoveExtensions

func (e *Callback) RemoveExtensions(key string)

func (*Callback) Set

func (callback *Callback) Set(key string, value *PathItem)

Set adds or replaces key 'key' of 'callback' with 'value'. Note: 'callback' MUST be non-nil

func (*Callback) Value

func (callback *Callback) Value(key string) *PathItem

Value returns the callback for key or nil

type CallbackRef

type CallbackRef = RefValue[*Callback]

CallbackRef represents either a Callback or a $ref to a Callback. When serializing and both fields are set, Ref is preferred over Value.

type Callbacks

type Callbacks Refs[*Callback]

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) Export

func (e *Components) Export(gr int) map[string]interface{}

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) Export

func (e *Contact) Export(gr int) map[string]interface{}

func (*Contact) MarshalJSON

func (contact *Contact) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Contact.

func (*Contact) MarshalYAML

func (contact *Contact) MarshalYAML() (interface{}, error)

func (*Contact) RemoveExtensions

func (e *Contact) RemoveExtensions(key string)

type Content

type Content map[string]*MediaType

Content is specified by OpenAPI/Swagger 3.0 standard.

func NewContent

func NewContent() Content

func NewContentWithFormDataSchema

func NewContentWithFormDataSchema(schema *Schema) Content

func NewContentWithFormDataSchemaRef

func NewContentWithFormDataSchemaRef(schema *SchemaRef) Content

func NewContentWithJSONSchema

func NewContentWithJSONSchema(schema *Schema) Content

func NewContentWithJSONSchemaRef

func NewContentWithJSONSchemaRef(schema *SchemaRef) Content

func NewContentWithSchema

func NewContentWithSchema(schema *Schema, consumes []string) Content

func NewContentWithSchemaRef

func NewContentWithSchemaRef(schema *SchemaRef, consumes []string) Content

func (Content) Get

func (content Content) Get(mime string) *MediaType

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) Export

func (e *Discriminator) Export(gr int) map[string]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) Export

func (e *Encoding) Export(gr int) map[string]interface{}

func (*Encoding) MarshalJSON

func (encoding *Encoding) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Encoding.

func (*Encoding) MarshalYAML

func (encoding *Encoding) MarshalYAML() (interface{}, error)

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

func (encoding *Encoding) WithHeader(name string, header *Header) *Encoding

func (*Encoding) WithHeaderRef

func (encoding *Encoding) WithHeaderRef(name string, ref *HeaderRef) *Encoding

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) Export

func (e *Example) Export(gr int) map[string]interface{}

func (*Example) MarshalJSON

func (example *Example) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Example.

func (*Example) MarshalYAML

func (example *Example) MarshalYAML() (interface{}, error)

func (*Example) RemoveExtensions

func (e *Example) RemoveExtensions(key string)

type ExampleRef

type ExampleRef = RefValue[*Example]

ExampleRef represents either an Example or a $ref to an Example. When serializing and both fields are set, Ref is preferred over Value.

type Examples

type Examples Refs[*Example]

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) Export

func (e *ExternalDocs) Export(gr int) map[string]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

type FormatCallback func(value string) error

FormatCallback performs custom checks on exotic formats

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) Export

func (e *Header) Export(gr int) map[string]interface{}

func (*Header) RemoveExtensions

func (e *Header) RemoveExtensions(key string)

type HeaderRef

type HeaderRef = RefValue[*Header]

HeaderRef represents either a Header or a $ref to a Header. When serializing and both fields are set, Ref is preferred over Value.

type Headers

type Headers Refs[*Header]

type IExtensions

type IExtensions interface {
	AddExtensions(key string, value interface{})
	RemoveExtensions(key string)
	Export(gr int) map[string]interface{}
}

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) Export

func (e *Info) Export(gr int) map[string]interface{}

func (*Info) MarshalJSON

func (info *Info) MarshalJSON() ([]byte, error)

func (*Info) MarshalYAML

func (info *Info) MarshalYAML() (interface{}, error)

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) Export

func (e *License) Export(gr int) map[string]interface{}

func (*License) MarshalJSON

func (license *License) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of License.

func (*License) MarshalYAML

func (license *License) MarshalYAML() (interface{}, error)

func (*License) RemoveExtensions

func (e *License) RemoveExtensions(key string)
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) Export

func (e *Link) Export(gr int) map[string]interface{}

func (*Link) MarshalJSON

func (link *Link) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Link.

func (*Link) MarshalYAML

func (link *Link) MarshalYAML() (interface{}, error)

func (*Link) RemoveExtensions

func (e *Link) RemoveExtensions(key string)

type LinkRef

type LinkRef = RefValue[*Link]

LinkRef represents either a Link or a $ref to a Link. When serializing and both fields are set, Ref is preferred over Value.

type Links Refs[*Link]

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) Export

func (e *MediaType) Export(gr int) map[string]interface{}

func (*MediaType) MarshalJSON

func (mediaType *MediaType) MarshalJSON() ([]byte, error)

func (*MediaType) MarshalYAML

func (mediaType *MediaType) MarshalYAML() (interface{}, error)

func (*MediaType) RemoveExtensions

func (e *MediaType) RemoveExtensions(key string)

func (*MediaType) WithEncoding

func (mediaType *MediaType) WithEncoding(name string, enc *Encoding) *MediaType

func (*MediaType) WithExample

func (mediaType *MediaType) WithExample(name string, value interface{}) *MediaType

func (*MediaType) WithSchema

func (mediaType *MediaType) WithSchema(schema *Schema) *MediaType

func (*MediaType) WithSchemaRef

func (mediaType *MediaType) WithSchemaRef(schema *SchemaRef) *MediaType

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) Export

func (e *OAuthFlow) Export(gr int) map[string]interface{}

func (*OAuthFlow) MarshalJSON

func (flow *OAuthFlow) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of OAuthFlow.

func (*OAuthFlow) MarshalYAML

func (flow *OAuthFlow) MarshalYAML() (interface{}, error)

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) Export

func (e *OAuthFlows) Export(gr int) map[string]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 *Operation) AddParameter(p *Parameter)

func (*Operation) AddResponse

func (operation *Operation) AddResponse(status int, response *Response)

func (*Operation) Export

func (e *Operation) Export(gr int) map[string]interface{}

func (*Operation) MarshalJSON

func (operation *Operation) MarshalJSON() ([]byte, error)

func (*Operation) MarshalYAML

func (operation *Operation) MarshalYAML() (interface{}, error)

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 NewCookieParameter(name string) *Parameter

func NewHeaderParameter

func NewHeaderParameter(name string) *Parameter

func NewPathParameter

func NewPathParameter(name string) *Parameter

func NewQueryParameter

func NewQueryParameter(name string) *Parameter

func (*Parameter) AddExtensions

func (e *Parameter) AddExtensions(key string, value interface{})

func (*Parameter) Export

func (e *Parameter) Export(gr int) map[string]interface{}

func (*Parameter) MarshalJSON

func (parameter *Parameter) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Parameter.

func (*Parameter) MarshalYAML

func (parameter *Parameter) MarshalYAML() (interface{}, error)

func (*Parameter) RemoveExtensions

func (e *Parameter) RemoveExtensions(key string)

func (*Parameter) WithDescription

func (parameter *Parameter) WithDescription(value string) *Parameter

func (*Parameter) WithRequired

func (parameter *Parameter) WithRequired(value bool) *Parameter

func (*Parameter) WithSchema

func (parameter *Parameter) WithSchema(value *Schema) *Parameter

type ParameterRef

type ParameterRef = RefValue[*Parameter]

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 ParametersMap Refs[*Parameter]

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) Export

func (e *PathItem) Export(gr int) map[string]interface{}

func (*PathItem) GetOperation

func (pathItem *PathItem) GetOperation(method string) *Operation

func (*PathItem) MarshalJSON

func (pathItem *PathItem) MarshalJSON() ([]byte, error)

func (*PathItem) MarshalYAML

func (pathItem *PathItem) MarshalYAML() (interface{}, error)

func (*PathItem) Operations

func (pathItem *PathItem) Operations() map[string]*Operation

func (*PathItem) RemoveExtensions

func (e *PathItem) RemoveExtensions(key string)

func (*PathItem) SetOperation

func (pathItem *PathItem) SetOperation(method string, operation *Operation)

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

func NewPathsWithCapacity(cap int) *Paths

NewPathsWithCapacity builds a paths object of the given capacity.

func (*Paths) AddExtensions

func (e *Paths) AddExtensions(key string, value interface{})

func (*Paths) Delete

func (paths *Paths) Delete(key string)

Delete removes the entry associated with key 'key' from 'paths'.

func (*Paths) Export

func (e *Paths) Export(gr int) map[string]interface{}

func (*Paths) Len

func (paths *Paths) Len() int

Len returns the amount of keys in paths excluding paths.extensions.

func (*Paths) Map

func (paths *Paths) Map() (m map[string]*PathItem)

Map returns paths as a 'map'. Note: iteration on Go maps is not ordered.

func (*Paths) MarshalJSON

func (paths *Paths) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Paths.

func (*Paths) MarshalYAML

func (paths *Paths) MarshalYAML() (any, error)

Support YAML Marshaler interface for gopkg.in/yaml

func (*Paths) RemoveExtensions

func (e *Paths) RemoveExtensions(key string)

func (*Paths) Set

func (paths *Paths) Set(key string, value *PathItem)

Set adds or replaces key 'key' of 'paths' with 'value'. Note: 'paths' MUST be non-nil

func (*Paths) Value

func (paths *Paths) Value(key string) *PathItem

Value returns the paths for key or nil

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

func (x *RefValue[T]) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of CallbackRef.

func (*RefValue[T]) MarshalYAML

func (x *RefValue[T]) MarshalYAML() (interface{}, error)

MarshalYAML returns the YAML encoding of CallbackRef.

func (*RefValue[T]) RefTo

func (x *RefValue[T]) RefTo(name string)

func (*RefValue[T]) Set

func (x *RefValue[T]) Set(v T)

type Refs

type Refs[T marshaller] map[string]*RefValue[T]

func (Refs[T]) AddRef

func (refs Refs[T]) AddRef(name string, ref string)

func (Refs[T]) AddValue

func (refs Refs[T]) AddValue(name string, value T)

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) Export

func (e *RequestBody) Export(gr int) map[string]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) Export

func (e *Response) Export(gr int) map[string]interface{}

func (*Response) MarshalJSON

func (response *Response) MarshalJSON() ([]byte, error)

func (*Response) RemoveExtensions

func (e *Response) RemoveExtensions(key string)

func (*Response) WithContent

func (response *Response) WithContent(content Content) *Response

func (*Response) WithDescription

func (response *Response) WithDescription(value string) *Response

func (*Response) WithJSONSchema

func (response *Response) WithJSONSchema(schema *Schema) *Response

func (*Response) WithJSONSchemaRef

func (response *Response) WithJSONSchemaRef(schema *SchemaRef) *Response

type ResponseBodies

type ResponseBodies Refs[*Response]

type ResponseRef

type ResponseRef = RefValue[*Response]

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

func NewResponsesWithCapacity(cap int) *Responses

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) Delete

func (responses *Responses) Delete(key string)

Delete removes the entry associated with key 'key' from 'responses'.

func (*Responses) Export

func (e *Responses) Export(gr int) map[string]interface{}

func (*Responses) Len

func (responses *Responses) Len() int

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

func (responses *Responses) MarshalJSON() ([]byte, error)

func (*Responses) MarshalYAML

func (responses *Responses) MarshalYAML() (interface{}, error)

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 NewAllOfSchema(schemas ...*Schema) *Schema

func NewAnyOfSchema

func NewAnyOfSchema(schemas ...*Schema) *Schema

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 NewOneOfSchema(schemas ...*Schema) *Schema

func NewSchema

func NewSchema() *Schema

func NewStringSchema

func NewStringSchema() *Schema

func NewUUIDSchema

func NewUUIDSchema() *Schema

func (*Schema) AddExtensions

func (e *Schema) AddExtensions(key string, value interface{})

func (*Schema) Export

func (e *Schema) Export(gr int) map[string]interface{}

func (*Schema) IsEmpty

func (schema *Schema) IsEmpty() bool

IsEmpty tells whether schema is equivalent to the empty schema `{}`.

func (*Schema) MarshalJSON

func (schema *Schema) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of Schema.

func (*Schema) NewRef

func (schema *Schema) NewRef() *SchemaRef

func (*Schema) PermitsNull

func (schema *Schema) PermitsNull() bool

func (*Schema) RemoveExtensions

func (e *Schema) RemoveExtensions(key string)

func (*Schema) WithAdditionalProperties

func (schema *Schema) WithAdditionalProperties(v *Schema) *Schema

func (*Schema) WithAnyAdditionalProperties

func (schema *Schema) WithAnyAdditionalProperties() *Schema

func (*Schema) WithDefault

func (schema *Schema) WithDefault(defaultValue interface{}) *Schema

func (*Schema) WithEnum

func (schema *Schema) WithEnum(values ...interface{}) *Schema

func (*Schema) WithExclusiveMax

func (schema *Schema) WithExclusiveMax(value bool) *Schema

func (*Schema) WithExclusiveMin

func (schema *Schema) WithExclusiveMin(value bool) *Schema

func (*Schema) WithFormat

func (schema *Schema) WithFormat(value string) *Schema

func (*Schema) WithItems

func (schema *Schema) WithItems(value *Schema) *Schema

func (*Schema) WithLength

func (schema *Schema) WithLength(i int64) *Schema

func (*Schema) WithLengthDecodedBase64

func (schema *Schema) WithLengthDecodedBase64(i int64) *Schema

func (*Schema) WithMax

func (schema *Schema) WithMax(value float64) *Schema

func (*Schema) WithMaxItems

func (schema *Schema) WithMaxItems(i int64) *Schema

func (*Schema) WithMaxLength

func (schema *Schema) WithMaxLength(i int64) *Schema

func (*Schema) WithMaxLengthDecodedBase64

func (schema *Schema) WithMaxLengthDecodedBase64(i int64) *Schema

func (*Schema) WithMaxProperties

func (schema *Schema) WithMaxProperties(i int64) *Schema

func (*Schema) WithMin

func (schema *Schema) WithMin(value float64) *Schema

func (*Schema) WithMinItems

func (schema *Schema) WithMinItems(i int64) *Schema

func (*Schema) WithMinLength

func (schema *Schema) WithMinLength(i int64) *Schema

func (*Schema) WithMinLengthDecodedBase64

func (schema *Schema) WithMinLengthDecodedBase64(i int64) *Schema

func (*Schema) WithMinProperties

func (schema *Schema) WithMinProperties(i int64) *Schema

func (*Schema) WithNullable

func (schema *Schema) WithNullable() *Schema

func (*Schema) WithPattern

func (schema *Schema) WithPattern(pattern string) *Schema

func (*Schema) WithProperties

func (schema *Schema) WithProperties(properties map[string]*Schema) *Schema

func (*Schema) WithProperty

func (schema *Schema) WithProperty(name string, propertySchema *Schema) *Schema

func (*Schema) WithPropertyRef

func (schema *Schema) WithPropertyRef(name string, ref *SchemaRef) *Schema

func (*Schema) WithRequired

func (schema *Schema) WithRequired(required []string) *Schema

func (*Schema) WithUniqueItems

func (schema *Schema) WithUniqueItems(unique bool) *Schema

func (*Schema) WithoutAdditionalProperties

func (schema *Schema) WithoutAdditionalProperties() *Schema

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

type SchemaRef RefValue[*Schema]

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

func (s *SchemaRef) MarshalJSON() ([]byte, error)

由于存在循环定义, 不能用别名,需要重新实现 marshaller

func (*SchemaRef) MarshalYAML

func (s *SchemaRef) MarshalYAML() (interface{}, error)

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 Schemas

type Schemas map[string]*SchemaRef

type SecurityRequirement

type SecurityRequirement map[string][]string

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) Export

func (e *SecurityScheme) Export(gr int) map[string]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

type SerializationMethod struct {
	Style   string
	Explode bool
}

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) Export

func (e *Server) Export(gr int) map[string]interface{}

func (*Server) MarshalJSON

func (server *Server) MarshalJSON() ([]byte, error)

func (*Server) MarshalYAML

func (server *Server) MarshalYAML() (interface{}, error)

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) Export

func (e *ServerVariable) Export(gr int) map[string]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 Servers

type Servers []*Server

Servers is specified by OpenAPI/Swagger standard version 3.

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 NewT

func NewT() *T

func (*T) AddExtensions

func (e *T) AddExtensions(key string, value interface{})

func (*T) AddOperation

func (doc *T) AddOperation(path string, method string, operation *Operation)

func (*T) AddServer

func (doc *T) AddServer(server *Server)

func (*T) AddServers

func (doc *T) AddServers(servers ...*Server)

func (*T) Export

func (e *T) Export(gr int) map[string]interface{}

func (*T) MarshalJSON

func (doc *T) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of T.

func (*T) MarshalYAML

func (doc *T) MarshalYAML() (interface{}, error)

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) Export

func (e *Tag) Export(gr int) map[string]interface{}

func (*Tag) MarshalJSON

func (t *Tag) MarshalJSON() ([]byte, error)

func (*Tag) MarshalYAML

func (t *Tag) MarshalYAML() (interface{}, error)

func (*Tag) RemoveExtensions

func (e *Tag) RemoveExtensions(key string)

type Tags

type Tags []*Tag

Tags is specified by OpenAPI/Swagger 3.0 standard.

func (Tags) Get

func (tags Tags) Get(name string) *Tag

type Types

type Types []string

func (*Types) Includes

func (pTypes *Types) Includes(typ string) bool

func (*Types) Is

func (pTypes *Types) Is(typ string) bool

func (*Types) MarshalJSON

func (pTypes *Types) MarshalJSON() ([]byte, error)

func (*Types) MarshalYAML

func (pTypes *Types) MarshalYAML() (interface{}, error)

func (*Types) Permits

func (pTypes *Types) Permits(typ string) bool

func (*Types) Slice

func (pTypes *Types) Slice() []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) Export

func (e *XML) Export(gr int) map[string]interface{}

func (*XML) MarshalJSON

func (xml *XML) MarshalJSON() ([]byte, error)

func (*XML) MarshalYAML

func (xml *XML) MarshalYAML() (interface{}, error)

func (*XML) RemoveExtensions

func (e *XML) RemoveExtensions(key string)

Jump to

Keyboard shortcuts

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