Movatterモバイル変換


[0]ホーム

URL:


openapi

packagemodule
v1.2.0Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2025 License:MITImports:12Imported by:1

Details

Repository

github.com/sv-tools/openapi

Links

README

OpenAPI v3.1 Specification

Code AnalysisGo ReferencecodecovGitHub tag (latest SemVer)

The implementation of OpenAPI v3.1 Specification for Go using generics.

go get github.com/sv-tools/openapi

Supported Go versions

  • v1.25
  • v1.24
  • v1.23
  • v1.22

Versions

  • v0 -Deprecated. The initial version with the full implementation of the v3.1 Specification using generics. See thev0 branch.
  • v1 - The current version with the in-place validation of the specification.
    • The minimum version of Go isv1.22.
    • Everything has been moved to the root folder. So, the import path isgithub.com/sv-tools/openapi.
    • AddedValidator struct for validation of the specification and the data.
      • Validator.ValidateSpec() method validates the specification.
      • Validator.ValidateData() method validates the data.
      • Validator.ValidateDataAsJSON() method validates the data by converting it intomap[string]any type first usingjson.Marshal andjson.Unmarshal.WARNING: the function is slow due to double conversion.
    • AddedParseObject function to createSchemaBuilder by parsing an object.The function supportsjson,yaml andopenapi field tags for the structs.
    • Use OpenAPIv3.1.1 by default.

Features

  • The official v3.0 and v3.1examples are tested.In most cases, the v3.0 specification can be converted to v3.1 by changing only the version parameter.

    @@ -1,4 +1,4 @@-openapi: "3.0.0"+openapi: "3.1.0"

NOTE: The descriptions of most structures and their fields are taken from the official documentations.

Links

License

MIT licensed. See the bundledLICENSE file for more details.

Documentation

Index

Constants

View Source
const (// InPath used together with Path Templating, where the parameter value is actually part of the operation’s URL.// This does not include the host or base path of the API.// For example, in /items/{itemId}, the path parameter is itemId.////https://spec.openapis.org/oas/v3.1.1#parameter-locationsInPath = "path"// InQuery used for parameters that are appended to the URL.// For example, in /items?id=###, the query parameter is id.////https://spec.openapis.org/oas/v3.1.1#parameter-locationsInQuery = "query"// InHeader used as custom headers that are expected as part of the request.// Note that [RFC7230] states header names are case insensitive.////https://spec.openapis.org/oas/v3.1.1#parameter-locationsInHeader = "header"// InCookie used to pass a specific cookie value to the API.////https://spec.openapis.org/oas/v3.1.1#parameter-locationsInCookie = "cookie"// StyleMatrix is the parameters defined by [RFC6570](https://www.rfc-editor.org/rfc/rfc6570#section-3.2.7)//// Supported types://   - primitive//   - array//   - object//// Can be used with `in: path` location.StyleMatrix = "matrix"// StyleLabel is the parameters defined by [RFC6570](https://www.rfc-editor.org/rfc/rfc6570#section-3.2.5)//// Supported types://   - primitive//   - array//   - object//// Can be used with `in: path` location.StyleLabel = "label"// StyleForm is the parameters defined by [RFC6570](https://www.rfc-editor.org/rfc/rfc6570#section-3.2.8)//// Supported types://   - primitive//   - array//   - object//// Can be used with `in: query` and `in: cookie` locations.StyleForm = "form"// StyleSimple is the parameters defined by [RFC6570](https://www.rfc-editor.org/rfc/rfc6570#section-3.2.2)// This option replaces collectionFormat with a csv value from OpenAPI 2.0.//// Supported types://   - array//// Can be used with `in: path` and `in: header` locations.StyleSimple = "simple"// StyleSpaceDelimited is space separated array or object values.// This option replaces collectionFormat with a ssv value from OpenAPI 2.0.//// Supported types://   - array//   - object//// Can be used with `in: query` location.StyleSpaceDelimited = "spaceDelimited"// StylePipeDelimited is pipe separated array or object values.// This option replaces collectionFormat with a pipes value from OpenAPI 2.0.//// Supported types://   - array//   - object//// Can be used with `in: query` location.StylePipeDelimited = "pipeDelimited"// StyleDeepObject provides a simple way of rendering nested objects using form parameters.//// Supported types://   - object//// Can be used with `in: query` location.StyleDeepObject = "deepObject"ReservedCharacters = ":/?#[]@!$&'()*+,;=")
View Source
const (TypeApiKey        = "apiKey"TypeHTTP          = "http"TypeMutualTLS     = "mutualTLS"TypeOAuth2        = "oauth2"TypeOpenIDConnect = "openIdConnect")
View Source
const (Int32Format    = "int32"Int64Format    = "int64"FloatFormat    = "float"DoubleFormat   = "double"PasswordFormat = "password"// DateTimeFormat is date and time together, for example, 2018-11-13T20:20:39+00:00.DateTimeFormat = "date-time"// TimeFormat is time, for example, 20:20:39+00:00TimeFormat = "time"// DateFormat is date, for example, 2018-11-13.DateFormat = "date"// DurationFormat is a duration as defined by the ISO 8601 ABNF for “duration”.// For example, P3D expresses a duration of 3 days.////https://datatracker.ietf.org/doc/html/rfc3339#appendix-ADurationFormat = "duration"// EmailFormat is internet email address, seeRFC 5321, section 4.1.2.////https://tools.ietf.org/html/rfc5321#section-4.1.2EmailFormat = "email"// IDNEmailFormat is the internationalized form of an Internet email address, seeRFC 6531.////https://tools.ietf.org/html/rfc6531IDNEmailFormat = "idn-email"// HostnameFormat is internet host name, seeRFC 1123, section 2.1.////https://datatracker.ietf.org/doc/html/rfc1123#section-2.1HostnameFormat = "hostname"// IDNHostnameFormat is an internationalized Internet host name, see RFC5890, section 2.3.2.3.////https://tools.ietf.org/html/rfc6531IDNHostnameFormat = "idn-hostname"// IPv4Format is IPv4 address, according to dotted-quad ABNF syntax as defined inRFC 2673, section 3.2.////https://tools.ietf.org/html/rfc2673#section-3.2IPv4Format = "ipv4"// IPv6Format is IPv6 address, as defined inRFC 2373, section 2.2.////https://tools.ietf.org/html/rfc2373#section-2.2IPv6Format = "ipv6"// UUIDFormat is a Universally Unique Identifier as defined byRFC 4122.// Example: 3e4666bf-d5e5-4aa7-b8ce-cefe41c7568a////RFC 4122UUIDFormat = "uuid"// URIFormat is a universal resource identifier (URI), according to RFC3986.////https://tools.ietf.org/html/rfc3986URIFormat = "uri"// URIReferenceFormat is a URI Reference (either a URI or a relative-reference), according to RFC3986, section 4.1.////https://tools.ietf.org/html/rfc3986#section-4.1URIReferenceFormat = "uri-reference"// IRIFormat is the internationalized equivalent of a “uri”, according to RFC3987.////https://tools.ietf.org/html/rfc3987IRIFormat = "iri"// IRIReferenceFormat is The internationalized equivalent of a “uri-reference”, according to RFC3987////https://tools.ietf.org/html/rfc3987IRIReferenceFormat = "iri-reference"// URITemplateFormat is a URI Template (of any level) according to RFC6570.// If you don’t already know what a URI Template is, you probably don’t need this value.////https://tools.ietf.org/html/rfc6570URITemplateFormat = "uri-template"// JsonPointerFormat is a JSON Pointer, according to RFC6901.// There is more discussion on the use of JSON Pointer within JSON Schema in Structuring a complex schema.// Note that this should be used only when the entire string contains only JSON Pointer content, e.g. /foo/bar.// JSON Pointer URI fragments, e.g. #/foo/bar/ should use "uri-reference".////https://tools.ietf.org/html/rfc6901JsonPointerFormat = "json-pointer"// RelativeJsonPointerFormat is a relative JSON pointer.////https://tools.ietf.org/html/draft-handrews-relative-json-pointer-01RelativeJsonPointerFormat = "relative-json-pointer"// RegexFormat is a regular expression, which should be valid according to the ECMA 262 dialect.////https://www.ecma-international.org/publications/files/ECMA-ST/Ecma-262.pdfRegexFormat = "regex")
View Source
const (// StringType is used for strings of text. It may contain Unicode characters.////https://json-schema.org/understanding-json-schema/reference/string.html#stringStringType = "string"// NumberType is used for any numeric type, either integers or floating point numbers.////https://json-schema.org/understanding-json-schema/reference/numeric.html#numberNumberType = "number"// IntegerType is used for integral numbers.// JSON does not have distinct types for integers and floating-point values.// Therefore, the presence or absence of a decimal point is not enough to distinguish between integers and non-integers.// For example, 1 and 1.0 are two ways to represent the same value in JSON.// JSON Schema considers that value an integer no matter which representation was used.////https://json-schema.org/understanding-json-schema/reference/numeric.html#integerIntegerType = "integer"// ObjectType is the mapping type in JSON.// They map “keys” to “values”.// In JSON, the “keys” must always be strings.// Each of these pairs is conventionally referred to as a “property”.////https://json-schema.org/understanding-json-schema/reference/object.html#objectObjectType = "object"// ArrayType is used for ordered elements.// In JSON, each element in an array may be of a different type.////https://json-schema.org/understanding-json-schema/reference/array.html#arrayArrayType = "array"// BooleanType matches only two special values: true and false.// Note that values that evaluate to true or false, such as 1 and 0, are not accepted by the schema.////https://json-schema.org/understanding-json-schema/reference/boolean.html#booleanBooleanType = "boolean"// NullType has only one acceptable value: null.////https://json-schema.org/understanding-json-schema/reference/null.html#nullNullType = "null"SevenBitEncoding        = "7bit"EightBitEncoding        = "8bit"BinaryEncoding          = "binary"QuotedPrintableEncoding = "quoted-printable"Base16Encoding          = "base16"Base32Encoding          = "base32"Base64Encoding          = "base64")
View Source
const (// Draft202012 is the default value for the schema field.Draft202012 = "https://json-schema.org/draft/2020-12/schema")
View Source
const ExtensionPrefix = "x-"

Variables

View Source
var (ErrRequired          =errors.New("required")ErrMutuallyExclusive =errors.New("mutually exclusive")ErrUnused            =errors.New("unused"))
View Source
var ErrExtensionNameMustStartWithPrefix =errors.New("extension name must start with `" +ExtensionPrefix + "`")
View Source
var PathNamePattern =regexp.MustCompile(`[^/#?]+$`)
View Source
var ResponseCodePattern =regexp.MustCompile(`^[1-5](?:\d{2}|XX)$`)

Functions

funcConvertToJSON

func ConvertToJSON(valueany) (any,error)

funcGetType

func GetType(vany) (string,error)

GetType returns the JSON Schema type of the given value.

funcNewSpecNotFoundError

func NewSpecNotFoundError(messagestring, visitedObjects visitedObjects)error

funcNewUnsupportedSpecTypeError

func NewUnsupportedSpecTypeError(specany)error

funcNewUnsupportedTypeError

func NewUnsupportedTypeError(vreflect.Kind)error

funcNewUnsupportedVersionError

func NewUnsupportedVersionError(versionstring)error

Types

typeBoolOrSchema

type BoolOrSchema struct {Schema  *RefOrSpec[Schema]Allowedbool}

BoolOrSchema handles Boolean or Schema type.

It MUST be used as a pointer,otherwise the `false` can be omitted by json or yaml encoders in case of `omitempty` tag is set.

funcNewBoolOrSchema

func NewBoolOrSchema(vany) *BoolOrSchema

func (*BoolOrSchema)MarshalJSON

func (o *BoolOrSchema) MarshalJSON() ([]byte,error)

MarshalJSON implements json.Marshaler interface.

func (*BoolOrSchema)MarshalYAML

func (o *BoolOrSchema) MarshalYAML() (any,error)

MarshalYAML implements yaml.Marshaler interface.

func (*BoolOrSchema)UnmarshalJSON

func (o *BoolOrSchema) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*BoolOrSchema)UnmarshalYAML

func (o *BoolOrSchema) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeCallback

type Callback struct {Paths map[string]*RefOrSpec[Extendable[PathItem]]}

Callback is a map of possible out-of band callbacks related to the parent operation.Each value in the map is a Path Item Object that describes a set of requests that may be initiated bythe API provider and the expected responses.The key value used to identify the path item object is an expression, evaluated at runtime,that identifies a URL to use for the callback operation.To describe incoming requests from the API provider independent from another API call, use the webhooks field.

https://spec.openapis.org/oas/v3.1.1#callback-object

Example:

myCallback:  '{$request.query.queryUrl}':    post:      requestBody:        description: Callback payload        content:          'application/json':            schema:              $ref: '#/components/schemas/SomePayload'      responses:        '200':          description: callback successfully processed

func (*Callback)Add

func (o *Callback) Add(expressionstring, item *RefOrSpec[Extendable[PathItem]]) *Callback

func (*Callback)MarshalJSON

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

MarshalJSON implements json.Marshaler interface.

func (*Callback)MarshalYAML

func (o *Callback) MarshalYAML() (any,error)

MarshalYAML implements yaml.Marshaler interface.

func (*Callback)UnmarshalJSON

func (o *Callback) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*Callback)UnmarshalYAML

func (o *Callback) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeCallbackBuilder

type CallbackBuilder struct {// contains filtered or unexported fields}

funcNewCallbackBuilder

func NewCallbackBuilder() *CallbackBuilder

func (*CallbackBuilder)AddExt

func (b *CallbackBuilder) AddExt(namestring, valueany) *CallbackBuilder

func (*CallbackBuilder)AddPathItem

func (b *CallbackBuilder) AddPathItem(expressionstring, item *RefOrSpec[Extendable[PathItem]]) *CallbackBuilder

func (*CallbackBuilder)Build

func (*CallbackBuilder)Extensions

func (b *CallbackBuilder) Extensions(v map[string]any) *CallbackBuilder

func (*CallbackBuilder)Paths

typeComponents

type Components struct {// An object to hold reusable Schema Objects.Schemas map[string]*RefOrSpec[Schema] `json:"schemas,omitempty" yaml:"schemas,omitempty"`// An object to hold reusable Response Objects.Responses map[string]*RefOrSpec[Extendable[Response]] `json:"responses,omitempty" yaml:"responses,omitempty"`// An object to hold reusable Parameter Objects.Parameters map[string]*RefOrSpec[Extendable[Parameter]] `json:"parameters,omitempty" yaml:"parameters,omitempty"`// An object to hold reusable Example Objects.Examples map[string]*RefOrSpec[Extendable[Example]] `json:"examples,omitempty" yaml:"examples,omitempty"`// An object to hold reusable Request Body Objects.RequestBodies map[string]*RefOrSpec[Extendable[RequestBody]] `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"`// An object to hold reusable Header Objects.Headers map[string]*RefOrSpec[Extendable[Header]] `json:"headers,omitempty" yaml:"headers,omitempty"`// An object to hold reusable Security Scheme Objects.SecuritySchemes map[string]*RefOrSpec[Extendable[SecurityScheme]] `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`// An object to hold reusable Link Objects.Links map[string]*RefOrSpec[Extendable[Link]] `json:"links,omitempty" yaml:"links,omitempty"`// An object to hold reusable Callback Objects.Callbacks map[string]*RefOrSpec[Extendable[Callback]] `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`// An object to hold reusable Path Item Object.Paths map[string]*RefOrSpec[Extendable[PathItem]] `json:"paths,omitempty" yaml:"paths,omitempty"`}

Components holds a set of reusable objects for different aspects of the OAS.All objects defined within the components object will have no effect on the API unless they are explicitly referencedfrom properties outside the components object.

https://spec.openapis.org/oas/v3.1.1#components-object

Example:

components:  schemas:    GeneralError:      type: object      properties:        code:          type: integer          format: int32        message:          type: string    Category:      type: object      properties:        id:          type: integer          format: int64        name:          type: string    Tag:      type: object      properties:        id:          type: integer          format: int64        name:          type: string  parameters:    skipParam:      name: skip      in: query      description: number of items to skip      required: true      schema:        type: integer        format: int32    limitParam:      name: limit      in: query      description: max records to return      required: true      schema:        type: integer        format: int32  responses:    NotFound:      description: Entity not found.    IllegalInput:      description: Illegal input for operation.    GeneralError:      description: General Error      content:        application/json:          schema:            $ref: '#/components/schemas/GeneralError'  securitySchemes:    api_key:      type: apiKey      name: api_key      in: header    petstore_auth:      type: oauth2      flows:        implicit:          authorizationUrl: https://example.org/api/oauth/dialog          scopes:            write:pets: modify pets in your account            read:pets: read your pets

func (*Components)Add

func (o *Components) Add(namestring, vany) *Components

Add adds the given object to the appropriate list based on a type and returns the current object (self|this).

typeContact

type Contact struct {// The identifying name of the contact person/organization.Namestring `json:"name,omitempty" yaml:"name,omitempty"`// The URL pointing to the contact information.// This MUST be in the form of a URL.URLstring `json:"url,omitempty" yaml:"url,omitempty"`// The email address of the contact person/organization.// This MUST be in the form of an email address.Emailstring `json:"email,omitempty" yaml:"email,omitempty"`}

Contact information for the exposed API.

https://spec.openapis.org/oas/v3.1.1#contact-object

Example:

name: API Supporturl: https://www.example.com/supportemail: support@example.com

typeContactBuilder

type ContactBuilder struct {// contains filtered or unexported fields}

funcNewContactBuilder

func NewContactBuilder() *ContactBuilder

func (*ContactBuilder)AddExt

func (b *ContactBuilder) AddExt(namestring, valueany) *ContactBuilder

func (*ContactBuilder)Build

func (b *ContactBuilder) Build() *Extendable[Contact]

func (*ContactBuilder)Email

func (*ContactBuilder)Extensions

func (b *ContactBuilder) Extensions(v map[string]any) *ContactBuilder

func (*ContactBuilder)Name

func (*ContactBuilder)URL

typeDiscriminator

type Discriminator struct {// An object to hold mappings between payload values and schema names or references.Mapping map[string]string `json:"mapping,omitempty" yaml:"mapping,omitempty"`// REQUIRED.// The name of the property in the payload that will hold the discriminator value.PropertyNamestring `json:"propertyName" yaml:"propertyName"`}

Discriminator is used when request bodies or response payloads may be one of a number of different schemas,a discriminator object can be used to aid in serialization, deserialization, and validation.The discriminator is a specific object in a schema which is used to inform the consumer of the document ofan alternative schema based on the value associated with it.When using the discriminator, inline schemas will not be considered.

https://spec.openapis.org/oas/v3.1.1#discriminator-object

Example:

MyResponseType:  oneOf:  - $ref: '#/components/schemas/Cat'  - $ref: '#/components/schemas/Dog'  - $ref: '#/components/schemas/Lizard'  - $ref: 'https://gigantic-server.com/schemas/Monster/schema.json'  discriminator:    propertyName: petType    mapping:      dog: '#/components/schemas/Dog'      monster: 'https://gigantic-server.com/schemas/Monster/schema.json'

typeDiscriminatorBuilder

type DiscriminatorBuilder struct {// contains filtered or unexported fields}

funcNewDiscriminatorBuilder

func NewDiscriminatorBuilder() *DiscriminatorBuilder

func (*DiscriminatorBuilder)AddMapping

func (b *DiscriminatorBuilder) AddMapping(name, valuestring) *DiscriminatorBuilder

func (*DiscriminatorBuilder)Build

func (*DiscriminatorBuilder)Mapping

func (*DiscriminatorBuilder)PropertyName

typeEncoding

type Encoding struct {// The Content-Type for encoding a specific property.// Default value depends on the property type://   for object - application/json;//   for array – the default is defined based on the inner type;//   for all other cases the default is application/octet-stream.// The value can be a specific media type (e.g. application/json), a wildcard media type (e.g. image/*),// or a comma-separated list of the two types.ContentTypestring `json:"contentType,omitempty" yaml:"contentType,omitempty"`// A map allowing additional information to be provided as headers, for example Content-Disposition.// Content-Type is described separately and SHALL be ignored in this section.// This property SHALL be ignored if the request body media type is not a multipart.Headers map[string]*RefOrSpec[Extendable[Header]] `json:"headers,omitempty" yaml:"headers,omitempty"`// Describes how a specific property value will be serialized depending on its type.// See Parameter Object for details on the style property.// The behavior follows the same values as query parameters, including default values.// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.// If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored.Stylestring `json:"style,omitempty" yaml:"style,omitempty"`// When this is true, property values of type array or object generate separate parameters for each value of the array,// or key-value-pair of the map.// For other types of properties this property has no effect.// When style is form, the default value is true.// For all other styles, the default value is false.// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.// If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored.Explodebool `json:"explode,omitempty" yaml:"explode,omitempty"`// Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986]//   :/?#[]@!$&'()*+,;=// to be included without percent-encoding.// The default value is false.// This property SHALL be ignored if the request body media type is not application/x-www-form-urlencoded or multipart/form-data.// If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be ignored.AllowReservedbool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`}

Encoding is definition that applied to a single schema property.

https://spec.openapis.org/oas/v3.1.1#encoding-object

Example:

requestBody:  content:    multipart/form-data:      schema:        type: object        properties:          id:            # default is text/plain            type: string            format: uuid          address:            # default is application/json            type: object            properties: {}          historyMetadata:            # need to declare XML format!            description: metadata in XML format            type: object            properties: {}          profileImage: {}      encoding:        historyMetadata:          # require XML Content-Type in utf-8 encoding          contentType: application/xml; charset=utf-8        profileImage:          # only accept png/jpeg          contentType: image/png, image/jpeg          headers:            X-Rate-Limit-Limit:              description: The number of allowed requests in the current period              schema:                type: integer

typeEncodingBuilder

type EncodingBuilder struct {// contains filtered or unexported fields}

funcNewEncodingBuilder

func NewEncodingBuilder() *EncodingBuilder

func (*EncodingBuilder)AddExt

func (b *EncodingBuilder) AddExt(namestring, valueany) *EncodingBuilder

func (*EncodingBuilder)AllowReserved

func (b *EncodingBuilder) AllowReserved(vbool) *EncodingBuilder

func (*EncodingBuilder)Build

func (b *EncodingBuilder) Build() *Extendable[Encoding]

func (*EncodingBuilder)ContentType

func (b *EncodingBuilder) ContentType(vstring) *EncodingBuilder

func (*EncodingBuilder)Explode

func (b *EncodingBuilder) Explode(vbool) *EncodingBuilder

func (*EncodingBuilder)Extensions

func (b *EncodingBuilder) Extensions(v map[string]any) *EncodingBuilder

func (*EncodingBuilder)Header

func (*EncodingBuilder)Headers

func (*EncodingBuilder)Style

typeExample

type Example struct {// Short description for the example.Summarystring `json:"summary,omitempty" yaml:"summary,omitempty"`// Long description for the example.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// Embedded literal example.// The value field and externalValue field are mutually exclusive.// To represent examples of media types that cannot naturally represented in JSON or YAML,// use a string value to contain the example, escaping where necessary.Valueany `json:"value,omitempty" yaml:"value,omitempty"`// A URI that points to the literal example.// This provides the capability to reference examples that cannot easily be included in JSON or YAML documents.// The value field and externalValue field are mutually exclusive.// See the rules for resolving Relative References.ExternalValuestring `json:"externalValue,omitempty" yaml:"externalValue,omitempty"`}

Example is expected to be compatible with the type schema of its associated value.Tooling implementations MAY choose to validate compatibility automatically, and reject the example value(s) if incompatible.

https://spec.openapis.org/oas/v3.1.1#example-object

Example:

requestBody:  content:    'application/json':      schema:        $ref: '#/components/schemas/Address'      examples:        foo:          summary: A foo example          value: {"foo": "bar"}        bar:          summary: A bar example          value: {"bar": "baz"}    'application/xml':      examples:        xmlExample:          summary: This is an example in XML          externalValue: 'https://example.org/examples/address-example.xml'    'text/plain':      examples:        textExample:          summary: This is a text example          externalValue: 'https://foo.bar/examples/address-example.txt'

typeExampleBuilder

type ExampleBuilder struct {// contains filtered or unexported fields}

funcNewExampleBuilder

func NewExampleBuilder() *ExampleBuilder

func (*ExampleBuilder)AddExt

func (b *ExampleBuilder) AddExt(namestring, valueany) *ExampleBuilder

func (*ExampleBuilder)Build

func (*ExampleBuilder)Description

func (b *ExampleBuilder) Description(vstring) *ExampleBuilder

func (*ExampleBuilder)Extensions

func (b *ExampleBuilder) Extensions(v map[string]any) *ExampleBuilder

func (*ExampleBuilder)ExternalValue

func (b *ExampleBuilder) ExternalValue(vstring) *ExampleBuilder

func (*ExampleBuilder)Summary

func (b *ExampleBuilder) Summary(vstring) *ExampleBuilder

func (*ExampleBuilder)Value

func (b *ExampleBuilder) Value(vany) *ExampleBuilder

typeExtendable

type Extendable[Tany] struct {Spec       *T             `json:"-" yaml:"-"`Extensions map[string]any `json:"-" yaml:"-"`}

Extendable allows extensions to the OpenAPI Schema.The field name MUST begin with `x-`, for example, `x-internal-id`.Field names beginning `x-oai-` and `x-oas-` are reserved for uses defined by the OpenAPI Initiative.The value can be null, a primitive, an array or an object.

https://spec.openapis.org/oas/v3.1.1#specification-extensions

Example:

  openapi: 3.1.1  info:    title: Sample Pet Store App    summary: A pet store manager.    description: This is a sample server for a pet store.    version: 1.0.1    x-build-data: 2006-01-02T15:04:05Z07:00x-build-commit-id: dac33af14d0d4a5f1c226141042ca7cefc6aeb75

funcNewComponents

func NewComponents() *Extendable[Components]

funcNewExtendable

func NewExtendable[Tany](spec *T) *Extendable[T]

NewExtendable creates new Extendable object for given spec

funcNewPaths

func NewPaths() *Extendable[Paths]

func (*Extendable[T])AddExt

func (o *Extendable[T]) AddExt(namestring, valueany) *Extendable[T]

AddExt sets the extension and returns the current object.The `x-` prefix will be added automatically to given name.

func (*Extendable[T])GetExt

func (o *Extendable[T]) GetExt(namestring)any

GetExt returns the extension value by name.The `x-` prefix will be added automatically to given name.

func (*Extendable[T])MarshalJSON

func (o *Extendable[T]) MarshalJSON() ([]byte,error)

MarshalJSON implements json.Marshaler interface.

func (*Extendable[T])MarshalYAML

func (o *Extendable[T]) MarshalYAML() (any,error)

MarshalYAML implements yaml.Marshaler interface.

func (*Extendable[T])UnmarshalJSON

func (o *Extendable[T]) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*Extendable[T])UnmarshalYAML

func (o *Extendable[T]) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeExternalDocs

type ExternalDocs struct {// A description of the target documentation.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description" yaml:"description"`// REQUIRED.// The URL for the target documentation.// This MUST be in the form of a URL.URLstring `json:"url" yaml:"url"`}

ExternalDocs allows referencing an external resource for extended documentation.

https://spec.openapis.org/oas/v3.1.1#external-documentation-object

Example:

description: Find more info hereurl: https://example.com

typeExternalDocsBuilder

type ExternalDocsBuilder struct {// contains filtered or unexported fields}

funcNewExternalDocsBuilder

func NewExternalDocsBuilder() *ExternalDocsBuilder

func (*ExternalDocsBuilder)AddExt

func (b *ExternalDocsBuilder) AddExt(namestring, valueany) *ExternalDocsBuilder

func (*ExternalDocsBuilder)Build

func (*ExternalDocsBuilder)Description

func (*ExternalDocsBuilder)Extensions

func (b *ExternalDocsBuilder) Extensions(v map[string]any) *ExternalDocsBuilder

func (*ExternalDocsBuilder)URL

typeHeader

type Header struct {// The schema defining the type used for the header.Schema *RefOrSpec[Schema] `json:"schema,omitempty" yaml:"schema,omitempty"`// A map containing the representations for the header.// The key is the media type and the value describes it.// The map MUST only contain one entry.Content map[string]*Extendable[MediaType] `json:"content,omitempty" yaml:"content,omitempty"`// A brief description of the header.// This could contain examples of use.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// Describes how the header value will be serialized.Stylestring `json:"style,omitempty" yaml:"style,omitempty"`// When this is true, header values of type array or object generate separate headers// for each value of the array or key-value pair of the map.// For other types of parameters this property has no effect.// When style is form, the default value is true.// For all other styles, the default value is false.Explodebool `json:"explode,omitempty" yaml:"explode,omitempty"`// Determines whether this header is mandatory.// The property MAY be included and its default value is false.Requiredbool `json:"required,omitempty" yaml:"required,omitempty"`// Specifies that a header is deprecated and SHOULD be transitioned out of usage.// Default value is false.Deprecatedbool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`}

Header Object follows the structure of the Parameter Object with the some changes.

https://spec.openapis.org/oas/v3.1.1#header-object

Example:

description: The number of allowed requests in the current periodschema:  type: integer

All fields are copied from Parameter Object as is, except name and in fields.

typeHeaderBuilder

type HeaderBuilder struct {// contains filtered or unexported fields}

funcNewHeaderBuilder

func NewHeaderBuilder() *HeaderBuilder

func (*HeaderBuilder)AddContent

func (b *HeaderBuilder) AddContent(namestring, value *Extendable[MediaType]) *HeaderBuilder

func (*HeaderBuilder)AddExt

func (b *HeaderBuilder) AddExt(namestring, valueany) *HeaderBuilder

func (*HeaderBuilder)Build

func (*HeaderBuilder)Content

func (*HeaderBuilder)Deprecated

func (b *HeaderBuilder) Deprecated(vbool) *HeaderBuilder

func (*HeaderBuilder)Description

func (b *HeaderBuilder) Description(vstring) *HeaderBuilder

func (*HeaderBuilder)Explode

func (b *HeaderBuilder) Explode(vbool) *HeaderBuilder

func (*HeaderBuilder)Extensions

func (b *HeaderBuilder) Extensions(v map[string]any) *HeaderBuilder

func (*HeaderBuilder)Required

func (b *HeaderBuilder) Required(vbool) *HeaderBuilder

func (*HeaderBuilder)Schema

func (*HeaderBuilder)Style

typeInfo

type Info struct {// REQUIRED.// The title of the API.Titlestring `json:"title" yaml:"title"`// A short summary of the API.Summarystring `json:"summary,omitempty" yaml:"summary,omitempty"`// A description of the API.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// A URL to the Terms of Service for the API.// This MUST be in the form of a URL.TermsOfServicestring `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"`// The contact information for the exposed API.Contact *Extendable[Contact] `json:"contact,omitempty" yaml:"contact,omitempty"`// The license information for the exposed API.License *Extendable[License] `json:"license,omitempty" yaml:"license,omitempty"`// REQUIRED.// The version of the OpenAPI document (which is distinct from the OpenAPI Specification version or the API implementation version).Versionstring `json:"version" yaml:"version"`}

Info provides metadata about the API.The metadata MAY be used by the clients if needed, and MAY be presented in editing or documentation generation tools for convenience.

https://spec.openapis.org/oas/v3.1.1#info-object

Example:

title: Sample Pet Store Appsummary: A pet store manager.description: This is a sample server for a pet store.termsOfService: https://example.com/terms/contact:  name: API Support  url: https://www.example.com/support  email: support@example.comlicense:  name: Apache 2.0  url: https://www.apache.org/licenses/LICENSE-2.0.htmlversion: 1.0.1

typeInfoBuilder

type InfoBuilder struct {// contains filtered or unexported fields}

funcNewInfoBuilder

func NewInfoBuilder() *InfoBuilder

func (*InfoBuilder)AddExt

func (b *InfoBuilder) AddExt(namestring, valueany) *InfoBuilder

func (*InfoBuilder)Build

func (b *InfoBuilder) Build() *Extendable[Info]

func (*InfoBuilder)Contact

func (b *InfoBuilder) Contact(v *Extendable[Contact]) *InfoBuilder

func (*InfoBuilder)Description

func (b *InfoBuilder) Description(vstring) *InfoBuilder

func (*InfoBuilder)Extensions

func (b *InfoBuilder) Extensions(v map[string]any) *InfoBuilder

func (*InfoBuilder)License

func (b *InfoBuilder) License(v *Extendable[License]) *InfoBuilder

func (*InfoBuilder)Summary

func (b *InfoBuilder) Summary(vstring) *InfoBuilder

func (*InfoBuilder)TermsOfService

func (b *InfoBuilder) TermsOfService(vstring) *InfoBuilder

func (*InfoBuilder)Title

func (b *InfoBuilder) Title(vstring) *InfoBuilder

func (*InfoBuilder)Version

func (b *InfoBuilder) Version(vstring) *InfoBuilder

typeLicense

type License struct {// REQUIRED.// The license name used for the API.Namestring `json:"name" yaml:"name"`// An SPDX license expression for the API.// The identifier field is mutually exclusive of the url field.Identifierstring `json:"identifier,omitempty" yaml:"identifier,omitempty"`// A URL to the license used for the API.// This MUST be in the form of a URL.// The url field is mutually exclusive of the identifier field.URLstring `json:"url,omitempty" yaml:"url,omitempty"`}

License information for the exposed API.

https://spec.openapis.org/oas/v3.1.1#license-object

Example:

name: Apache 2.0identifier: Apache-2.0

typeLicenseBuilder

type LicenseBuilder struct {// contains filtered or unexported fields}

funcNewLicenseBuilder

func NewLicenseBuilder() *LicenseBuilder

func (*LicenseBuilder)AddExt

func (b *LicenseBuilder) AddExt(namestring, valueany) *LicenseBuilder

func (*LicenseBuilder)Build

func (b *LicenseBuilder) Build() *Extendable[License]

func (*LicenseBuilder)Extensions

func (b *LicenseBuilder) Extensions(v map[string]any) *LicenseBuilder

func (*LicenseBuilder)Identifier

func (b *LicenseBuilder) Identifier(vstring) *LicenseBuilder

func (*LicenseBuilder)Name

func (*LicenseBuilder)URL

typeLink

type Link struct {// A literal value or {expression} to use as a request body when calling the target operation.RequestBodyany `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`// A map representing parameters to pass to an operation as specified with operationId or identified via operationRef.// The key is the parameter name to be used, whereas the value can be a constant or an expression to be evaluated and// passed to the linked operation.// The parameter name can be qualified using the parameter location [{in}.]{name} for operations that use// the same parameter name in different locations (e.g. path.id).Parameters map[string]any `json:"parameters,omitempty" yaml:"parameters,omitempty"`// A server object to be used by the target operation.Server *Extendable[Server] `json:"server,omitempty" yaml:"server,omitempty"`// A relative or absolute URI reference to an OAS operation.// This field is mutually exclusive of the operationId field, and MUST point to an Operation Object.// Relative operationRef values MAY be used to locate an existing Operation Object in the OpenAPI definition.// See the rules for resolving Relative References.OperationRefstring `json:"operationRef,omitempty" yaml:"operationRef,omitempty"`// The name of an existing, resolvable OAS operation, as defined with a unique operationId.// This field is mutually exclusive of the operationRef field.OperationIDstring `json:"operationId,omitempty" yaml:"operationId,omitempty"`// A description of the link.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`}

Link represents a possible design-time link for a response.The presence of a link does not guarantee the caller’s ability to successfully invoke it,rather it provides a known relationship and traversal mechanism between responses and other operations.Unlike dynamic links (i.e. links provided in the response payload),the OAS linking mechanism does not require link information in the runtime response.For computing links, and providing instructions to execute them,a runtime expression is used for accessing values in an operationand using them as parameters while invoking the linked operation.

https://spec.openapis.org/oas/v3.1.1#link-object

Example:

paths:  /users/{id}:    parameters:    - name: id      in: path      required: true      description: the user identifier, as userId      schema:        type: string    get:      responses:        '200':          description: the user being returned          content:            application/json:              schema:                type: object                properties:                  uuid: # the unique user id                    type: string                    format: uuid          links:            address:              # the target link operationId              operationId: getUserAddress              parameters:                # get the `id` field from the request path parameter named `id`                userId: $request.path.id  # the path item of the linked operation  /users/{userid}/address:    parameters:    - name: userid      in: path      required: true      description: the user identifier, as userId      schema:        type: string    # linked operation    get:      operationId: getUserAddress      responses:        '200':          description: the user's address

typeLinkBuilder

type LinkBuilder struct {// contains filtered or unexported fields}

funcNewLinkBuilder

func NewLinkBuilder() *LinkBuilder

func (*LinkBuilder)AddExt

func (b *LinkBuilder) AddExt(namestring, valueany) *LinkBuilder

func (*LinkBuilder)AddParameter

func (b *LinkBuilder) AddParameter(namestring, valueany) *LinkBuilder

func (*LinkBuilder)Build

func (b *LinkBuilder) Build() *RefOrSpec[Extendable[Link]]

func (*LinkBuilder)Description

func (b *LinkBuilder) Description(vstring) *LinkBuilder

func (*LinkBuilder)Extensions

func (b *LinkBuilder) Extensions(v map[string]any) *LinkBuilder

func (*LinkBuilder)OperationID

func (b *LinkBuilder) OperationID(vstring) *LinkBuilder

func (*LinkBuilder)OperationRef

func (b *LinkBuilder) OperationRef(vstring) *LinkBuilder

func (*LinkBuilder)Parameters

func (b *LinkBuilder) Parameters(v map[string]any) *LinkBuilder

func (*LinkBuilder)RequestBody

func (b *LinkBuilder) RequestBody(vany) *LinkBuilder

func (*LinkBuilder)Server

func (b *LinkBuilder) Server(v *Extendable[Server]) *LinkBuilder

typeMapKeyMustBeStringErroradded inv1.1.0

type MapKeyMustBeStringError struct {LocationstringKeyTypereflect.Kind}

MapKeyMustBeStringError is an error that is returned when the map key is not a string.

funcNewMapKeyMustBeStringErroradded inv1.1.0

func NewMapKeyMustBeStringError(locationstring, keyTypereflect.Kind) *MapKeyMustBeStringError

NewMapKeyMustBeStringError creates a new MapKeyMustBeStringError with the given location and key type.

func (*MapKeyMustBeStringError)Erroradded inv1.1.0

func (*MapKeyMustBeStringError)Isadded inv1.1.0

typeMediaType

type MediaType struct {// The schema defining the content of the request, response, or parameter.Schema *RefOrSpec[Schema] `json:"schema,omitempty" yaml:"schema,omitempty"`// Example of the media type. The example object SHOULD be in the correct format as specified by the media type.// The example field is mutually exclusive of the examples field.// Furthermore, if referencing a schema which contains an example, the example value SHALL override the example provided by the schema.Exampleany `json:"example,omitempty" yaml:"example,omitempty"`// Examples of the parameter’s potential value.// Each example SHOULD contain a value in the correct format as specified in the parameter encoding.// The examples field is mutually exclusive of the example field.// Furthermore, if referencing a schema that contains an example, the examples value SHALL override the example provided by the schema.Examples map[string]*RefOrSpec[Extendable[Example]] `json:"examples,omitempty" yaml:"examples,omitempty"`// A map between a property name and its encoding information.// The key, being the property name, MUST exist in the schema as a property.// The encoding object SHALL only apply to requestBody objects when the media type is multipart or application/x-www-form-urlencoded.Encoding map[string]*Extendable[Encoding] `json:"encoding,omitempty" yaml:"encoding,omitempty"`}

MediaType provides schema and examples for the media type identified by its key.

https://spec.openapis.org/oas/v3.1.1#media-type-object

Example:

application/json:  schema:    $ref: "#/components/schemas/Pet"  examples:    cat:      summary: An example of a cat      value:        name: Fluffy        petType: Cat        color: White        gender: male        breed: Persian    dog:      summary: An example of a dog with a cat's name      value:        name: Puma        petType: Dog        color: Black        gender: Female        breed: Mixed    frog:      $ref: "#/components/examples/frog-example"

typeMediaTypeBuilder

type MediaTypeBuilder struct {// contains filtered or unexported fields}

funcNewMediaTypeBuilder

func NewMediaTypeBuilder() *MediaTypeBuilder

func (*MediaTypeBuilder)AddEncoding

func (b *MediaTypeBuilder) AddEncoding(namestring, value *Extendable[Encoding]) *MediaTypeBuilder

func (*MediaTypeBuilder)AddExample

func (*MediaTypeBuilder)AddExt

func (b *MediaTypeBuilder) AddExt(namestring, valueany) *MediaTypeBuilder

func (*MediaTypeBuilder)Build

func (*MediaTypeBuilder)Encoding

func (*MediaTypeBuilder)Example

func (*MediaTypeBuilder)Examples

func (*MediaTypeBuilder)Extensions

func (b *MediaTypeBuilder) Extensions(v map[string]any) *MediaTypeBuilder

func (*MediaTypeBuilder)Schema

typeOAuthFlow

type OAuthFlow struct {// REQUIRED.// The available scopes for the OAuth2 security scheme.// A map between the scope name and a short description for it.// The map MAY be empty.//// Applies To: oauth2Scopes map[string]string `json:"scopes,omitempty" yaml:"scopes,omitempty"`// REQUIRED.// The authorization URL to be used for this flow.// This MUST be in the form of a URL.// The OAuth2 standard requires the use of TLS.//// Applies To:oauth2 ("implicit", "authorizationCode")AuthorizationURLstring `json:"authorizationUrl,omitempty" yaml:"authorizationUrl,omitempty"`// REQUIRED.// The token URL to be used for this flow.// This MUST be in the form of a URL.// The OAuth2 standard requires the use of TLS.//// Applies To: oauth2 ("password", "clientCredentials", "authorizationCode")TokenURLstring `json:"tokenUrl,omitempty" yaml:"tokenUrl,omitempty"`// The URL to be used for obtaining refresh tokens.// This MUST be in the form of a URL.// The OAuth2 standard requires the use of TLS.//// Applies To: oauth2RefreshURLstring `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"`}

OAuthFlow configuration details for a supported OAuth Flow

https://spec.openapis.org/oas/v3.1.1#oauth-flow-object

Example:

implicit:  authorizationUrl: https://example.com/api/oauth/dialog  scopes:    write:pets: modify pets in your account    read:pets: read your petsauthorizationCode  authorizationUrl: https://example.com/api/oauth/dialog  scopes:    write:pets: modify pets in your account    read:pets: read your pets

typeOAuthFlowBuilder

type OAuthFlowBuilder struct {// contains filtered or unexported fields}

funcNewOAuthFlowBuilder

func NewOAuthFlowBuilder() *OAuthFlowBuilder

func (*OAuthFlowBuilder)AddExt

func (b *OAuthFlowBuilder) AddExt(namestring, valueany) *OAuthFlowBuilder

func (*OAuthFlowBuilder)AddScope

func (b *OAuthFlowBuilder) AddScope(name, valuestring) *OAuthFlowBuilder

func (*OAuthFlowBuilder)AuthorizationURL

func (b *OAuthFlowBuilder) AuthorizationURL(vstring) *OAuthFlowBuilder

func (*OAuthFlowBuilder)Build

func (*OAuthFlowBuilder)Extensions

func (b *OAuthFlowBuilder) Extensions(v map[string]any) *OAuthFlowBuilder

func (*OAuthFlowBuilder)RefreshURL

func (b *OAuthFlowBuilder) RefreshURL(vstring) *OAuthFlowBuilder

func (*OAuthFlowBuilder)Scopes

func (*OAuthFlowBuilder)TokenURL

typeOAuthFlows

type OAuthFlows struct {// Configuration for the OAuth Implicit flow.Implicit *Extendable[OAuthFlow] `json:"implicit,omitempty" yaml:"implicit,omitempty"`// Configuration for the OAuth Resource Owner Password flow.Password *Extendable[OAuthFlow] `json:"password,omitempty" yaml:"password,omitempty"`// Configuration for the OAuth Client Credentials flow.// Previously called application in OpenAPI 2.0.ClientCredentials *Extendable[OAuthFlow] `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"`// Configuration for the OAuth Authorization Code flow.// Previously called accessCode in OpenAPI 2.0.AuthorizationCode *Extendable[OAuthFlow] `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty"`}

OAuthFlows allows configuration of the supported OAuth Flows.

https://spec.openapis.org/oas/v3.1.1#oauth-flows-object

Example:

type: oauth2flows:  implicit:    authorizationUrl: https://example.com/api/oauth/dialog    scopes:      write:pets: modify pets in your account      read:pets: read your pets  authorizationCode:    authorizationUrl: https://example.com/api/oauth/dialog    tokenUrl: https://example.com/api/oauth/token    scopes:      write:pets: modify pets in your account      read:pets: read your pets

typeOAuthFlowsBuilder

type OAuthFlowsBuilder struct {// contains filtered or unexported fields}

funcNewOAuthFlowsBuilder

func NewOAuthFlowsBuilder() *OAuthFlowsBuilder

func (*OAuthFlowsBuilder)AddExt

func (b *OAuthFlowsBuilder) AddExt(namestring, valueany) *OAuthFlowsBuilder

func (*OAuthFlowsBuilder)AuthorizationCode

func (b *OAuthFlowsBuilder) AuthorizationCode(v *Extendable[OAuthFlow]) *OAuthFlowsBuilder

func (*OAuthFlowsBuilder)Build

func (*OAuthFlowsBuilder)ClientCredentials

func (b *OAuthFlowsBuilder) ClientCredentials(v *Extendable[OAuthFlow]) *OAuthFlowsBuilder

func (*OAuthFlowsBuilder)Extensions

func (b *OAuthFlowsBuilder) Extensions(v map[string]any) *OAuthFlowsBuilder

func (*OAuthFlowsBuilder)Implicit

func (*OAuthFlowsBuilder)Password

typeOpenAPI

type OpenAPI struct {// An element to hold various schemas for the document.Components *Extendable[Components] `json:"components,omitempty" yaml:"components,omitempty"`// REQUIRED// Provides metadata about the API. The metadata MAY be used by tooling as required.Info *Extendable[Info] `json:"info" yaml:"info"`// Additional external documentation.ExternalDocs *Extendable[ExternalDocs] `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`// Holds the relative paths to the individual endpoints and their operations.// The path is appended to the URL from the Server Object in order to construct the full URL.// The Paths MAY be empty, due to Access Control List (ACL) constraints.Paths *Extendable[Paths] `json:"paths,omitempty" yaml:"paths,omitempty"`// The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement.// Closely related to the callbacks feature, this section describes requests initiated other than by an API call,// for example by an out of band registration.// The key name is a unique string to refer to each webhook, while the (optionally referenced) PathItem Object describes// a request that may be initiated by the API provider and the expected responses.WebHooksWebhooks `json:"webhooks,omitempty" yaml:"webhooks,omitempty"`// The default value for the $schema keyword within Schema Objects contained within this OAS document.// This MUST be in the form of a URI.JsonSchemaDialectstring `json:"jsonSchemaDialect,omitempty" yaml:"jsonSchemaDialect,omitempty"`// REQUIRED// This string MUST be the version number of the OpenAPI Specification that the OpenAPI document uses.// The openapi field SHOULD be used by tooling to interpret the OpenAPI document.// This is not related to the API info.version string.OpenAPIstring `json:"openapi" yaml:"openapi"`// A declaration of which security mechanisms can be used across the API.// The list of values includes alternative security requirement objects that can be used.// Only one of the security requirement objects need to be satisfied to authorize a request.// Individual operations can override this definition.// To make security optional, an empty security requirement ({}) can be included in the array.Security []SecurityRequirement `json:"security,omitempty" yaml:"security,omitempty"`// A list of tags used by the document with additional metadata.// The order of the tags can be used to reflect on their order by the parsing tools.// Not all tags that are used by the Operation Object must be declared.// The tags that are not declared MAY be organized randomly or based on the tools’ logic.// Each tag name in the list MUST be unique.Tags []*Extendable[Tag] `json:"tags,omitempty" yaml:"tags,omitempty"`// An array of Server Objects, which provide connectivity information to a target server.// If the servers property is not provided, or is an empty array, the default value would be a Server Object with a url value of /.Servers []*Extendable[Server] `json:"servers,omitempty" yaml:"servers,omitempty"`}

OpenAPI is the root object of the OpenAPI document.

https://spec.openapis.org/oas/v3.1.1#openapi-object

Example:

openapi: 3.1.1info:  title: Minimal OpenAPI example  version: 1.0.0paths: { }

typeOpenAPIBuilder

type OpenAPIBuilder struct {// contains filtered or unexported fields}

funcNewOpenAPIBuilder

func NewOpenAPIBuilder() *OpenAPIBuilder

func (*OpenAPIBuilder)AddComponent

func (b *OpenAPIBuilder) AddComponent(namestring, componentany) *OpenAPIBuilder

func (*OpenAPIBuilder)AddExt

func (b *OpenAPIBuilder) AddExt(namestring, valueany) *OpenAPIBuilder

func (*OpenAPIBuilder)AddPath

func (*OpenAPIBuilder)AddSecurity

func (*OpenAPIBuilder)AddServers

func (b *OpenAPIBuilder) AddServers(servers ...*Extendable[Server]) *OpenAPIBuilder

func (*OpenAPIBuilder)AddTags

func (b *OpenAPIBuilder) AddTags(tags ...*Extendable[Tag]) *OpenAPIBuilder

func (*OpenAPIBuilder)AddWebHook

func (b *OpenAPIBuilder) AddWebHook(namestring, path *RefOrSpec[Extendable[PathItem]]) *OpenAPIBuilder

func (*OpenAPIBuilder)Build

func (b *OpenAPIBuilder) Build() *Extendable[OpenAPI]

func (*OpenAPIBuilder)Components

func (b *OpenAPIBuilder) Components(components *Extendable[Components]) *OpenAPIBuilder

func (*OpenAPIBuilder)Extensions

func (b *OpenAPIBuilder) Extensions(v map[string]any) *OpenAPIBuilder

func (*OpenAPIBuilder)ExternalDocs

func (b *OpenAPIBuilder) ExternalDocs(externalDocs *Extendable[ExternalDocs]) *OpenAPIBuilder

func (*OpenAPIBuilder)Info

func (*OpenAPIBuilder)JsonSchemaDialect

func (b *OpenAPIBuilder) JsonSchemaDialect(jsonSchemaDialectstring) *OpenAPIBuilder

func (*OpenAPIBuilder)OpenAPI

func (b *OpenAPIBuilder) OpenAPI(openAPIstring) *OpenAPIBuilder

func (*OpenAPIBuilder)Paths

func (b *OpenAPIBuilder) Paths(paths *Extendable[Paths]) *OpenAPIBuilder

func (*OpenAPIBuilder)Security

func (b *OpenAPIBuilder) Security(security ...SecurityRequirement) *OpenAPIBuilder

func (*OpenAPIBuilder)Servers

func (b *OpenAPIBuilder) Servers(servers ...*Extendable[Server]) *OpenAPIBuilder

func (*OpenAPIBuilder)Tags

func (b *OpenAPIBuilder) Tags(tags ...*Extendable[Tag]) *OpenAPIBuilder

func (*OpenAPIBuilder)WebHooks

func (b *OpenAPIBuilder) WebHooks(webHooksWebhooks) *OpenAPIBuilder

typeOperation

type Operation struct {// The request body applicable for this operation.// The requestBody is fully supported in HTTP methods where the HTTP 1.1 specification [RFC7231] has// explicitly defined semantics for request bodies.// In other cases where the HTTP spec is vague (such as [GET](section-4.3.1), [HEAD](section-4.3.2) and// [DELETE](section-4.3.5)), requestBody is permitted but does not have well-defined semantics and SHOULD be avoided if possible.RequestBody *RefOrSpec[Extendable[RequestBody]] `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`// The list of possible responses as they are returned from executing this operation.Responses *Extendable[Responses] `json:"responses,omitempty" yaml:"responses,omitempty"`// A map of possible out-of band callbacks related to the parent operation.// The key is a unique identifier for the Callback Object.// Each value in the map is a Callback Object that describes a request that may be initiated by the API provider and the expected responses.Callbacks map[string]*RefOrSpec[Extendable[Callback]] `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`// Additional external documentation for this operation.ExternalDocs *Extendable[ExternalDocs] `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`// Unique string used to identify the operation.// The id MUST be unique among all operations described in the API.// The operationId value is case-sensitive.// Tools and libraries MAY use the operationId to uniquely identify an operation, therefore,// it is RECOMMENDED to follow common programming naming conventions.OperationIDstring `json:"operationId,omitempty" yaml:"operationId,omitempty"`// A short summary of what the operation does.Summarystring `json:"summary,omitempty" yaml:"summary,omitempty"`// A verbose explanation of the operation behavior.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// A list of parameters that are applicable for this operation.// If a parameter is already defined at the Path Item, the new definition will override it but can never remove it.// The list MUST NOT include duplicated parameters.// A unique parameter is defined by a combination of a name and location.// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object’s components/parameters.Parameters []*RefOrSpec[Extendable[Parameter]] `json:"parameters,omitempty" yaml:"parameters,omitempty"`// A list of tags for API documentation control.// Tags can be used for logical grouping of operations by resources or any other qualifier.Tags []string `json:"tags,omitempty" yaml:"tags,omitempty"`// A declaration of which security mechanisms can be used for this operation.// The list of values includes alternative security requirement objects that can be used.// Only one of the security requirement objects need to be satisfied to authorize a request.// To make security optional, an empty security requirement ({}) can be included in the array.// This definition overrides any declared top-level security.// To remove a top-level security declaration, an empty array can be used.Security []SecurityRequirement `json:"security,omitempty" yaml:"security,omitempty"`// An alternative server array to service this operation.// If an alternative server object is specified at the Path Item Object or Root level, it will be overridden by this value.Servers []*Extendable[Server] `json:"servers,omitempty" yaml:"servers,omitempty"`// Declares this operation to be deprecated.// Consumers SHOULD refrain from usage of the declared operation.// Default value is false.Deprecatedbool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`}

Operation Describes a single API operation on a path.

https://spec.openapis.org/oas/v3.1.1#operation-object

Example:

tags:- petsummary: Updates a pet in the store with form dataoperationId: updatePetWithFormparameters:- name: petId  in: path  description: ID of pet that needs to be updated  required: true  schema:    type: stringrequestBody:  content:    'application/x-www-form-urlencoded':      schema:       type: object       properties:          name:            description: Updated name of the pet            type: string          status:            description: Updated status of the pet            type: string       required:         - statusresponses:  '200':    description: Pet updated.    content:      'application/json': {}      'application/xml': {}  '405':    description: Method Not Allowed    content:      'application/json': {}      'application/xml': {}security:- petstore_auth:  - write:pets  - read:pets

typeOperationBuilder

type OperationBuilder struct {// contains filtered or unexported fields}

funcNewOperationBuilder

func NewOperationBuilder() *OperationBuilder

func (*OperationBuilder)AddCallback

func (*OperationBuilder)AddExt

func (b *OperationBuilder) AddExt(namestring, valueany) *OperationBuilder

func (*OperationBuilder)AddParameters

func (*OperationBuilder)AddSecurity

func (*OperationBuilder)AddServers

func (b *OperationBuilder) AddServers(v ...*Extendable[Server]) *OperationBuilder

func (*OperationBuilder)AddTags

func (b *OperationBuilder) AddTags(v ...string) *OperationBuilder

func (*OperationBuilder)Build

func (*OperationBuilder)Callbacks

func (*OperationBuilder)Deprecated

func (b *OperationBuilder) Deprecated(vbool) *OperationBuilder

func (*OperationBuilder)Description

func (b *OperationBuilder) Description(vstring) *OperationBuilder

func (*OperationBuilder)Extensions

func (b *OperationBuilder) Extensions(v map[string]any) *OperationBuilder

func (*OperationBuilder)ExternalDocs

func (*OperationBuilder)OperationID

func (b *OperationBuilder) OperationID(vstring) *OperationBuilder

func (*OperationBuilder)Parameters

func (*OperationBuilder)RequestBody

func (*OperationBuilder)Security

func (*OperationBuilder)Servers

func (*OperationBuilder)Summary

func (*OperationBuilder)Tags

typeParameter

type Parameter struct {// Example of the parameter’s potential value.// The example SHOULD match the specified schema and encoding properties if present.// The example field is mutually exclusive of the examples field.// Furthermore, if referencing a schema that contains an example, the example value SHALL override the example provided by the schema.// To represent examples of media types that cannot naturally be represented in JSON or YAML,// a string value can contain the example with escaping where necessary.Exampleany `json:"example,omitempty" yaml:"example,omitempty"`// A map containing the representations for the parameter.// The key is the media type and the value describes it.// The map MUST only contain one entry.Content map[string]*Extendable[MediaType] `json:"content,omitempty" yaml:"content,omitempty"`// Examples of the parameter’s potential value.// Each example SHOULD contain a value in the correct format as specified in the parameter encoding.// The examples field is mutually exclusive of the example field.// Furthermore, if referencing a schema that contains an example, the examples value SHALL override the example provided by the schema.Examples map[string]*RefOrSpec[Extendable[Example]] `json:"examples,omitempty" yaml:"examples,omitempty"`// The schema defining the type used for the parameter.Schema *RefOrSpec[Schema] `json:"schema,omitempty" yaml:"schema,omitempty"`// REQUIRED.// The location of the parameter.// Possible values are "query", "header", "path" or "cookie".Instring `json:"in" yaml:"in"`// A brief description of the parameter.// This could contain examples of use.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// Describes how the parameter value will be serialized depending on the type of the parameter value.// Default values (based on value of in)://   for query - form;//   for path - simple;//   for header - simple;//   for cookie - form.Stylestring `json:"style,omitempty" yaml:"style,omitempty"`// REQUIRED.// The name of the parameter.// Parameter names are case sensitive.// If in is "path", the name field MUST correspond to a template expression occurring within the path field in the Paths Object.// See Path Templating for further information.// If in is "header" and the name field is "Accept", "Content-Type" or "Authorization", the parameter definition SHALL be ignored.// For all other cases, the name corresponds to the parameter name used by the in property.Namestring `json:"name" yaml:"name"`// When this is true, parameter values of type array or object generate separate parameters// for each value of the array or key-value pair of the map.// For other types of parameters this property has no effect.// When style is form, the default value is true.// For all other styles, the default value is false.Explodebool `json:"explode,omitempty" yaml:"explode,omitempty"`// Determines whether the parameter value SHOULD allow reserved characters, as defined by [RFC3986]//   :/?#[]@!$&'()*+,;=// to be included without percent-encoding.// This property only applies to parameters with an in value of query.// The default value is false.AllowReservedbool `json:"allowReserved,omitempty" yaml:"allowReserved,omitempty"`// Sets the ability to pass empty-valued parameters.// This is valid only for query parameters and allows sending a parameter with an empty value.// Default value is false.// If style is used, and if behavior is n/a (cannot be serialized), the value of allowEmptyValue SHALL be ignored.// Use of this property is NOT RECOMMENDED, as it is likely to be removed in a later revision.AllowEmptyValuebool `json:"allowEmptyValue,omitempty" yaml:"allowEmptyValue,omitempty"`// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage.// Default value is false.Deprecatedbool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`// Determines whether this parameter is mandatory.// If the parameter location is "path", this property is REQUIRED and its value MUST be true.// Otherwise, the property MAY be included and its default value is false.Requiredbool `json:"required,omitempty" yaml:"required,omitempty"`}

Parameter describes a single operation parameter.A unique parameter is defined by a combination of a name and location.

https://spec.openapis.org/oas/v3.1.1#parameter-object

Example:

name: petdescription: Pets operations

typeParameterBuilder

type ParameterBuilder struct {// contains filtered or unexported fields}

funcNewParameterBuilder

func NewParameterBuilder() *ParameterBuilder

func (*ParameterBuilder)AddContent

func (b *ParameterBuilder) AddContent(namestring, value *Extendable[MediaType]) *ParameterBuilder

func (*ParameterBuilder)AddExample

func (*ParameterBuilder)AddExt

func (b *ParameterBuilder) AddExt(namestring, valueany) *ParameterBuilder

func (*ParameterBuilder)AllowEmptyValue

func (b *ParameterBuilder) AllowEmptyValue(vbool) *ParameterBuilder

func (*ParameterBuilder)AllowReserved

func (b *ParameterBuilder) AllowReserved(vbool) *ParameterBuilder

func (*ParameterBuilder)Build

func (*ParameterBuilder)Content

func (*ParameterBuilder)Deprecated

func (b *ParameterBuilder) Deprecated(vbool) *ParameterBuilder

func (*ParameterBuilder)Description

func (b *ParameterBuilder) Description(vstring) *ParameterBuilder

func (*ParameterBuilder)Example

func (*ParameterBuilder)Examples

func (*ParameterBuilder)Explode

func (*ParameterBuilder)Extensions

func (b *ParameterBuilder) Extensions(v map[string]any) *ParameterBuilder

func (*ParameterBuilder)In

func (*ParameterBuilder)Name

func (*ParameterBuilder)Required

func (b *ParameterBuilder) Required(vbool) *ParameterBuilder

func (*ParameterBuilder)Schema

func (*ParameterBuilder)Style

typeParseOptionadded inv1.1.0

type ParseOption func(*parseOptions)

funcWithDefaultEncodingadded inv1.1.0

func WithDefaultEncoding(vstring)ParseOption

WithDefaultEncoding sets the default encoding for the schema for []byte fields.The default encoding is Base64Encoding.

typePathItem

type PathItem struct {// An optional, string summary, intended to apply to all operations in this path.Summarystring `json:"summary,omitempty" yaml:"summary,omitempty"`// An optional, string description, intended to apply to all operations in this path.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// A definition of a GET operation on this path.Get *Extendable[Operation] `json:"get,omitempty" yaml:"get,omitempty"`// A definition of a PUT operation on this path.Put *Extendable[Operation] `json:"put,omitempty" yaml:"put,omitempty"`// A definition of a POST operation on this path.Post *Extendable[Operation] `json:"post,omitempty" yaml:"post,omitempty"`// A definition of a DELETE operation on this path.Delete *Extendable[Operation] `json:"delete,omitempty" yaml:"delete,omitempty"`// A definition of a OPTIONS operation on this path.Options *Extendable[Operation] `json:"options,omitempty" yaml:"options,omitempty"`// A definition of a HEAD operation on this path.Head *Extendable[Operation] `json:"head,omitempty" yaml:"head,omitempty"`// A definition of a PATCH operation on this path.Patch *Extendable[Operation] `json:"patch,omitempty" yaml:"patch,omitempty"`// A definition of a TRACE operation on this path.Trace *Extendable[Operation] `json:"trace,omitempty" yaml:"trace,omitempty"`// An alternative server array to service all operations in this path.Servers []*Extendable[Server] `json:"servers,omitempty" yaml:"servers,omitempty"`// A list of parameters that are applicable for all the operations described under this path.// These parameters can be overridden at the operation level, but cannot be removed there.// The list MUST NOT include duplicated parameters.// A unique parameter is defined by a combination of a name and location.// The list can use the Reference Object to link to parameters that are defined at the OpenAPI Object’s components/parameters.Parameters []*RefOrSpec[Extendable[Parameter]] `json:"parameters,omitempty" yaml:"parameters,omitempty"`}

PathItem describes the operations available on a single path.A Path Item MAY be empty, due to ACL constraints.The path itself is still exposed to the documentation viewer but they will not know which operations and parameters are available.

https://spec.openapis.org/oas/v3.1.1#path-item-object

Example:

get:  description: Returns pets based on ID  summary: Find pets by ID  operationId: getPetsById  responses:    '200':      description: pet response      content:        '*/*' :          schema:            type: array            items:              $ref: '#/components/schemas/Pet'    default:      description: error payload      content:        'text/html':          schema:            $ref: '#/components/schemas/ErrorModel'parameters:- name: id  in: path  description: ID of pet to use  required: true  schema:    type: array    items:      type: string  style: simple

typePathItemBuilder

type PathItemBuilder struct {// contains filtered or unexported fields}

funcNewPathItemBuilder

func NewPathItemBuilder() *PathItemBuilder

func (*PathItemBuilder)AddExt

func (b *PathItemBuilder) AddExt(namestring, valueany) *PathItemBuilder

func (*PathItemBuilder)AddParameters

func (*PathItemBuilder)AddServers

func (b *PathItemBuilder) AddServers(v ...*Extendable[Server]) *PathItemBuilder

func (*PathItemBuilder)Build

func (*PathItemBuilder)Delete

func (*PathItemBuilder)Description

func (b *PathItemBuilder) Description(vstring) *PathItemBuilder

func (*PathItemBuilder)Extensions

func (b *PathItemBuilder) Extensions(v map[string]any) *PathItemBuilder

func (*PathItemBuilder)Get

func (*PathItemBuilder)Head

func (*PathItemBuilder)Options

func (*PathItemBuilder)Parameters

func (*PathItemBuilder)Patch

func (*PathItemBuilder)Post

func (*PathItemBuilder)Put

func (*PathItemBuilder)Servers

func (*PathItemBuilder)Summary

func (*PathItemBuilder)Trace

typePaths

type Paths struct {// A relative path to an individual endpoint.// The field name MUST begin with a forward slash (/).// The path is appended (no relative URL resolution) to the expanded URL// from the Server Object’s url field in order to construct the full URL.// Path templating is allowed.// When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts.// Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical.// In case of ambiguous matching, it’s up to the tooling to decide which one to use.Paths map[string]*RefOrSpec[Extendable[PathItem]] `json:"-" yaml:"-"`}

Paths holds the relative paths to the individual endpoints and their operations.The path is appended to the URL from the Server Object in order to construct the full URL.The Paths MAY be empty, due to Access Control List (ACL) constraints.

https://spec.openapis.org/oas/v3.1.1#paths-object

Example:

/pets:  get:    description: Returns all pets from the system that the user has access to    responses:      '200':        description: A list of pets.        content:          application/json:            schema:              type: array              items:                $ref: '#/components/schemas/pet'

func (*Paths)Add

func (o *Paths) Add(pathstring, item *RefOrSpec[Extendable[PathItem]]) *Paths

func (*Paths)MarshalJSON

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

MarshalJSON implements json.Marshaler interface.

func (*Paths)MarshalYAML

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

MarshalYAML implements yaml.Marshaler interface.

func (*Paths)UnmarshalJSON

func (o *Paths) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*Paths)UnmarshalYAML

func (o *Paths) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeRef

type Ref struct {// REQUIRED.// The reference identifier.// This MUST be in the form of a URI.Refstring `json:"$ref" yaml:"$ref"`// A short summary which by default SHOULD override that of the referenced component.// If the referenced object-type does not allow a summary field, then this field has no effect.Summarystring `json:"summary,omitempty" yaml:"summary,omitempty"`// A description which by default SHOULD override that of the referenced component.// CommonMark syntax MAY be used for rich text representation.// If the referenced object-type does not allow a description field, then this field has no effect.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`}

Ref is a simple object to allow referencing other components in the OpenAPI document, internally and externally.The $ref string value contains a URI [RFC3986], which identifies the location of the value being referenced.See the rules for resolving Relative References.

https://spec.openapis.org/oas/v3.1.1#reference-object

Example:

$ref: '#/components/schemas/Pet'

typeRefOrSpec

type RefOrSpec[Tany] struct {Ref  *Ref `json:"-" yaml:"-"`Spec *T   `json:"-" yaml:"-"`}

RefOrSpec holds either Ref or any OpenAPI spec type.

NOTE: The Ref object takes precedent over Spec if using json or yaml Marshal and Unmarshal functions.

funcNewRefOrExtSpec

func NewRefOrExtSpec[Tany](vany) *RefOrSpec[Extendable[T]]

NewRefOrExtSpec creates an object of RefOrSpec[Extendable[any]] type from given Ref or string or any form of Spec.

funcNewRefOrSpec

func NewRefOrSpec[Tany](vany) *RefOrSpec[T]

NewRefOrSpec creates an object of RefOrSpec type from given Ref or string or any form of Spec.

func (*RefOrSpec[T])GetSpec

func (o *RefOrSpec[T]) GetSpec(c *Extendable[Components]) (*T,error)

GetSpec return a Spec if it is set or loads it from Components in case of Ref or an error

func (*RefOrSpec[T])MarshalJSON

func (o *RefOrSpec[T]) MarshalJSON() ([]byte,error)

MarshalJSON implements json.Marshaler interface.

func (*RefOrSpec[T])MarshalYAML

func (o *RefOrSpec[T]) MarshalYAML() (any,error)

MarshalYAML implements yaml.Marshaler interface.

func (*RefOrSpec[T])UnmarshalJSON

func (o *RefOrSpec[T]) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*RefOrSpec[T])UnmarshalYAML

func (o *RefOrSpec[T]) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeRequestBody

type RequestBody struct {// REQUIRED.// The content of the request body.// The key is a media type or [media type range](appendix-D) and the value describes it.// For requests that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*Content map[string]*Extendable[MediaType] `json:"content,omitempty" yaml:"content,omitempty"`// A brief description of the request body.// This could contain examples of use.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// Determines if the request body is required in the request.// Defaults to false.Requiredbool `json:"required,omitempty" yaml:"required,omitempty"`}

RequestBody describes a single request body.

https://spec.openapis.org/oas/v3.1.1#request-body-object

Example:

description: user to add to the systemcontent:  'application/json':    schema:      $ref: '#/components/schemas/User'    examples:      user:        summary: User Example        externalValue: 'https://foo.bar/examples/user-example.json'  'application/xml':    schema:      $ref: '#/components/schemas/User'    examples:      user:        summary: User example in XML        externalValue: 'https://foo.bar/examples/user-example.xml'  'text/plain':    examples:      user:        summary: User example in Plain text        externalValue: 'https://foo.bar/examples/user-example.txt'  '*/*':    examples:      user:        summary: User example in other format        externalValue: 'https://foo.bar/examples/user-example.whatever'

typeRequestBodyBuilder

type RequestBodyBuilder struct {// contains filtered or unexported fields}

funcNewRequestBodyBuilder

func NewRequestBodyBuilder() *RequestBodyBuilder

func (*RequestBodyBuilder)AddContent

func (*RequestBodyBuilder)AddExt

func (b *RequestBodyBuilder) AddExt(namestring, valueany) *RequestBodyBuilder

func (*RequestBodyBuilder)Build

func (*RequestBodyBuilder)Content

func (*RequestBodyBuilder)Description

func (*RequestBodyBuilder)Extensions

func (b *RequestBodyBuilder) Extensions(v map[string]any) *RequestBodyBuilder

func (*RequestBodyBuilder)Required

typeResponse

type Response struct {// Maps a header name to its definition.// [RFC7230] states header names are case insensitive.// If a response header is defined with the name "Content-Type", it SHALL be ignored.Headers map[string]*RefOrSpec[Extendable[Header]] `json:"headers,omitempty" yaml:"headers,omitempty"`// A map containing descriptions of potential response payloads.// The key is a media type or [media type range](appendix-D) and the value describes it.// For responses that match multiple keys, only the most specific key is applicable. e.g. text/plain overrides text/*Content map[string]*Extendable[MediaType] `json:"content,omitempty" yaml:"content,omitempty"`// A map of operations links that can be followed from the response.// The key of the map is a short name for the link, following the naming constraints of the names for Component Objects.Links map[string]*RefOrSpec[Extendable[Link]] `json:"links,omitempty" yaml:"links,omitempty"`// REQUIRED.// A description of the response.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`}

Response describes a single response from an API Operation, including design-time, static links to operations based on the response.

https://spec.openapis.org/oas/v3.1.1#response-object

Example:

description: A complex object array responsecontent:  application/json:    schema:      type: array      items:        $ref: '#/components/schemas/VeryComplexType'

typeResponseBuilder

type ResponseBuilder struct {// contains filtered or unexported fields}

funcNewResponseBuilder

func NewResponseBuilder() *ResponseBuilder

func (*ResponseBuilder)AddContent

func (b *ResponseBuilder) AddContent(keystring, value *Extendable[MediaType]) *ResponseBuilder

func (*ResponseBuilder)AddExt

func (b *ResponseBuilder) AddExt(namestring, valueany) *ResponseBuilder

func (*ResponseBuilder)AddHeader

func (*ResponseBuilder)AddLink

func (*ResponseBuilder)Build

func (*ResponseBuilder)Content

func (*ResponseBuilder)Description

func (b *ResponseBuilder) Description(vstring) *ResponseBuilder

func (*ResponseBuilder)Extensions

func (b *ResponseBuilder) Extensions(v map[string]any) *ResponseBuilder

func (*ResponseBuilder)Headers

func (*ResponseBuilder)Links

typeResponses

type Responses struct {// The documentation of responses other than the ones declared for specific HTTP response codes.// Use this field to cover undeclared responses.Default *RefOrSpec[Extendable[Response]] `json:"default,omitempty" yaml:"default,omitempty"`// Any HTTP status code can be used as the property name, but only one property per code,// to describe the expected response for that HTTP status code.// This field MUST be enclosed in quotation marks (for example, “200”) for compatibility between JSON and YAML.// To define a range of response codes, this field MAY contain the uppercase wildcard character X.// For example, 2XX represents all response codes between [200-299].// Only the following range definitions are allowed: 1XX, 2XX, 3XX, 4XX, and 5XX.// If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.Response map[string]*RefOrSpec[Extendable[Response]] `json:"-" yaml:"-"`}

Responses is a container for the expected responses of an operation.The container maps a HTTP response code to the expected response.The documentation is not necessarily expected to cover all possible HTTP response codes because they may not be known in advance.However, documentation is expected to cover a successful operation response and any known errors.The default MAY be used as a default response object for all HTTP codes that are not covered individually by the Responses Object.The Responses Object MUST contain at least one response code, and if only one response code is providedit SHOULD be the response for a successful operation call.

https://spec.openapis.org/oas/v3.1.1#responses-object

Example:

'200':  description: a pet to be returned  content:    application/json:      schema:        $ref: '#/components/schemas/Pet'default:  description: Unexpected error  content:    application/json:      schema:        $ref: '#/components/schemas/ErrorModel'

func (*Responses)MarshalJSON

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

MarshalJSON implements json.Marshaler interface.

func (*Responses)MarshalYAML

func (o *Responses) MarshalYAML() (any,error)

MarshalYAML implements yaml.Marshaler interface.

func (*Responses)UnmarshalJSON

func (o *Responses) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*Responses)UnmarshalYAML

func (o *Responses) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeResponsesBuilder

type ResponsesBuilder struct {// contains filtered or unexported fields}

funcNewResponsesBuilder

func NewResponsesBuilder() *ResponsesBuilder

func (*ResponsesBuilder)AddExt

func (b *ResponsesBuilder) AddExt(namestring, valueany) *ResponsesBuilder

func (*ResponsesBuilder)AddResponse

func (*ResponsesBuilder)Build

func (*ResponsesBuilder)Default

func (*ResponsesBuilder)Extensions

func (b *ResponsesBuilder) Extensions(v map[string]any) *ResponsesBuilder

func (*ResponsesBuilder)Response

typeSchema

type Schema struct {// The $schema keyword is used to declare which dialect of JSON Schema the schema was written for.// The value of the $schema keyword is also the identifier for a schema that can be used to verify// that the schema is valid according to the dialect $schema identifies.// A schema that describes another schema is called a "meta-schema".// $schema applies to the entire document and must be at the root level.// It does not apply to externally referenced ($ref, $dynamicRef) documents.// Those schemas need to declare their own $schema.// If $schema is not used, an implementation might allow you to specify a value externally or// it might make assumptions about which specification version should be used to evaluate the schema.// It's recommended that all JSON Schemas have a $schema keyword to communicate to readers and// tooling which specification version is intended.////https://json-schema.org/understanding-json-schema/reference/schema#schemaSchemastring `json:"$schema,omitempty" yaml:"$schema,omitempty"`// The value of $id is a URI-reference without a fragment that resolves against the retrieval-uri.// The resulting URI is the base URI for the schema.////https://json-schema.org/understanding-json-schema/structuring#idIDstring `json:"$id,omitempty" yaml:"$id,omitempty"`//https://json-schema.org/understanding-json-schema/structuring#dollardefsDefs          map[string]*RefOrSpec[Schema] `json:"$defs,omitempty"          yaml:"$defs,omitempty"`DynamicRefstring                        `json:"$dynamicRef,omitempty"    yaml:"$dynamicRef,omitempty"`Vocabulary    map[string]bool               `json:"$vocabulary,omitempty"    yaml:"$vocabulary,omitempty"`DynamicAnchorstring                        `json:"$dynamicAnchor,omitempty" yaml:"dynamicAnchor,omitempty"`//https://json-schema.org/understanding-json-schema/reference/type#type-specific-keywordsType *SingleOrArray[string] `json:"type,omitempty" yaml:"type,omitempty"`// The default keyword specifies a default value.// This value is not used to fill in missing values during the validation process.// Non-validation tools such as documentation generators or form generators may use this value// to give hints to users about how to use a value.// However, default is typically used to express that if a value is missing,// then the value is semantically the same as if the value was present with the default value.// The value of default should validate against the schema in which it resides, but that isn't required.Defaultany `json:"default,omitempty" yaml:"default,omitempty"`// The title keyword preferably be short.Titlestring `json:"title,omitempty" yaml:"title,omitempty"`// The description keyword provides a more lengthy explanation about the purpose of the data described by the schema.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// The const keyword is used to restrict a value to a single value.////https://json-schema.org/understanding-json-schema/reference/constConststring `json:"const,omitempty" yaml:"const,omitempty"`// The $comment keyword is strictly intended for adding comments to a schema.// Its value must always be a string.// Unlike the annotations title, description, and examples, JSON schema implementations aren’t allowed// to attach any meaning or behavior to it whatsoever, and may even strip them at any time.// Therefore, they are useful for leaving notes to future editors of a JSON schema,// but should not be used to communicate to users of the schema.////https://json-schema.org/understanding-json-schema/reference/generic.html#commentsCommentstring `json:"$comment,omitempty" yaml:"$comment,omitempty"`// The enum keyword is used to restrict a value to a fixed set of values.// It must be an array with at least one element, where each element is unique.////https://json-schema.org/understanding-json-schema/reference/generic.html#enumerated-valuesEnum []any `json:"enum,omitempty" yaml:"enum,omitempty"`// The examples keyword is a place to provide an array of examples that validate against the schema.// This isn't used for validation, but may help with explaining the effect and purpose of the schema to a reader.// Each entry should validate against the schema in which it resides, but that isn't strictly required.// There is no need to duplicate the default value in the examples array,// since default will be treated as another example.Examples []any `json:"examples,omitempty" yaml:"examples,omitempty"`// The readOnly indicates that a value should not be modified.// It could be used to indicate that a PUT request that changes a value would result in a 400 Bad Request response.ReadOnlybool `json:"readOnly,omitempty" yaml:"readOnly,omitempty"`// The writeOnly indicates that a value may be set, but will remain hidden.// In could be used to indicate you can set a value with a PUT request,// but it would not be included when retrieving that record with a GET request.WriteOnlybool `json:"writeOnly,omitempty" yaml:"writeOnly,omitempty"`// The deprecated keyword is a boolean that indicates that the instance value the keyword applies to// should not be used and may be removed in the future.Deprecatedbool `json:"deprecated,omitempty" yaml:"deprecated,omitempty"`//https://json-schema.org/understanding-json-schema/reference/non_json_data#contentschemaContentSchema *RefOrSpec[Schema] `json:"contentSchema,omitempty" yaml:"contentSchema,omitempty"`// The contentMediaType keyword specifies the MIME type of the contents of a string, as described inRFC 2046.// There is a list of MIME types officially registered by the IANA, but the set of types supported will be// application and operating system dependent.////https://json-schema.org/understanding-json-schema/reference/non_json_data#contentmediatypeContentMediaTypestring `json:"contentMediaType,omitempty" yaml:"contentMediaType,omitempty"`// The contentEncoding keyword specifies the encoding used to store the contents, as specified inRFC 2054, part 6.1 andRFC 4648.////https://json-schema.org/understanding-json-schema/reference/non_json_data#contentencodingContentEncodingstring `json:"contentEncoding,omitempty" yaml:"contentEncoding,omitempty"`// The not keyword declares that an instance validates if it doesn’t validate against the given subschema.////https://json-schema.org/understanding-json-schema/reference/combining.html#notNot *RefOrSpec[Schema] `json:"not,omitempty" yaml:"not,omitempty"`// To validate against allOf, the given data must be valid against all of the given subschemas.////https://json-schema.org/understanding-json-schema/reference/combining.html#allofAllOf []*RefOrSpec[Schema] `json:"allOf,omitempty" yaml:"allOf,omitempty"`// To validate against anyOf, the given data must be valid against any (one or more) of the given subschemas.////https://json-schema.org/understanding-json-schema/reference/combining.html#anyofAnyOf []*RefOrSpec[Schema] `json:"anyOf,omitempty" yaml:"anyOf,omitempty"`// To validate against oneOf, the given data must be valid against exactly one of the given subschemas.////https://json-schema.org/understanding-json-schema/reference/combining.html#oneofOneOf []*RefOrSpec[Schema] `json:"oneOf,omitempty" yaml:"oneOf,omitempty"`// The dependentRequired keyword conditionally requires that certain properties must be present if// a given property is present in an object.// For example, suppose we have a schema representing a customer.// If you have their credit card number, you also want to ensure you have a billing address.// If you don’t have their credit card number, a billing address would not be required.// We represent this dependency of one property on another using the dependentRequired keyword.// The value of the dependentRequired keyword is an object.// Each entry in the object maps from the name of a property, p, to an array of strings listing properties that// are required if p is present.////https://json-schema.org/understanding-json-schema/reference/conditionals.html#dependentrequiredDependentRequired map[string][]string `json:"dependentRequired,omitempty" yaml:"dependentRequired,omitempty"`// The dependentSchemas keyword conditionally applies a subschema when a given property is present.// This schema is applied in the same way allOf applies schemas.// Nothing is merged or extended.// Both schemas apply independently.////https://json-schema.org/understanding-json-schema/reference/conditionals.html#dependentschemasDependentSchemas map[string]*RefOrSpec[Schema] `json:"dependentSchemas,omitempty" yaml:"dependentSchemas,omitempty"`//https://json-schema.org/understanding-json-schema/reference/conditionals.html#if-then-elseIf   *RefOrSpec[Schema] `json:"if,omitempty"   yaml:"if,omitempty"`Then *RefOrSpec[Schema] `json:"then,omitempty" yaml:"then,omitempty"`Else *RefOrSpec[Schema] `json:"else,omitempty" yaml:"else,omitempty"`// MultipleOf restricts the numbers to a multiple of a given number, using the multipleOf keyword.// It may be set to any positive number.////https://json-schema.org/understanding-json-schema/reference/numeric.html#multiplesMultipleOf *int `json:"multipleOf,omitempty" yaml:"multipleOf,omitempty"`// x ≥ minimumMinimum *int `json:"minimum,omitempty" yaml:"minimum,omitempty"`// x > exclusiveMinimumExclusiveMinimum *int `json:"exclusiveMinimum,omitempty" yaml:"exclusiveMinimum,omitempty"`// x ≤ maximumMaximum *int `json:"maximum,omitempty" yaml:"maximum,omitempty"`// x < exclusiveMaximumExclusiveMaximum *int `json:"exclusiveMaximum,omitempty" yaml:"exclusiveMaximum,omitempty"`MinLength *int   `json:"minLength,omitempty" yaml:"minLength,omitempty"`MaxLength *int   `json:"maxLength,omitempty" yaml:"maxLength,omitempty"`Patternstring `json:"pattern,omitempty"   yaml:"pattern,omitempty"`Formatstring `json:"format,omitempty"    yaml:"format,omitempty"`// List validation is useful for arrays of arbitrary length where each item matches the same schema.// For this kind of array, set the items keyword to a single schema that will be used to validate all of the items in the array.////https://json-schema.org/understanding-json-schema/reference/array#itemsItems *BoolOrSchema `json:"items,omitempty" yaml:"items,omitempty"`//https://json-schema.org/understanding-json-schema/reference/array#lengthMaxItems *int `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`// The unevaluatedItems keyword is similar to unevaluatedProperties, but for items.////https://json-schema.org/understanding-json-schema/reference/array#unevaluateditemsUnevaluatedItems *BoolOrSchema `json:"unevaluatedItems,omitempty" yaml:"unevaluatedItems,omitempty"`// While the items schema must be valid for every item in the array, the contains schema only needs// to validate against one or more items in the array.////https://json-schema.org/understanding-json-schema/reference/array.html#containsContains    *RefOrSpec[Schema] `json:"contains,omitempty"    yaml:"contains,omitempty"`MinContains *int               `json:"minContains,omitempty" yaml:"minContains,omitempty"`MaxContains *int               `json:"maxContains,omitempty" yaml:"maxContains,omitempty"`//https://json-schema.org/understanding-json-schema/reference/array.html#lengthMinItems *int `json:"minItems,omitempty" yaml:"minItems,omitempty"`// A schema can ensure that each of the items in an array is unique.// Simply set the uniqueItems keyword to true.////https://json-schema.org/understanding-json-schema/reference/array.html#uniquenessUniqueItems *bool `json:"uniqueItems,omitempty" yaml:"uniqueItems,omitempty"`// The prefixItems is an array, where each item is a schema that corresponds to each index of the document’s array.// That is, an array where the first element validates the first element of the input array,// the second element validates the second element of the input array, etc.////https://json-schema.org/understanding-json-schema/reference/array.html#tuple-validationPrefixItems []*RefOrSpec[Schema] `json:"prefixItems,omitempty" yaml:"prefixItems,omitempty"`// The properties (key-value pairs) on an object are defined using the properties keyword.// The value of properties is an object, where each key is the name of a property and each value is// a schema used to validate that property.// Any property that doesn't match any of the property names in the properties keyword is ignored by this keyword.////https://json-schema.org/understanding-json-schema/reference/object.html#propertiesProperties map[string]*RefOrSpec[Schema] `json:"properties,omitempty" yaml:"properties,omitempty"`// Sometimes you want to say that, given a particular kind of property name, the value should match a particular schema.// That’s where patternProperties comes in: it maps regular expressions to schemas.// If a property name matches the given regular expression, the property value must validate against the corresponding schema.////https://json-schema.org/understanding-json-schema/reference/object.html#pattern-propertiesPatternProperties map[string]*RefOrSpec[Schema] `json:"patternProperties,omitempty" yaml:"patternProperties,omitempty"`// The additionalProperties keyword is used to control the handling of extra stuff, that is,// properties whose names are not listed in the properties keyword or match any of the regular expressions// in the patternProperties keyword.// By default any additional properties are allowed.//// The value of the additionalProperties keyword is a schema that will be used to validate any properties in the instance// that are not matched by properties or patternProperties.// Setting the additionalProperties schema to false means no additional properties will be allowed.////https://json-schema.org/understanding-json-schema/reference/object.html#additional-propertiesAdditionalProperties *BoolOrSchema `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`// The unevaluatedProperties keyword is similar to additionalProperties except that it can recognize properties declared in subschemas.// So, the example from the previous section can be rewritten without the need to redeclare properties.////https://json-schema.org/understanding-json-schema/reference/object.html#unevaluated-propertiesUnevaluatedProperties *BoolOrSchema `json:"unevaluatedProperties,omitempty" yaml:"unevaluatedProperties,omitempty"`// The names of properties can be validated against a schema, irrespective of their values.// This can be useful if you don’t want to enforce specific properties, but you want to make sure that// the names of those properties follow a specific convention.// You might, for example, want to enforce that all names are valid ASCII tokens so they can be used// as attributes in a particular programming language.////https://json-schema.org/understanding-json-schema/reference/object.html#property-namesPropertyNames *RefOrSpec[Schema] `json:"propertyNames,omitempty" yaml:"propertyNames,omitempty"`// The min number of properties on an object.////https://json-schema.org/understanding-json-schema/reference/object.html#sizeMinProperties *int `json:"minProperties,omitempty" yaml:"minProperties,omitempty"`// The max number of properties on an object.////https://json-schema.org/understanding-json-schema/reference/object.html#sizeMaxProperties *int `json:"maxProperties,omitempty" yaml:"maxProperties,omitempty"`// The required keyword takes an array of zero or more strings.// Each of these strings must be unique.////https://json-schema.org/understanding-json-schema/reference/object.html#required-propertiesRequired []string `json:"required,omitempty" yaml:"required,omitempty"`// Adds support for polymorphism.// The discriminator is an object name that is used to differentiate between other schemas which may satisfy the payload description.// See Composition and Inheritance for more details.Discriminator *Discriminator `json:"discriminator,omitempty" yaml:"discriminator,omitempty"`// Additional external documentation for this tag.// xmlXML *Extendable[XML] `json:"xml,omitempty" yaml:"xml,omitempty"`// Additional external documentation for this schema.ExternalDocs *Extendable[ExternalDocs] `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`// A free-form property to include an example of an instance for this schema.// To represent examples that cannot be naturally represented in JSON or YAML, a string value can be used to// contain the example with escaping where necessary.//// Deprecated: The example property has been deprecated in favor of the JSON Schema examples keyword.// Use of example is discouraged, and later versions of this specification may remove it.Exampleany `json:"example,omitempty" yaml:"example,omitempty"`Extensions map[string]any `json:"-" yaml:"-"`// GoPackage is a custom field to store the Go package of the schema.GoPackagestring `json:"x-go-package,omitempty" yaml:"x-go-package,omitempty"`// GoType is a custom field to store the Go type of the schema.GoTypestring `json:"x-go-type,omitempty" yaml:"x-go-type,omitempty"`}

The Schema Object allows the definition of input and output data types.These types can be objects, but also primitives and arrays.This object is a superset of the JSON Schema Specification Draft 2020-12.For more information about the properties, see JSON Schema Core and JSON Schema Validation.Unless stated otherwise, the property definitions follow those of JSON Schema and do not add any additional semantics.Where JSON Schema indicates that behavior is defined by the application (e.g. for annotations),OAS also defers the definition of semantics to the application consuming the OpenAPI document.

https://spec.openapis.org/oas/v3.1.1#schema-objecthttps://json-schema.org/understanding-json-schema/index.html

func (*Schema)AddExt

func (o *Schema) AddExt(namestring, valueany) *Schema

AddExt sets the extension and returns the current object (self|this).Schema does not require special `x-` prefix.The extension will be ignored if the name overlaps with a struct field during marshaling to JSON or YAML.

func (*Schema)GetExt

func (o *Schema) GetExt(namestring)any

func (*Schema)MarshalJSON

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

MarshalJSON implements json.Marshaler interface.

func (*Schema)MarshalYAML

func (o *Schema) MarshalYAML() (any,error)

MarshalYAML implements yaml.Marshaler interface.

func (*Schema)UnmarshalJSON

func (o *Schema) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*Schema)UnmarshalYAML

func (o *Schema) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeSchemaBuilderadded inv1.1.0

type SchemaBuilder struct {// contains filtered or unexported fields}

funcNewSchemaBuilder

func NewSchemaBuilder() *SchemaBuilder

funcParseObjectadded inv1.1.0

func ParseObject(objany, components *Extendable[Components], opts ...ParseOption) (*SchemaBuilder,error)

ParseObject parses the object and returns the schema or the reference to the schema.

The object can be a struct, pointer to struct, map, slice, pointer to map or slice, or any other type.The object can contain fields with `json`, `yaml` or `openapi` tags.

`openapi:"<name>[,ref:<ref> || any other tags]"` tag:  - <name> is the name of the field in the schema, can be "-" to skip the field or empty to use the name from json, yaml tags or original field name.json schema fields:  - ref:<ref> is a reference to the schema, can not be used with jsonschema fields.  - required, marks the field as required by adding it to the required list of the parent schema.  - deprecated, marks the field as deprecated.  - title:<title>, sets the title of the field or summary for the fereference.  - summary:<summary>, sets the summary of the reference.  - description:<description>, sets the description of the field.  - type:<type> (boolean, integer, number, string, array, object), may be used multiple times.    The first usage overrides the default type, all other types are added.  - addtype:<type>, adds additional type, may be used multiple times.  - format:<format>, sets the format of the type.

The `components` parameter is needed to store the schemas of the structs, and to avoid the circular references.In case of the given object is struct, the function will return a reference to the schema stored in the componentsOtherwise, the function will return the schema itself.

func (*SchemaBuilder)AddAllOfadded inv1.1.0

func (b *SchemaBuilder) AddAllOf(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddAnyOfadded inv1.1.0

func (b *SchemaBuilder) AddAnyOf(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddDefadded inv1.1.0

func (b *SchemaBuilder) AddDef(namestring, value *RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddDependentRequiredadded inv1.1.0

func (b *SchemaBuilder) AddDependentRequired(namestring, value ...string) *SchemaBuilder

func (*SchemaBuilder)AddDependentSchemaadded inv1.1.0

func (b *SchemaBuilder) AddDependentSchema(namestring, value *RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddEnumadded inv1.1.0

func (b *SchemaBuilder) AddEnum(v ...any) *SchemaBuilder

func (*SchemaBuilder)AddExamplesadded inv1.1.0

func (b *SchemaBuilder) AddExamples(v ...any) *SchemaBuilder

func (*SchemaBuilder)AddExtadded inv1.1.0

func (b *SchemaBuilder) AddExt(namestring, valueany) *SchemaBuilder

func (*SchemaBuilder)AddOneOfadded inv1.1.0

func (b *SchemaBuilder) AddOneOf(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddPatternPropertyadded inv1.1.0

func (b *SchemaBuilder) AddPatternProperty(namestring, value *RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddPrefixItemsadded inv1.1.0

func (b *SchemaBuilder) AddPrefixItems(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddPropertyadded inv1.1.0

func (b *SchemaBuilder) AddProperty(namestring, value *RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AddRequiredadded inv1.1.0

func (b *SchemaBuilder) AddRequired(v ...string) *SchemaBuilder

func (*SchemaBuilder)AddTypeadded inv1.1.0

func (b *SchemaBuilder) AddType(v ...string) *SchemaBuilder

func (*SchemaBuilder)AddVocabularyadded inv1.1.0

func (b *SchemaBuilder) AddVocabulary(namestring, valuebool) *SchemaBuilder

func (*SchemaBuilder)AdditionalPropertiesadded inv1.1.0

func (b *SchemaBuilder) AdditionalProperties(v *BoolOrSchema) *SchemaBuilder

func (*SchemaBuilder)AllOfadded inv1.1.0

func (b *SchemaBuilder) AllOf(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)AnyOfadded inv1.1.0

func (b *SchemaBuilder) AnyOf(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)Buildadded inv1.1.0

func (b *SchemaBuilder) Build() *RefOrSpec[Schema]

func (*SchemaBuilder)Commentadded inv1.1.0

func (b *SchemaBuilder) Comment(vstring) *SchemaBuilder

func (*SchemaBuilder)Constadded inv1.1.0

func (*SchemaBuilder)Containsadded inv1.1.0

func (b *SchemaBuilder) Contains(v *RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)ContentEncodingadded inv1.1.0

func (b *SchemaBuilder) ContentEncoding(vstring) *SchemaBuilder

func (*SchemaBuilder)ContentMediaTypeadded inv1.1.0

func (b *SchemaBuilder) ContentMediaType(vstring) *SchemaBuilder

func (*SchemaBuilder)ContentSchemaadded inv1.1.0

func (b *SchemaBuilder) ContentSchema(v *RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)Defaultadded inv1.1.0

func (b *SchemaBuilder) Default(vany) *SchemaBuilder

func (*SchemaBuilder)Defsadded inv1.1.0

func (*SchemaBuilder)DependentRequiredadded inv1.1.0

func (b *SchemaBuilder) DependentRequired(v map[string][]string) *SchemaBuilder

func (*SchemaBuilder)DependentSchemasadded inv1.1.0

func (b *SchemaBuilder) DependentSchemas(v map[string]*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)Deprecatedadded inv1.1.0

func (b *SchemaBuilder) Deprecated(vbool) *SchemaBuilder

func (*SchemaBuilder)Descriptionadded inv1.1.0

func (b *SchemaBuilder) Description(vstring) *SchemaBuilder

func (*SchemaBuilder)Discriminatoradded inv1.1.0

func (b *SchemaBuilder) Discriminator(v *Discriminator) *SchemaBuilder

func (*SchemaBuilder)DynamicAnchoradded inv1.1.0

func (b *SchemaBuilder) DynamicAnchor(vstring) *SchemaBuilder

func (*SchemaBuilder)DynamicRefadded inv1.1.0

func (b *SchemaBuilder) DynamicRef(vstring) *SchemaBuilder

func (*SchemaBuilder)Elseadded inv1.1.0

func (*SchemaBuilder)Enumadded inv1.1.0

func (b *SchemaBuilder) Enum(v ...any) *SchemaBuilder

func (*SchemaBuilder)Exampleadded inv1.1.0

func (b *SchemaBuilder) Example(vany) *SchemaBuilder

func (*SchemaBuilder)Examplesadded inv1.1.0

func (b *SchemaBuilder) Examples(v ...any) *SchemaBuilder

func (*SchemaBuilder)ExclusiveMaximumadded inv1.1.0

func (b *SchemaBuilder) ExclusiveMaximum(vint) *SchemaBuilder

func (*SchemaBuilder)ExclusiveMinimumadded inv1.1.0

func (b *SchemaBuilder) ExclusiveMinimum(vint) *SchemaBuilder

func (*SchemaBuilder)Extensionsadded inv1.1.0

func (b *SchemaBuilder) Extensions(v map[string]any) *SchemaBuilder

func (*SchemaBuilder)ExternalDocsadded inv1.1.0

func (b *SchemaBuilder) ExternalDocs(v *Extendable[ExternalDocs]) *SchemaBuilder

func (*SchemaBuilder)Formatadded inv1.1.0

func (b *SchemaBuilder) Format(vstring) *SchemaBuilder

func (*SchemaBuilder)GoPackageadded inv1.1.0

func (b *SchemaBuilder) GoPackage(vstring) *SchemaBuilder

func (*SchemaBuilder)GoTypeadded inv1.1.0

func (b *SchemaBuilder) GoType(vstring) *SchemaBuilder

func (*SchemaBuilder)IDadded inv1.1.0

func (*SchemaBuilder)Ifadded inv1.1.0

func (*SchemaBuilder)IsRefadded inv1.1.0

func (b *SchemaBuilder) IsRef()bool

func (*SchemaBuilder)Itemsadded inv1.1.0

func (*SchemaBuilder)MaxContainsadded inv1.1.0

func (b *SchemaBuilder) MaxContains(vint) *SchemaBuilder

func (*SchemaBuilder)MaxItemsadded inv1.1.0

func (b *SchemaBuilder) MaxItems(vint) *SchemaBuilder

func (*SchemaBuilder)MaxLengthadded inv1.1.0

func (b *SchemaBuilder) MaxLength(vint) *SchemaBuilder

func (*SchemaBuilder)MaxPropertiesadded inv1.1.0

func (b *SchemaBuilder) MaxProperties(vint) *SchemaBuilder

func (*SchemaBuilder)Maximumadded inv1.1.0

func (b *SchemaBuilder) Maximum(vint) *SchemaBuilder

func (*SchemaBuilder)MinContainsadded inv1.1.0

func (b *SchemaBuilder) MinContains(vint) *SchemaBuilder

func (*SchemaBuilder)MinItemsadded inv1.1.0

func (b *SchemaBuilder) MinItems(vint) *SchemaBuilder

func (*SchemaBuilder)MinLengthadded inv1.1.0

func (b *SchemaBuilder) MinLength(vint) *SchemaBuilder

func (*SchemaBuilder)MinPropertiesadded inv1.1.0

func (b *SchemaBuilder) MinProperties(vint) *SchemaBuilder

func (*SchemaBuilder)Minimumadded inv1.1.0

func (b *SchemaBuilder) Minimum(vint) *SchemaBuilder

func (*SchemaBuilder)MultipleOfadded inv1.1.0

func (b *SchemaBuilder) MultipleOf(vint) *SchemaBuilder

func (*SchemaBuilder)Notadded inv1.1.0

func (*SchemaBuilder)OneOfadded inv1.1.0

func (b *SchemaBuilder) OneOf(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)Patternadded inv1.1.0

func (b *SchemaBuilder) Pattern(vstring) *SchemaBuilder

func (*SchemaBuilder)PatternPropertiesadded inv1.1.0

func (b *SchemaBuilder) PatternProperties(v map[string]*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)PrefixItemsadded inv1.1.0

func (b *SchemaBuilder) PrefixItems(v ...*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)Propertiesadded inv1.1.0

func (b *SchemaBuilder) Properties(v map[string]*RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)PropertyNamesadded inv1.1.0

func (b *SchemaBuilder) PropertyNames(v *RefOrSpec[Schema]) *SchemaBuilder

func (*SchemaBuilder)ReadOnlyadded inv1.1.0

func (b *SchemaBuilder) ReadOnly(vbool) *SchemaBuilder

func (*SchemaBuilder)Refadded inv1.1.0

func (*SchemaBuilder)Requiredadded inv1.1.0

func (b *SchemaBuilder) Required(v ...string) *SchemaBuilder

func (*SchemaBuilder)Schemaadded inv1.1.0

func (b *SchemaBuilder) Schema(vstring) *SchemaBuilder

func (*SchemaBuilder)Thenadded inv1.1.0

func (*SchemaBuilder)Titleadded inv1.1.0

func (*SchemaBuilder)Typeadded inv1.1.0

func (b *SchemaBuilder) Type(v ...string) *SchemaBuilder

func (*SchemaBuilder)UnevaluatedItemsadded inv1.1.0

func (b *SchemaBuilder) UnevaluatedItems(v *BoolOrSchema) *SchemaBuilder

func (*SchemaBuilder)UnevaluatedPropertiesadded inv1.1.0

func (b *SchemaBuilder) UnevaluatedProperties(v *BoolOrSchema) *SchemaBuilder

func (*SchemaBuilder)UniqueItemsadded inv1.1.0

func (b *SchemaBuilder) UniqueItems(vbool) *SchemaBuilder

func (*SchemaBuilder)Vocabularyadded inv1.1.0

func (b *SchemaBuilder) Vocabulary(v map[string]bool) *SchemaBuilder

func (*SchemaBuilder)WriteOnlyadded inv1.1.0

func (b *SchemaBuilder) WriteOnly(vbool) *SchemaBuilder

func (*SchemaBuilder)XMLadded inv1.1.0

typeSecurityRequirement

type SecurityRequirement map[string][]string

SecurityRequirement is the lists of the required security schemes to execute this operation.The name used for each property MUST correspond to a security scheme declared in the Security Schemes under the Components Object.Security Requirement Objects that contain multiple schemes require that all schemes MUST be satisfied for a request to be authorized.This enables support for scenarios where multiple query parameters or HTTP headers are required to convey security information.When a list of Security Requirement Objects is defined on the OpenAPI Object or Operation Object,only one of the Security Requirement Objects in the list needs to be satisfied to authorize the request.

https://spec.openapis.org/oas/v3.1.1#security-requirement-object

Example:

api_key: []

typeSecurityRequirementBuilder

type SecurityRequirementBuilder struct {// contains filtered or unexported fields}

funcNewSecurityRequirementBuilder

func NewSecurityRequirementBuilder() *SecurityRequirementBuilder

func (*SecurityRequirementBuilder)Add

func (*SecurityRequirementBuilder)Build

typeSecurityScheme

type SecurityScheme struct {// REQUIRED.// The type of the security scheme.// Valid values are "apiKey", "http", "mutualTLS", "oauth2", "openIdConnect".//// Applies To: anyTypestring `json:"type" yaml:"type"`// A description for security scheme.// CommonMark syntax MAY be used for rich text representation.//// Applies To: anyDescriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// REQUIRED.// The name of the header, query or cookie parameter to be used.//// Applies To: apiKeyNamestring `json:"name,omitempty" yaml:"name,omitempty"`// REQUIRED.// The location of the API key.// Valid values are "query", "header" or "cookie".//// Applies To: apiKeyInstring `json:"in,omitempty" yaml:"in,omitempty"`// REQUIRED.// The name of the HTTP Authorization scheme to be used in the Authorization header as defined in [RFC7235].// The values used SHOULD be registered in the IANA Authentication Scheme registry.//// Applies To: httpSchemestring `json:"scheme,omitempty" yaml:"scheme,omitempty"`// A hint to the client to identify how the bearer token is formatted.// Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes.//// Applies To: http ("bearer")BearerFormatstring `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"`// REQUIRED.// An object containing configuration information for the flow types supported.//// Applies To: oauth2Flows *Extendable[OAuthFlows] `json:"flows,omitempty" yaml:"flows,omitempty"`// REQUIRED.// OpenId Connect URL to discover OAuth2 configuration values.// This MUST be in the form of a URL.// The OpenID Connect standard requires the use of TLS.//// Applies To: openIdConnectOpenIDConnectURLstring `json:"openIdConnectUrl,omitempty" yaml:"openIdConnectUrl,omitempty"`}

SecurityScheme defines a security scheme that can be used by the operations.Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter),mutual TLS (use of a client certificate), OAuth2’s common flows (implicit, password, client credentials and authorization code)as defined in [RFC6749], and OpenID Connect Discovery.Please note that as of 2020, the implicit flow is about to be deprecated by OAuth 2.0 Security Best Current Practice.Recommended for most use case is Authorization Code Grant flow with PKCE.

https://spec.openapis.org/oas/v3.1.1#security-scheme-object

Example:

type: oauth2flows:  implicit:    authorizationUrl: https://example.com/api/oauth/dialog    scopes:      write:pets: modify pets in your account      read:pets: read your pets

typeSecuritySchemeBuilder

type SecuritySchemeBuilder struct {// contains filtered or unexported fields}

funcNewSecuritySchemeBuilder

func NewSecuritySchemeBuilder() *SecuritySchemeBuilder

func (*SecuritySchemeBuilder)AddExt

func (*SecuritySchemeBuilder)BearerFormat

func (*SecuritySchemeBuilder)Build

func (*SecuritySchemeBuilder)Description

func (*SecuritySchemeBuilder)Extensions

func (*SecuritySchemeBuilder)Flows

func (*SecuritySchemeBuilder)In

func (*SecuritySchemeBuilder)Name

func (*SecuritySchemeBuilder)OpenIDConnectURL

func (b *SecuritySchemeBuilder) OpenIDConnectURL(vstring) *SecuritySchemeBuilder

func (*SecuritySchemeBuilder)Scheme

func (*SecuritySchemeBuilder)Type

typeServer

type Server struct {// A map between a variable name and its value.// The value is used for substitution in the server’s URL template.Variables map[string]*Extendable[ServerVariable] `json:"variables,omitempty" yaml:"variables,omitempty"`// REQUIRED.// A URL to the target host.// This URL supports Server Variables and MAY be relative, to indicate that the host location is relative// to the location where the OpenAPI document is being served.// Variable substitutions will be made when a variable is named in {brackets}.URLstring `json:"url" yaml:"url"`// An optional string describing the host designated by the URL.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`}

Server is an object representing a Server.

https://spec.openapis.org/oas/v3.1.1#server-object

Example:

servers:- url: https://development.gigantic-server.com/v1  description: Development server- url: https://staging.gigantic-server.com/v1  description: Staging server- url: https://api.gigantic-server.com/v1  description: Production server

typeServerBuilder

type ServerBuilder struct {// contains filtered or unexported fields}

funcNewServerBuilder

func NewServerBuilder() *ServerBuilder

func (*ServerBuilder)AddExt

func (b *ServerBuilder) AddExt(namestring, valueany) *ServerBuilder

func (*ServerBuilder)AddVariable

func (b *ServerBuilder) AddVariable(namestring, value *Extendable[ServerVariable]) *ServerBuilder

func (*ServerBuilder)Build

func (b *ServerBuilder) Build() *Extendable[Server]

func (*ServerBuilder)Description

func (b *ServerBuilder) Description(vstring) *ServerBuilder

func (*ServerBuilder)Extensions

func (b *ServerBuilder) Extensions(v map[string]any) *ServerBuilder

func (*ServerBuilder)URL

func (*ServerBuilder)Variables

typeServerVariable

type ServerVariable struct {// REQUIRED.// The default value to use for substitution, which SHALL be sent if an alternate value is not supplied.// Note this behavior is different than the Schema Object’s treatment of default values,// because in those cases parameter values are optional.// If the enum is defined, the value MUST exist in the enum’s values.Defaultstring `json:"default" yaml:"default"`// An optional description for the server variable.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`// An enumeration of string values to be used if the substitution options are from a limited set.// The array MUST NOT be empty.Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"`}

ServerVariable is an object representing a Server Variable for server URL template substitution.

https://spec.openapis.org/oas/v3.1.1#server-variable-object

typeServerVariableBuilder

type ServerVariableBuilder struct {// contains filtered or unexported fields}

funcNewServerVariableBuilder

func NewServerVariableBuilder() *ServerVariableBuilder

func (*ServerVariableBuilder)AddEnum

func (*ServerVariableBuilder)AddExt

func (*ServerVariableBuilder)Build

func (*ServerVariableBuilder)Default

func (*ServerVariableBuilder)Description

func (*ServerVariableBuilder)Enum

func (*ServerVariableBuilder)Extensions

typeSingleOrArray

type SingleOrArray[Tany] []T

SingleOrArray holds list or single value

funcNewSingleOrArray

func NewSingleOrArray[Tany](v ...T) *SingleOrArray[T]

NewSingleOrArray creates SingleOrArray object.

func (*SingleOrArray[T])Add

func (o *SingleOrArray[T]) Add(v ...T) *SingleOrArray[T]

func (*SingleOrArray[T])MarshalJSON

func (o *SingleOrArray[T]) MarshalJSON() ([]byte,error)

MarshalJSON implements json.Marshaler interface.

func (*SingleOrArray[T])MarshalYAML

func (o *SingleOrArray[T]) MarshalYAML() (any,error)

MarshalYAML implements yaml.Marshaler interface.

func (*SingleOrArray[T])UnmarshalJSON

func (o *SingleOrArray[T]) UnmarshalJSON(data []byte)error

UnmarshalJSON implements json.Unmarshaler interface.

func (*SingleOrArray[T])UnmarshalYAML

func (o *SingleOrArray[T]) UnmarshalYAML(node *yaml.Node)error

UnmarshalYAML implements yaml.Unmarshaler interface.

typeSpecNotFoundError

type SpecNotFoundError struct {// contains filtered or unexported fields}

func (*SpecNotFoundError)Error

func (e *SpecNotFoundError) Error()string

func (*SpecNotFoundError)Is

func (e *SpecNotFoundError) Is(targeterror)bool

typeTag

type Tag struct {// Additional external documentation for this tag.ExternalDocs *Extendable[ExternalDocs] `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`// REQUIRED.// The name of the tag.Namestring `json:"name" yaml:"name"`// A description for the tag.// CommonMark syntax MAY be used for rich text representation.Descriptionstring `json:"description,omitempty" yaml:"description,omitempty"`}

Tag adds metadata to a single tag that is used by the Operation Object.It is not mandatory to have a Tag Object per tag defined in the Operation Object instances.

https://spec.openapis.org/oas/v3.1.1#tag-object

Example:

name: petdescription: Pets operations

typeTagBuilder

type TagBuilder struct {// contains filtered or unexported fields}

funcNewTagBuilder

func NewTagBuilder() *TagBuilder

func (*TagBuilder)AddExt

func (b *TagBuilder) AddExt(namestring, valueany) *TagBuilder

func (*TagBuilder)Build

func (b *TagBuilder) Build() *Extendable[Tag]

func (*TagBuilder)Description

func (b *TagBuilder) Description(vstring) *TagBuilder

func (*TagBuilder)Extensions

func (b *TagBuilder) Extensions(v map[string]any) *TagBuilder

func (*TagBuilder)ExternalDocs

func (b *TagBuilder) ExternalDocs(v *Extendable[ExternalDocs]) *TagBuilder

func (*TagBuilder)Name

func (b *TagBuilder) Name(vstring) *TagBuilder

typeUnsupportedSpecTypeError

type UnsupportedSpecTypeErrorstring

func (UnsupportedSpecTypeError)Error

func (UnsupportedSpecTypeError)Is

typeUnsupportedTypeError

type UnsupportedTypeErrorstring

func (UnsupportedTypeError)Error

func (UnsupportedTypeError)Is

typeUnsupportedVersionError

type UnsupportedVersionErrorstring

func (UnsupportedVersionError)Error

func (UnsupportedVersionError)Is

typeValidationOption

type ValidationOption func(*validationOptions)

ValidationOption is a type for validation options.

funcAllowExtensionNameWithoutPrefix

func AllowExtensionNameWithoutPrefix()ValidationOption

AllowExtensionNameWithoutPrefix is a validation option to allow extension name without `x-` prefix.

funcAllowRequestBodyForDelete

func AllowRequestBodyForDelete()ValidationOption

AllowRequestBodyForDelete is a validation option to allow request body for DELETE operation.

funcAllowRequestBodyForGet

func AllowRequestBodyForGet()ValidationOption

AllowRequestBodyForGet is a validation option to allow request body for GET operation.

funcAllowRequestBodyForHead

func AllowRequestBodyForHead()ValidationOption

AllowRequestBodyForHead is a validation option to allow request body for HEAD operation.

funcAllowUndefinedTagsInOperation

func AllowUndefinedTagsInOperation()ValidationOption

AllowUndefinedTagsInOperation is a validation option to allow undefined tags in operation.

funcAllowUnusedComponents

func AllowUnusedComponents()ValidationOption

AllowUnusedComponents is a validation option to allow unused components.

funcDoNotValidateDefaultValues

func DoNotValidateDefaultValues()ValidationOption

DoNotValidateDefaultValues is a validation option to skip default values validation.

funcDoNotValidateExamples

func DoNotValidateExamples()ValidationOption

DoNotValidateExamples is a validation option to skip examples validation.

funcUpdateCompiler

func UpdateCompiler(f func(*jsonschema.Compiler))ValidationOption

UpdateCompiler is a type to modify the jsonschema.Compiler.

funcValidateStringDataAsJSON

func ValidateStringDataAsJSON()ValidationOption

typeValidator

type Validator struct {// contains filtered or unexported fields}

Validator is a struct for validating the OpenAPI specification and a data.

funcNewValidator

func NewValidator(spec *Extendable[OpenAPI], opts ...ValidationOption) (*Validator,error)

NewValidator creates an instance of Validator struct.

The function creates new jsonschema comppiler and adds the given spec to the compiler.

func (*Validator)ValidateData

func (v *Validator) ValidateData(locationstring, valueany)error

ValidateData validates the given value against the schema located at the given location.

The location should be in form of JSON Pointer.The value can be a struct, a string containing JSON, or any other types.If the value is a struct, it will be marshaled and unmarshaled to JSON.

func (*Validator)ValidateDataAsJSON

func (v *Validator) ValidateDataAsJSON(locationstring, valueany)error

ValidateDataAsJSON marshal and unmarshals the given value to JSON andvalidates it against the schema located at the given location.

If the value is a string, it will be unmarshaled to JSON first, if failed it will be kept as is.

func (*Validator)ValidateSpec

func (v *Validator) ValidateSpec()error

ValidateSpec validates the specification.

typeWebhooks

type Webhooks = map[string]*RefOrSpec[Extendable[PathItem]]

funcNewWebhooks

func NewWebhooks()Webhooks

typeXML

type XML struct {// Replaces the name of the element/attribute used for the described schema property.// When defined within items, it will affect the name of the individual XML elements within the list.// When defined alongside type being array (outside the items), it will affect the wrapping element and only if wrapped is true.// If wrapped is false, it will be ignored.Namestring `json:"name,omitempty" yaml:"name,omitempty"`// The URI of the namespace definition.// This MUST be in the form of an absolute URI.Namespacestring `json:"namespace,omitempty" yaml:"namespace,omitempty"`// The prefix to be used for the name.Prefixstring `json:"prefix,omitempty" yaml:"prefix,omitempty"`// Declares whether the property definition translates to an attribute instead of an element. Default value is false.Attributebool `json:"attribute,omitempty" yaml:"attribute,omitempty"`// MAY be used only for an array definition.// Signifies whether the array is wrapped (for example, <books><book/><book/></books>) or unwrapped (<book/><book/>).// Default value is false.// The definition takes effect only when defined alongside type being array (outside the items).Wrappedbool `json:"wrapped,omitempty" yaml:"wrapped,omitempty"`}

XML is a metadata object that allows for more fine-tuned XML model definitions.When using arrays, XML element names are not inferred (for singular/plural forms) and the name property SHOULDbe used to add that information.See examples for expected behavior.

https://spec.openapis.org/oas/v3.1.1#xml-object

Example:

Person:  type: object  properties:    id:      type: integer      format: int32      xml:        attribute: true    name:      type: string      xml:        namespace: https://example.com/schema/sample        prefix: sample<Person id="123">    <sample:name xmlns:sample="https://example.com/schema/sample">example</sample:name></Person>

typeXMLBuilder

type XMLBuilder struct {// contains filtered or unexported fields}

funcNewXMLBuilder

func NewXMLBuilder() *XMLBuilder

func (*XMLBuilder)AddExt

func (b *XMLBuilder) AddExt(namestring, valueany) *XMLBuilder

func (*XMLBuilder)Attribute

func (b *XMLBuilder) Attribute(vbool) *XMLBuilder

func (*XMLBuilder)Build

func (b *XMLBuilder) Build() *Extendable[XML]

func (*XMLBuilder)Extensions

func (b *XMLBuilder) Extensions(v map[string]any) *XMLBuilder

func (*XMLBuilder)Name

func (b *XMLBuilder) Name(vstring) *XMLBuilder

func (*XMLBuilder)Namespace

func (b *XMLBuilder) Namespace(vstring) *XMLBuilder

func (*XMLBuilder)Prefix

func (b *XMLBuilder) Prefix(vstring) *XMLBuilder

func (*XMLBuilder)Wrapped

func (b *XMLBuilder) Wrapped(vbool) *XMLBuilder

Source Files

View all Source files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f orF : Jump to
y orY : Canonical URL
go.dev uses cookies from Google to deliver and enhance the quality of its services and to analyze traffic.Learn more.

[8]ページ先頭

©2009-2025 Movatter.jp