spec

package module
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

spec3 — OpenAPI 3 Go Object Model

Go Reference

Go structs and JSON serialization for the OpenAPI Specification 3.2.0 (backward-compatible with 3.0 and 3.1).


Features

  • Complete object model for every OAS 3.2.0 object
  • Correct JSON marshaling (including $ref, x- extensions, and dollar-sign keys like $self)
  • OrderedMap preserves insertion order for deterministic JSON output
  • Typed constants for Style, ParameterIn, and SecuritySchemeType
  • easyjson codegen for hot-path objects (Info, Server, Tag, Contact, License, ExternalDocumentation)

Installation

go get github.com/shuttlefy/go-openapi3-spec

Quick Start

package main

import (
    "encoding/json"
    "fmt"
    "github.com/shuttlefy/go-openapi3-spec"
)

func main() {
    doc := &spec3.OpenAPI{
        OpenAPI: "3.2.0",
        Self:    "https://api.example.com/openapi.json",
        Info: &spec3.Info{
            Title:   "Pet Store",
            Version: "1.0.0",
        },
        Servers: []spec3.Server{
            {URL: "https://api.example.com/v1", Name: strPtr("production")},
        },
    }

    b, _ := json.MarshalIndent(doc, "", "  ")
    fmt.Println(string(b))
}

func strPtr(s string) *string { return &s }

Object Coverage

Root
Go Type OAS Object Notes
OpenAPI OpenAPI Object $self (3.2), jsonSchemaDialect (3.1+), webhooks (3.1+)
Info Info Object summary (3.1+)
Server Server Object name (3.2)
ServerVariable Server Variable Object
ExternalDocumentation External Documentation Object
Tag Tag Object summary, parent, kind (3.2)
Path & Operation
Go Type OAS Object Notes
Paths Paths Object
PathItem Path Item Object query operation (3.2), additionalOperations (3.2)
Operation Operation Object
Parameter Parameter Object in: querystring (3.2)
RequestBody Request Body Object
Response Response Object
Responses Responses Object wildcards 1XX5XX, full IANA code list
Encoding Encoding Object
MediaType Media Type Object itemSchema, itemEncoding, prefixEncoding (3.2)
Header Header Object
Link Link Object
Callback Callback Object
Schema & Vocabulary
Go Type OAS Object Notes
Schema Schema Object Full JSON Schema vocabulary
Discriminator Discriminator Object defaultMapping (3.2)
XML XML Object nodeType (3.2)
Example Example Object dataValue, serializedValue (3.2)
Security
Go Type OAS Object Notes
SecurityScheme Security Scheme Object mutualTLS (3.2), oauth2MetadataUrl, deprecated (3.2)
OAuthFlows OAuth Flows Object deviceAuthorization flow (3.2)
OAuthFlow OAuth Flow Object deviceAuthorizationUrl (3.2)
SecurityRequirement Security Requirement Object
Components
Go Type OAS Object Notes
Components Components Object pathItems (3.1+), mediaTypes (3.2)

Constants

// Parameter serialization styles
spec3.StyleMatrix         // path
spec3.StyleLabel          // path
spec3.StyleSimple         // path, header
spec3.StyleForm           // query, cookie
spec3.StyleSpaceDelimited // query
spec3.StylePipeDelimited  // query
spec3.StyleDeepObject     // query
spec3.StyleCookie         // cookie (OAS 3.2)

// Parameter locations
spec3.ParameterInPath        // "path"
spec3.ParameterInQuery       // "query"
spec3.ParameterInQueryString // "querystring" — OAS 3.2
spec3.ParameterInHeader      // "header"
spec3.ParameterInCookie      // "cookie"

// Security scheme types
spec3.SecuritySchemeTypeAPIKey        // "apiKey"
spec3.SecuritySchemeTypeHTTP          // "http"
spec3.SecuritySchemeTypeMutualTLS     // "mutualTLS" — OAS 3.2
spec3.SecuritySchemeTypeOAuth2        // "oauth2"
spec3.SecuritySchemeTypeOpenIDConnect // "openIdConnect"

OrderedMap

Map-like fields (e.g., Properties, Paths, SecuritySchemes) use OrderedMap to guarantee that JSON output preserves the order in which keys were inserted — important for human-readable documents and golden-file tests.

// Add a schema property
schema.Properties.Set("name", &spec3.Schema{Type: "string"})
schema.Properties.Set("age",  &spec3.Schema{Type: "integer", Format: "int32"})

// Iterate in insertion order
for _, entry := range schema.Properties.Entries() {
    fmt.Println(entry.Key, entry.Value)
}

Vendor extensions (x-*) are stored in a separate VendorExtensible embedded struct, also backed by OrderedMap with a prefix filter.


OAS 3.2.0 Changes at a Glance

Feature Field Type
Document self-URI OpenAPI.Self$self string
Server display name Server.Name *string
Tag hierarchy Tag.Parent, Tag.Kind, Tag.Summary string
Full query string param Parameter.In = "querystring" ParameterIn
Cookie serialization style StyleCookie constant Style
Schema-ready example value Example.DataValue interface{}
Wire-format example value Example.SerializedValue string
Discriminator fallback Discriminator.DefaultMapping string
XML DOM node type XML.NodeType string
Client-cert auth SecuritySchemeTypeMutualTLS SecuritySchemeType
OAuth metadata URL SecurityScheme.OAuth2MetadataURL string
Deprecated security scheme SecurityScheme.Deprecated bool
Device auth flow OAuthFlows.DeviceAuthorization OAuthFlow
Device auth URL OAuthFlow.DeviceAuthorizationURL string
Streaming item type MediaType.ItemSchema *Schema
Streaming item encoding MediaType.ItemEncoding *Encoding
Streaming prefix encoding MediaType.PrefixEncoding []Encoding
Reusable path items Components.PathItems *OrderedPathItems
Reusable media types Components.MediaTypes *OrderedMediaTypes
Wildcard response ranges "1XX""5XX" in Responses string keys

Examples

The examples/ directory contains reference documents:

File Description
openapi-full.json Hand-crafted reference covering every OAS 3.2.0 object
openapi-generated.json Auto-generated by TestOpenAPI_GenerateDocument
openapi-complete.json Compact working example

Code Generation

Several hot-path types use easyjson for faster marshaling. Regenerate after modifying the corresponding structs:

go generate ./...

Testing

go test ./...

TestFullJSON_* tests validate examples/openapi-full.json against all OAS 3.2.0 coverage requirements, including every new field introduced in 3.2.


Specification References

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LowerCaseKeys = strings.ToLower

LowerCaseKeys lowercases keys when looking up in the map

Functions

func MarshalYAML

func MarshalYAML(v interface{}) ([]byte, error)

MarshalYAML serializes v to YAML. It first marshals v to JSON (honouring all custom MarshalJSON implementations and `json` struct tags), converts the JSON-decoded value to a YAML node, and emits YAML bytes.

func MatchAll

func MatchAll(_ string) bool

MatchAll keys, is used as default filter

func MatchExtension

func MatchExtension(key string) bool

MatchExtension is used as filter for vendor extensions

func MatchNonEmptyKeys

func MatchNonEmptyKeys(key string) bool

MatchNonEmptyKeys keys, is used to allow only non empty strings

func NOPNormalizer

func NOPNormalizer(s string) string

NOPNormalizer passes the key through, used as default

func UnmarshalYAML

func UnmarshalYAML(data []byte, v interface{}) error

UnmarshalYAML parses YAML data into v. It first decodes the YAML into a generic structure, converts it to JSON, and then unmarshals the JSON into v, so all custom UnmarshalJSON implementations and `json` struct tags are respected.

Types

type Callback

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

Callback is a map of possible out-of-band callbacks. Key is an expression, value is a Path Item Object. See https://spec.openapis.org/oas/v3.2.0.html#callback-object Each value in the map is a Path Item Object that describes a set of requests that may be initiated by the API provider and the expected responses. The key value used to identify the callback object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.

func NewCallback

func NewCallback() Callback

NewCallback creates a new instance of Callback with correct filter

func (*Callback) ForEach

func (s *Callback) ForEach(fn func(string, *PathItem) error) error

ForEach executes the function for each security requirement

func (*Callback) Get

func (s *Callback) Get(key string) *PathItem

Get gets the security requirement by key

func (*Callback) GetOK

func (s *Callback) GetOK(key string) (*PathItem, bool)

GetOK checks if the key exists in the security requirement

func (*Callback) Keys

func (s *Callback) Keys() []string

Keys gets the list of keys

func (Callback) MarshalEasyJSON

func (s Callback) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON implements easyjson.Marshaler.

func (Callback) MarshalJSON

func (s Callback) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*Callback) Set

func (s *Callback) Set(key string, val *PathItem) bool

Set sets the value to the security requirement

func (*Callback) UnmarshalEasyJSON

func (s *Callback) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON implements easyjson.Unmarshaler.

func (*Callback) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler.

type Components

type Components struct {
	VendorExtensible

	Schemas         OrderedSchemas         `json:"schemas,omitempty"`
	Responses       OrderedResponses       `json:"responses,omitempty"`
	Parameters      OrderedParameters      `json:"parameters,omitempty"`
	Examples        OrderedExamples        `json:"examples,omitempty"`
	RequestBodies   OrderedRequestBodies   `json:"requestBodies,omitempty"`
	Headers         OrderedHeaders         `json:"headers,omitempty"`
	SecuritySchemes OrderedSecuritySchemes `json:"securitySchemes,omitempty"`
	Links           OrderedLinks           `json:"links,omitempty"`
	Callbacks       OrderedCallbacks       `json:"callbacks,omitempty"`
	// PathItems (OAS 3.1) holds reusable Path Item Objects. Keys MUST match ^[a-zA-Z0-9.\-_]+$
	PathItems *OrderedPathItems `json:"pathItems,omitempty"`
	// MediaTypes (OAS 3.2) holds reusable Media Type Objects. Keys MUST match ^[a-zA-Z0-9.\-_]+$
	MediaTypes *OrderedMediaTypes `json:"mediaTypes,omitempty"`
}

Components holds a set of reusable objects for different aspects of the OAS. See https://spec.openapis.org/oas/v3.2.0.html#components-object

func (*Components) MarshalJSON

func (c *Components) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler so Components serializes all fields (not only VendorExtensible).

type Contact

type Contact struct {
	VendorExtensible
	Name  string `json:"name,omitempty"`
	URL   string `json:"url,omitempty"`   // MUST be a URL.
	Email string `json:"email,omitempty"` // MUST be an email address.
}

Contact contains information for the exposed API. See https://spec.openapis.org/oas/v3.2.0.html#contact-object

func (Contact) MarshalEasyJSON

func (v Contact) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Contact) MarshalJSON

func (v Contact) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Contact) UnmarshalEasyJSON

func (v *Contact) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Contact) UnmarshalJSON

func (v *Contact) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Discriminator

type Discriminator struct {
	PropertyName string         `json:"propertyName"`
	Mapping      OrderedStrings `json:"mapping,omitempty"`
	// DefaultMapping (OAS 3.2) specifies the schema used when the discriminating property
	// is absent or has no explicit/implicit mapping. Required when propertyName is optional.
	DefaultMapping string `json:"defaultMapping,omitempty"`
}

Discriminator 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 specification of an alternative schema based on the value associated with it.

type Encoding

type Encoding struct {
	VendorExtensible

	ContentType    string            `json:"contentType,omitempty"`
	Headers        OrderedHeaders    `json:"headers,omitempty"`
	Style          string            `json:"style,omitempty"`
	Explode        bool              `json:"explode,omitempty"`
	AllowReserved  bool              `json:"allowReserved,omitempty"`
	Encoding       *OrderedEncodings `json:"encoding,omitempty"`
	PrefixEncoding []Encoding        `json:"prefixEncoding,omitempty"`
	ItemEncoding   *Encoding         `json:"itemEncoding,omitempty"`
}

Encoding definition applied to a single schema property.

type Example

type Example struct {
	VendorExtensible
	Reference

	Summary     *string `json:"summary,omitempty"`
	Description *string `json:"description,omitempty"`

	// DataValue (OAS 3.2) holds the schema-ready data form of the example.
	// Mutually exclusive with Value and SerializedValue.
	DataValue interface{} `json:"dataValue,omitempty"`

	// SerializedValue (OAS 3.2) holds the serialized (wire) form of the example value.
	// SHOULD NOT be used if the serialization format is JSON.
	// Mutually exclusive with Value and ExternalValue.
	SerializedValue string `json:"serializedValue,omitempty"`

	// ExternalValue identifies the serialized example in a separate document.
	// Mutually exclusive with SerializedValue and Value.
	ExternalValue string `json:"externalValue,omitempty"`

	// Value is the embedded literal example.
	// Deprecated for non-JSON serialization targets: use DataValue / SerializedValue instead.
	Value interface{} `json:"value,omitempty"`
}

Example https://spec.openapis.org/oas/v3.2.0.html#example-object

func (*Example) MarshalJSON

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

MarshalJSON implements json.Marshaler for Example.

type Extensions

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

Extensions vendor specific extensions

func (*Extensions) Add

func (e *Extensions) Add(key string, value interface{})

Add adds a value to these extensions.

func (*Extensions) Get

func (e *Extensions) Get(key string) interface{}

func (*Extensions) GetBool

func (e *Extensions) GetBool(key string) (bool, bool)

GetBool gets a boolean value from the extensions

func (*Extensions) GetInt

func (e *Extensions) GetInt(key string) (int, bool)

GetInt gets an int value from the extensions

func (*Extensions) GetInt32

func (e *Extensions) GetInt32(key string) (int32, bool)

GetInt32 gets an int32 value from the extensions

func (*Extensions) GetInt64

func (e *Extensions) GetInt64(key string) (int64, bool)

GetInt64 gets an int64 value from the extensions

func (*Extensions) GetOK

func (e *Extensions) GetOK(key string) (interface{}, bool)

func (*Extensions) GetString

func (e *Extensions) GetString(key string) (string, bool)

GetString gets a string value from the extensions

func (*Extensions) GetStringSlice

func (e *Extensions) GetStringSlice(key string) ([]string, bool)

GetStringSlice gets a string slice value from the extensions

func (Extensions) MarshalEasyJSON

func (e Extensions) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Extensions) MarshalJSON

func (e Extensions) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Extensions) Set

func (e *Extensions) Set(key string, value interface{}) bool

Set adds or updates a vendor extension. Key must begin with "x-". Uses pointer receiver so mutations persist in the caller's Extensions field.

func (*Extensions) UnmarshalEasyJSON

func (e *Extensions) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Extensions) UnmarshalJSON

func (e *Extensions) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ExternalDocumentation

type ExternalDocumentation struct {
	VendorExtensible
	Description string `json:"description,omitempty"`
	URL         string `json:"url,omitempty"` // MUST be a URL.
}

ExternalDocumentation allows referencing an external resource for extended documentation. See https://spec.openapis.org/oas/v3.2.0.html#external-documentation-object

easyjson:json

func (ExternalDocumentation) MarshalEasyJSON

func (v ExternalDocumentation) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ExternalDocumentation) MarshalJSON

func (v ExternalDocumentation) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ExternalDocumentation) UnmarshalEasyJSON

func (v *ExternalDocumentation) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ExternalDocumentation) UnmarshalJSON

func (v *ExternalDocumentation) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Filter

type Filter func(string) bool

Filter for deciding which keys make it into the sorted map

type Header struct {
	Parameter
}

Header follows the structure of the Parameter Object

type Info

type Info struct {
	VendorExtensible

	Title          string   `json:"title"`                    // REQUIRED.
	Summary        string   `json:"summary,omitempty"`        // OAS 3.1: short summary.
	Description    string   `json:"description,omitempty"`    // CommonMark allowed.
	TermsOfService string   `json:"termsOfService,omitempty"` // MUST be a URL.
	Contact        *Contact `json:"contact,omitempty"`
	License        *License `json:"license,omitempty"`
	Version        string   `json:"version"` // REQUIRED. Document version (distinct from OAS version).
}

Info provides metadata about the API. See https://spec.openapis.org/oas/v3.2.0.html#info-object

easyjson:json

func (Info) MarshalEasyJSON

func (v Info) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Info) MarshalJSON

func (v Info) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Info) UnmarshalEasyJSON

func (v *Info) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Info) UnmarshalJSON

func (v *Info) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type License

type License struct {
	VendorExtensible
	Name       string `json:"name"`                 // REQUIRED.
	Identifier string `json:"identifier,omitempty"` // OAS 3.1: SPDX expression; mutually exclusive with url.
	URL        string `json:"url,omitempty"`        // Mutually exclusive with identifier.
}

License contains information for the exposed API. See https://spec.openapis.org/oas/v3.2.0.html#license-object

easyjson:json

func (License) MarshalEasyJSON

func (v License) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (License) MarshalJSON

func (v License) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*License) UnmarshalEasyJSON

func (v *License) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*License) UnmarshalJSON

func (v *License) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Link struct {
	VendorExtensible
	Reference

	OperationRef string                 `json:"operationRef,omitempty"`
	OperationID  string                 `json:"operationId,omitempty"`
	Parameters   map[string]interface{} `json:"parameters,omitempty"`
	RequestBody  interface{}            `json:"requestBody,omitempty"`
	Description  *string                `json:"description,omitempty"`
	Server       Server                 `json:"server,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.

type MapEntry

type MapEntry struct {
	Key   string
	Value interface{}
}

MapEntry represents a key value pair

type MediaType

type MediaType struct {
	VendorExtensible
	Reference

	Schema         *Schema          `json:"schema,omitempty"`
	ItemSchema     *Schema          `json:"itemSchema,omitempty"`
	Example        interface{}      `json:"example,omitempty"`
	Examples       OrderedExamples  `json:"examples,omitempty"`
	Encoding       OrderedEncodings `json:"encoding,omitempty"`
	PrefixEncoding []Encoding       `json:"prefixEncoding,omitempty"`
	// ItemEncoding (OAS 3.2) single Encoding Object for streaming multipart content (itemEncoding field).
	ItemEncoding *Encoding `json:"itemEncoding,omitempty"`
}

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

func (*MediaType) MarshalJSON

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

MarshalJSON implements json.Marshaler. Emits {"$ref":"..."} when a ref is set, otherwise emits all non-empty fields as a JSON object. Ensures MediaType never serializes as null even when all fields are zero-valued.

type Normalizer

type Normalizer func(string) string

Normalizer is used to normalize keys when writing to a map

type OAuthFlow

type OAuthFlow struct {
	VendorExtensible

	AuthorizationURL string `json:"authorizationUrl,omitempty"`
	// DeviceAuthorizationURL (OAS 3.2) is required for the deviceAuthorization flow.
	DeviceAuthorizationURL string         `json:"deviceAuthorizationUrl,omitempty"`
	TokenURL               string         `json:"tokenUrl,omitempty"`
	RefreshURL             string         `json:"refreshUrl,omitempty"`
	Scopes                 OrderedStrings `json:"scopes,omitempty"`
}

OAuthFlow configuration details for a supported OAuth Flow

func (OAuthFlow) MarshalJSON

func (f OAuthFlow) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OAuthFlow.

type OAuthFlows

type OAuthFlows struct {
	VendorExtensible

	Implicit            OAuthFlow `json:"implicit,omitempty"`
	Password            OAuthFlow `json:"password,omitempty"`
	ClientCredentials   OAuthFlow `json:"clientCredentials,omitempty"`
	AuthorizationCode   OAuthFlow `json:"authorizationCode,omitempty"`
	DeviceAuthorization OAuthFlow `json:"deviceAuthorization,omitempty"` // OAS 3.2
}

OAuthFlows allows configuration of the supported OAuth Flows.

func (OAuthFlows) MarshalJSON

func (f OAuthFlows) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OAuthFlows.

type OpenAPI

type OpenAPI struct {
	VendorExtensible

	Components   *Components            `json:"components,omitempty"`
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
	Info         *Info                  `json:"info,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 info.version string, which describes the OpenAPI document’s version.
	*/
	OpenAPI           string                `json:"openapi"`
	Self              string                `json:"$self,omitempty"`             // OAS 3.2: self-assigned URI of this document.
	JsonSchemaDialect string                `json:"jsonSchemaDialect,omitempty"` // OAS 3.1+: default $schema for Schema Objects.
	Servers           []Server              `json:"servers,omitempty"`
	Paths             *Paths                `json:"paths,omitempty"`
	Webhooks          *OrderedPathItems     `json:"webhooks,omitempty"` // OAS 3.1+
	Security          []SecurityRequirement `json:"security,omitempty"`
	Tags              []Tag                 `json:"tags,omitempty"`
}

OpenAPI is the root document object of the OpenAPI document

func (*OpenAPI) MarshalJSON

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

MarshalJSON implements json.Marshaler so the root document serializes all fields. Without this, the embedded VendorExtensible.MarshalJSON would be used and only extensions would be emitted.

func (*OpenAPI) UnmarshalJSON

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

UnmarshalJSON implements json.Unmarshaler. It decodes both the regular OpenAPI fields and any vendor extensions from the same JSON object.

type Operation

type Operation struct {
	VendorExtensible

	Tags         []string              `json:"tags,omitempty"`
	Summary      *string               `json:"summary,omitempty"`
	Description  *string               `json:"description,omitempty"`
	ExternalDocs ExternalDocumentation `json:"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.
	*/
	OperationID string           `json:"operationId,omitempty"`
	Parameters  []Parameter      `json:"parameters,omitempty"`
	RequestBody RequestBody      `json:"requestBody,omitempty"`
	Responses   OrderedResponses `json:"responses,omitempty"`
	// Callbacks is a map of callback name → Callback Object (each Callback is itself a map of
	// runtime expression → Path Item Object). Type was previously *Callback which is incorrect
	// per the spec: the Operation field is Map[string, Callback | Reference], not a single Callback.
	Callbacks  *OrderedCallbacks     `json:"callbacks,omitempty"`
	Deprecated bool                  `json:"deprecated,omitempty"`
	Security   []SecurityRequirement `json:"security,omitempty"`
	Servers    []Server              `json:"servers,omitempty"`
}

Operation describes a single API operation on a path.

func (*Operation) MarshalJSON

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

MarshalJSON implements json.Marshaler so the operation serializes all fields (not only VendorExtensible).

type OrderedCallbacks

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

OrderedCallbacks is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedCallbacks

func NewOrderedCallbacks() OrderedCallbacks

NewOrderedCallbacks creates a new instance of OrderedCallbacks with correct filter

func (*OrderedCallbacks) ForEach

func (s *OrderedCallbacks) ForEach(fn func(string, *Callback) error) error

ForEach executes the function for each security requirement

func (*OrderedCallbacks) Get

func (s *OrderedCallbacks) Get(key string) *Callback

Get gets the security requirement by key

func (*OrderedCallbacks) GetOK

func (s *OrderedCallbacks) GetOK(key string) (*Callback, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedCallbacks) Keys

func (s *OrderedCallbacks) Keys() []string

Keys gets the list of keys

func (*OrderedCallbacks) Set

func (s *OrderedCallbacks) Set(key string, val *Callback) bool

Set sets the value to the security requirement

type OrderedEncodings

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

OrderedEncodings is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedEncodings

func NewOrderedEncodings() OrderedEncodings

NewOrderedEncodings creates a new instance of OrderedEncodings with correct filter

func (*OrderedEncodings) ForEach

func (s *OrderedEncodings) ForEach(fn func(string, *Encoding) error) error

ForEach executes the function for each security requirement

func (*OrderedEncodings) Get

func (s *OrderedEncodings) Get(key string) *Encoding

Get gets the security requirement by key

func (*OrderedEncodings) GetOK

func (s *OrderedEncodings) GetOK(key string) (*Encoding, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedEncodings) Keys

func (s *OrderedEncodings) Keys() []string

Keys gets the list of keys

func (*OrderedEncodings) Set

func (s *OrderedEncodings) Set(key string, val *Encoding) bool

Set sets the value to the security requirement

type OrderedExamples

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

OrderedExamples is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedExamples

func NewOrderedExamples() OrderedExamples

NewOrderedExamples creates a new instance of OrderedExamples with correct filter

func (*OrderedExamples) ForEach

func (s *OrderedExamples) ForEach(fn func(string, *Example) error) error

ForEach executes the function for each security requirement

func (*OrderedExamples) Get

func (s *OrderedExamples) Get(key string) *Example

Get gets the security requirement by key

func (*OrderedExamples) GetOK

func (s *OrderedExamples) GetOK(key string) (*Example, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedExamples) Keys

func (s *OrderedExamples) Keys() []string

Keys gets the list of keys

func (OrderedExamples) MarshalJSON

func (s OrderedExamples) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedExamples.

func (*OrderedExamples) Set

func (s *OrderedExamples) Set(key string, val *Example) bool

Set sets the value to the security requirement

func (*OrderedExamples) UnmarshalJSON

func (s *OrderedExamples) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for OrderedExamples.

type OrderedHeaders

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

OrderedHeaders is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedHeaders

func NewOrderedHeaders() OrderedHeaders

NewOrderedHeaders creates a new instance of OrderedHeaders with correct filter

func (*OrderedHeaders) ForEach

func (s *OrderedHeaders) ForEach(fn func(string, *Header) error) error

ForEach executes the function for each security requirement

func (*OrderedHeaders) Get

func (s *OrderedHeaders) Get(key string) *Header

Get gets the security requirement by key

func (*OrderedHeaders) GetOK

func (s *OrderedHeaders) GetOK(key string) (*Header, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedHeaders) Keys

func (s *OrderedHeaders) Keys() []string

Keys gets the list of keys

func (OrderedHeaders) MarshalJSON

func (s OrderedHeaders) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedHeaders.

func (*OrderedHeaders) Set

func (s *OrderedHeaders) Set(key string, val *Header) bool

Set sets the value to the security requirement

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

OrderedLinks is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedLinks() OrderedLinks

NewOrderedLinks creates a new instance of OrderedLinks with correct filter

func (*OrderedLinks) ForEach

func (s *OrderedLinks) ForEach(fn func(string, *Link) error) error

ForEach executes the function for each security requirement

func (*OrderedLinks) Get

func (s *OrderedLinks) Get(key string) *Link

Get gets the security requirement by key

func (*OrderedLinks) GetOK

func (s *OrderedLinks) GetOK(key string) (*Link, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedLinks) Keys

func (s *OrderedLinks) Keys() []string

Keys gets the list of keys

func (OrderedLinks) MarshalJSON

func (s OrderedLinks) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedLinks.

func (*OrderedLinks) Set

func (s *OrderedLinks) Set(key string, val *Link) bool

Set sets the value to the security requirement

type OrderedMap

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

OrderedMap is a map that preserves insertion order 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 any valid JSON value (null, a primitive, an array, or an object.)

func (*OrderedMap) Delete

func (s *OrderedMap) Delete(k string) bool

Delete a value from the map

func (*OrderedMap) Entries

func (s *OrderedMap) Entries() []MapEntry

Entries in the order of addition to the map

func (*OrderedMap) ForEach

func (s *OrderedMap) ForEach(fn func(string, interface{}) error) error

ForEach executes a function for each value in the map

func (*OrderedMap) Get

func (s *OrderedMap) Get(key string) interface{}

Get get a value for the specified key

func (*OrderedMap) GetOK

func (s *OrderedMap) GetOK(key string) (interface{}, bool)

GetOK get a value for the specified key, the boolean result indicates if the value was found or not

func (*OrderedMap) Keys

func (s *OrderedMap) Keys() []string

Keys in the order of addition to the map. The returned slice shares the underlying array; do not append to or modify it.

func (*OrderedMap) Len

func (s *OrderedMap) Len() int

Len of the known keys

func (OrderedMap) MarshalEasyJSON

func (s OrderedMap) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderedMap) MarshalJSON

func (s OrderedMap) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderedMap) Set

func (s *OrderedMap) Set(key string, value interface{}) bool

Set a value in the map. Returns true when key is new, false when updating an existing key.

func (OrderedMap) String

func (s OrderedMap) String() string

func (*OrderedMap) UnmarshalEasyJSON

func (s *OrderedMap) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderedMap) UnmarshalJSON

func (s *OrderedMap) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

func (*OrderedMap) Values

func (s *OrderedMap) Values() []interface{}

Values in the order of addition to the map

type OrderedMediaTypes

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

OrderedMediaTypes is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedMediaTypes

func NewOrderedMediaTypes() OrderedMediaTypes

NewOrderedMediaTypes creates a new instance of OrderedMediaTypes with correct filter

func (*OrderedMediaTypes) ForEach

func (s *OrderedMediaTypes) ForEach(fn func(string, *MediaType) error) error

ForEach executes the function for each security requirement

func (*OrderedMediaTypes) Get

func (s *OrderedMediaTypes) Get(key string) *MediaType

Get gets the security requirement by key

func (*OrderedMediaTypes) GetOK

func (s *OrderedMediaTypes) GetOK(key string) (*MediaType, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedMediaTypes) Keys

func (s *OrderedMediaTypes) Keys() []string

Keys gets the list of keys

func (OrderedMediaTypes) MarshalJSON

func (s OrderedMediaTypes) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedMediaTypes.

func (*OrderedMediaTypes) Set

func (s *OrderedMediaTypes) Set(key string, val *MediaType) bool

Set sets the value to the security requirement

func (*OrderedMediaTypes) UnmarshalJSON

func (s *OrderedMediaTypes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for OrderedMediaTypes.

type OrderedOperations

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

OrderedOperations represents a collection of API operations in a specific order.

func NewOrderedOperations

func NewOrderedOperations() OrderedOperations

NewOrderedOperations creates a new instance of OrderedOperations with correct filter

func (*OrderedOperations) ForEach

func (s *OrderedOperations) ForEach(fn func(string, *Operation) error) error

ForEach executes the function for each security requirement

func (*OrderedOperations) Get

func (s *OrderedOperations) Get(key string) *Operation

Get gets the security requirement by key

func (*OrderedOperations) GetOK

func (s *OrderedOperations) GetOK(key string) (*Operation, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedOperations) Keys

func (s *OrderedOperations) Keys() []string

Keys gets the list of keys

func (*OrderedOperations) Set

func (s *OrderedOperations) Set(key string, val *Operation) bool

Set sets the value to the security requirement

type OrderedParameters

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

func NewOrderedParameters

func NewOrderedParameters() OrderedParameters

func (*OrderedParameters) ForEach

func (s *OrderedParameters) ForEach(fn func(string, *Parameter) error) error

ForEach executes the function for each security requirement

func (*OrderedParameters) Get

func (s *OrderedParameters) Get(key string) *Parameter

Get gets the security requirement by key

func (*OrderedParameters) GetOK

func (s *OrderedParameters) GetOK(key string) (*Parameter, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedParameters) Keys

func (s *OrderedParameters) Keys() []string

Keys gets the list of keys

func (OrderedParameters) MarshalJSON

func (s OrderedParameters) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedParameters.

func (*OrderedParameters) Set

func (s *OrderedParameters) Set(key string, val *Parameter) bool

Set sets the value to the security requirement

type OrderedPathItems

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

OrderedPathItems is a map of string to Path Item Object (or $ref). Used for webhooks (OAS 3.1) and components.pathItems (OAS 3.1).

func NewOrderedPathItems

func NewOrderedPathItems() OrderedPathItems

NewOrderedPathItems returns a new OrderedPathItems.

func (*OrderedPathItems) Get

func (s *OrderedPathItems) Get(key string) *PathItem

Get returns the PathItem for key, or nil.

func (*OrderedPathItems) GetOK

func (s *OrderedPathItems) GetOK(key string) (*PathItem, bool)

GetOK returns the PathItem and true if key exists.

func (*OrderedPathItems) Keys

func (s *OrderedPathItems) Keys() []string

Keys returns the keys in order.

func (OrderedPathItems) MarshalEasyJSON

func (s OrderedPathItems) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON implements easyjson.Marshaler.

func (OrderedPathItems) MarshalJSON

func (s OrderedPathItems) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*OrderedPathItems) Set

func (s *OrderedPathItems) Set(key string, val *PathItem) bool

Set sets the PathItem for key. Returns false if key was filtered out.

func (*OrderedPathItems) UnmarshalEasyJSON

func (s *OrderedPathItems) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON implements easyjson.Unmarshaler.

func (*OrderedPathItems) UnmarshalJSON

func (s *OrderedPathItems) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

type OrderedRequestBodies

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

OrderedRequestBodies is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedRequestBodies

func NewOrderedRequestBodies() OrderedRequestBodies

NewOrderedRequestBodies creates a new instance of OrderedRequestBodies with correct filter

func (*OrderedRequestBodies) ForEach

func (s *OrderedRequestBodies) ForEach(fn func(string, *RequestBody) error) error

ForEach executes the function for each security requirement

func (*OrderedRequestBodies) Get

Get gets the security requirement by key

func (*OrderedRequestBodies) GetOK

func (s *OrderedRequestBodies) GetOK(key string) (*RequestBody, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedRequestBodies) Keys

func (s *OrderedRequestBodies) Keys() []string

Keys gets the list of keys

func (OrderedRequestBodies) MarshalJSON

func (s OrderedRequestBodies) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedRequestBodies.

func (*OrderedRequestBodies) Set

func (s *OrderedRequestBodies) Set(key string, val *RequestBody) bool

Set sets the value to the security requirement

type OrderedResponses

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

OrderedResponses is a container for the expected responses of an operation. The container maps a HTTP response code to the expected response.

func NewOrderedResponses

func NewOrderedResponses() OrderedResponses

NewOrderedResponses creates the new instance of the OrderedResponses with correct key-filter

func (*OrderedResponses) ForEach

func (s *OrderedResponses) ForEach(fn func(string, *Response) error) error

ForEach executes the function for each security requirement

func (*OrderedResponses) Get

func (s *OrderedResponses) Get(key string) *Response

Get gets the security requirement by key

func (*OrderedResponses) GetOK

func (s *OrderedResponses) GetOK(key string) (*Response, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedResponses) Keys

func (s *OrderedResponses) Keys() []string

Keys gets the list of keys

func (OrderedResponses) MarshalEasyJSON

func (s OrderedResponses) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (OrderedResponses) MarshalJSON

func (s OrderedResponses) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*OrderedResponses) Set

func (s *OrderedResponses) Set(key string, val *Response) bool

Set sets the value to the security requirement

func (*OrderedResponses) UnmarshalEasyJSON

func (s *OrderedResponses) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*OrderedResponses) UnmarshalJSON

func (s *OrderedResponses) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OrderedSchemas

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

OrderedSchemas is an ordered map of schema name → Schema.

func NewOrderedSchemas

func NewOrderedSchemas() OrderedSchemas

NewOrderedSchemas creates a new instance of OrderedSchemas with correct filter

func (*OrderedSchemas) ForEach

func (s *OrderedSchemas) ForEach(fn func(string, *Schema) error) error

ForEach executes the function for each security requirement

func (*OrderedSchemas) Get

func (s *OrderedSchemas) Get(key string) *Schema

Get gets the security requirement by key

func (*OrderedSchemas) GetOK

func (s *OrderedSchemas) GetOK(key string) (*Schema, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedSchemas) Keys

func (s *OrderedSchemas) Keys() []string

Keys gets the list of keys

func (OrderedSchemas) MarshalJSON

func (s OrderedSchemas) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedSchemas.

func (*OrderedSchemas) Set

func (s *OrderedSchemas) Set(key string, val *Schema) bool

Set sets the value to the security requirement

func (*OrderedSchemas) UnmarshalJSON

func (s *OrderedSchemas) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for OrderedSchemas.

type OrderedSecuritySchemes

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

OrderedSecuritySchemes is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedSecuritySchemes

func NewOrderedSecuritySchemes() OrderedSecuritySchemes

NewOrderedSecuritySchemes creates a new instance of OrderedSecuritySchemes with correct filter

func (*OrderedSecuritySchemes) ForEach

func (s *OrderedSecuritySchemes) ForEach(fn func(string, *SecurityScheme) error) error

ForEach executes the function for each security requirement

func (*OrderedSecuritySchemes) Get

Get gets the security requirement by key

func (*OrderedSecuritySchemes) GetOK

GetOK checks if the key exists in the security requirement

func (*OrderedSecuritySchemes) Keys

func (s *OrderedSecuritySchemes) Keys() []string

Keys gets the list of keys

func (OrderedSecuritySchemes) MarshalJSON

func (s OrderedSecuritySchemes) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedSecuritySchemes.

func (*OrderedSecuritySchemes) Set

Set sets the value to the security requirement

func (*OrderedSecuritySchemes) UnmarshalJSON

func (s *OrderedSecuritySchemes) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for OrderedSecuritySchemes.

type OrderedStrings

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

OrderedStrings is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewOrderedStrings

func NewOrderedStrings() OrderedStrings

NewOrderedStrings creates a new instance of OrderedStrings with correct filter

func (*OrderedStrings) ForEach

func (s *OrderedStrings) ForEach(fn func(string, *string) error) error

ForEach executes the function for each security requirement

func (*OrderedStrings) Get

func (s *OrderedStrings) Get(key string) *string

Get gets the security requirement by key

func (*OrderedStrings) GetOK

func (s *OrderedStrings) GetOK(key string) (*string, bool)

GetOK checks if the key exists in the security requirement

func (*OrderedStrings) Keys

func (s *OrderedStrings) Keys() []string

Keys gets the list of keys

func (OrderedStrings) MarshalJSON

func (s OrderedStrings) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for OrderedStrings.

func (*OrderedStrings) Set

func (s *OrderedStrings) Set(key string, val *string) bool

Set sets the value to the security requirement

func (*OrderedStrings) UnmarshalJSON

func (s *OrderedStrings) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler for OrderedStrings.

type Parameter

type Parameter struct {
	VendorExtensible
	Reference

	Name            string  `json:"name"`
	In              string  `json:"in"` // see ParameterIn constants
	Description     *string `json:"description"`
	Required        bool    `json:"required"`
	Deprecated      bool    `json:"deprecated"`
	AllowEmptyValue bool    `json:"allowEmptyValue"`
	//  style,explode,allowReserved used with schema
	Style         Style             `json:"style"`
	Explode       bool              `json:"explode"`
	AllowReserved bool              `json:"allowReserved"`
	Schema        Schema            `json:"schema"`
	Example       interface{}       `json:"example"`
	Examples      OrderedExamples   `json:"examples"`
	Content       OrderedMediaTypes `json:"content"`
}

Parameter describes a single operation parameter. A unique parameter is defined by a combination of a name and location. Valid In values: "path", "query", "querystring" (OAS 3.2), "header", "cookie". See ParameterIn constants and https://spec.openapis.org/oas/v3.2.0.html#parameter-object

func (*Parameter) MarshalJSON

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

MarshalJSON implements json.Marshaler so the parameter serializes all fields (not only VendorExtensible). When the parameter is a $ref, only {"$ref": "..."} is emitted.

type ParameterIn

type ParameterIn string

ParameterIn represents the location of a parameter. See https://spec.openapis.org/oas/v3.2.0.html#parameter-locations

const (
	ParameterInPath        ParameterIn = "path"
	ParameterInQuery       ParameterIn = "query"
	ParameterInQueryString ParameterIn = "querystring" // OAS 3.2: entire query string as a single value.
	ParameterInHeader      ParameterIn = "header"
	ParameterInCookie      ParameterIn = "cookie"
)

type PathItem

type PathItem struct {
	Reference
	Summary              *string               `json:"summary,omitempty"`
	Description          string                `json:"description,omitempty"`
	Get                  *Operation            `json:"get,omitempty"`
	Put                  *Operation            `json:"put,omitempty"`
	Post                 *Operation            `json:"post,omitempty"`
	Delete               *Operation            `json:"delete,omitempty"`
	Options              *Operation            `json:"options,omitempty"`
	Head                 *Operation            `json:"head,omitempty"`
	Patch                *Operation            `json:"patch,omitempty"`
	Trace                *Operation            `json:"trace,omitempty"`
	Query                *Operation            `json:"query,omitempty"`                // OAS 3.2: QUERY HTTP method.
	AdditionalOperations map[string]*Operation `json:"additionalOperations,omitempty"` // OAS 3.2: non-standard HTTP methods.
	Servers              []Server              `json:"servers,omitempty"`
	Parameters           []Parameter           `json:"parameters,omitempty"`
}

PathItem describes the operations available on a single path. See https://spec.openapis.org/oas/v3.2.0.html#path-item-object Operation fields are pointers so nil is omitted when serializing (omitempty).

func (*PathItem) MarshalJSON

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

MarshalJSON implements json.Marshaler. Emits {"$ref":"..."} when a ref is set, otherwise marshals all PathItem fields.

type Paths

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

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 ACL constraints.

func (*Paths) ForEach

func (p *Paths) ForEach(fn func(string, *PathItem) error) error

ForEach calls fn for each path and its PathItem in insertion order.

func (*Paths) Get

func (p *Paths) Get(path string) *PathItem

func (*Paths) GetOK

func (p *Paths) GetOK(path string) (*PathItem, bool)

func (*Paths) Keys

func (p *Paths) Keys() []string

Keys gets list of all the keys

func (Paths) MarshalEasyJSON

func (p Paths) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Paths) MarshalJSON

func (p Paths) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Paths) Set

func (p *Paths) Set(path string, item *PathItem) bool

func (*Paths) UnmarshalEasyJSON

func (p *Paths) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Paths) UnmarshalJSON

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

UnmarshalJSON supports json.Unmarshaler interface

type Reference

type Reference struct {
	// Ref holds the $ref string value (e.g. "#/components/schemas/Pet").
	// It is intentionally untagged: each embedding struct's MarshalJSON handles
	// emitting {"$ref":"..."} and populating this field on unmarshal.
	Ref string `json:"-"`
}

Reference is a simple object to allow referencing other components in the specification, internally and externally. See https://spec.openapis.org/oas/v3.2.0.html#reference-object

type RequestBody

type RequestBody struct {
	VendorExtensible
	Reference

	Description *string           `json:"description,omitempty"`
	Content     OrderedMediaTypes `json:"content"`
	Required    bool              `json:"required"`
}

RequestBody describes a single request body.

func (*RequestBody) MarshalJSON

func (r *RequestBody) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler so RequestBody serializes all fields (not only VendorExtensible). When the request body is a $ref, only {"$ref": "..."} is emitted.

type Response

type Response struct {
	VendorExtensible
	Reference

	Description *string            `json:"description,omitempty"`
	Summary     *string            `json:"summary,omitempty"`
	Headers     *OrderedHeaders    `json:"headers,omitempty"`
	Content     *OrderedMediaTypes `json:"content,omitempty"`
	Links       *OrderedLinks      `json:"links,omitempty"`
}

Response describes a single response from an API Operation, including design-time, static links to operations based on the response. Headers, Content, Links are pointers so nil is omitted when serializing (omitempty).

func (*Response) MarshalJSON

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

MarshalJSON implements json.Marshaler so the response serializes all fields (not only VendorExtensible). When the response is a $ref, only {"$ref": "..."} is emitted.

type Schema

type Schema struct {
	VendorExtensible
	Reference

	// Metadata
	Title       string `json:"title,omitempty"`
	Description string `json:"description,omitempty"`
	// Type is the JSON Schema type. In OAS 3.2 this may also be an array of strings.
	Type   string `json:"type,omitempty"`
	Format string `json:"format,omitempty"`

	// Validation — numbers
	Minimum          *float64    `json:"minimum,omitempty"`
	Maximum          *float64    `json:"maximum,omitempty"`
	ExclusiveMinimum interface{} `json:"exclusiveMinimum,omitempty"` // bool (3.0) or number (3.1+)
	ExclusiveMaximum interface{} `json:"exclusiveMaximum,omitempty"`
	MultipleOf       *float64    `json:"multipleOf,omitempty"`

	// Validation — strings
	MinLength *int64 `json:"minLength,omitempty"`
	MaxLength *int64 `json:"maxLength,omitempty"`
	Pattern   string `json:"pattern,omitempty"`

	// Validation — arrays
	Items       *Schema `json:"items,omitempty"`
	MinItems    *int64  `json:"minItems,omitempty"`
	MaxItems    *int64  `json:"maxItems,omitempty"`
	UniqueItems bool    `json:"uniqueItems,omitempty"`
	// PrefixItems is OAS 3.2 / JSON Schema 2020-12.
	PrefixItems []*Schema `json:"prefixItems,omitempty"`

	// Validation — objects
	Required   []string        `json:"required,omitempty"`
	Properties *OrderedSchemas `json:"properties,omitempty"`
	// AdditionalProperties accepts either a *Schema or a bool.
	AdditionalProperties interface{} `json:"additionalProperties,omitempty"`
	MinProperties        *int64      `json:"minProperties,omitempty"`
	MaxProperties        *int64      `json:"maxProperties,omitempty"`

	// Composition
	AllOf []*Schema `json:"allOf,omitempty"`
	AnyOf []*Schema `json:"anyOf,omitempty"`
	OneOf []*Schema `json:"oneOf,omitempty"`
	Not   *Schema   `json:"not,omitempty"`

	// Enum / const / default / example
	Enum    []interface{} `json:"enum,omitempty"`
	Default interface{}   `json:"default,omitempty"`
	Example interface{}   `json:"example,omitempty"`

	// Annotations
	ReadOnly   bool `json:"readOnly,omitempty"`
	WriteOnly  bool `json:"writeOnly,omitempty"`
	Deprecated bool `json:"deprecated,omitempty"`
	// Nullable is OAS 3.0 only; in OAS 3.1+ use type arrays instead.
	Nullable bool `json:"nullable,omitempty"`

	// Linked objects
	XML           *XML                   `json:"xml,omitempty"`
	ExternalDocs  *ExternalDocumentation `json:"externalDocs,omitempty"`
	Discriminator *Discriminator         `json:"discriminator,omitempty"`
}

Schema object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. https://spec.openapis.org/oas/v3.2.0.html#schema-object

func (*Schema) MarshalJSON

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

MarshalJSON implements json.Marshaler. When $ref is set, emits {"$ref":"..."} only. Otherwise marshals all fields and merges vendor extensions.

type SecurityRequirement

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

SecurityRequirement lists 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.

func (*SecurityRequirement) ForEach

func (s *SecurityRequirement) ForEach(fn func(string, []string) error) error

ForEach executes the function for each security requirement

func (*SecurityRequirement) Get

func (s *SecurityRequirement) Get(key string) []string

Get gets the security requirement by key

func (*SecurityRequirement) GetOK

func (s *SecurityRequirement) GetOK(key string) ([]string, bool)

GetOK checks if the key exists in the security requirement

func (*SecurityRequirement) Keys

func (s *SecurityRequirement) Keys() []string

Keys gets the list of keys

func (SecurityRequirement) MarshalEasyJSON

func (s SecurityRequirement) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (SecurityRequirement) MarshalJSON

func (s SecurityRequirement) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*SecurityRequirement) Set

func (s *SecurityRequirement) Set(key string, scopes ...string) bool

Set sets the value to the security requirement

func (*SecurityRequirement) UnmarshalEasyJSON

func (s *SecurityRequirement) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*SecurityRequirement) UnmarshalJSON

func (s *SecurityRequirement) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type SecurityScheme

type SecurityScheme struct {
	VendorExtensible
	Reference

	Type             string     `json:"type,omitempty"`
	Description      string     `json:"description,omitempty"`
	Name             string     `json:"name,omitempty"`
	In               string     `json:"in,omitempty"`
	Scheme           string     `json:"scheme,omitempty"`
	BearerFormat     string     `json:"bearerFormat,omitempty"`
	Flows            OAuthFlows `json:"flows,omitempty"`
	OpenIDConnectURL string     `json:"openIdConnectUrl,omitempty"`
	// OAuth2MetadataURL (OAS 3.2) URL to the OAuth2 authorization server metadata (RFC 8414). TLS required.
	OAuth2MetadataURL string `json:"oauth2MetadataUrl,omitempty"`
	// Deprecated (OAS 3.2) declares this security scheme as deprecated.
	Deprecated bool `json:"deprecated,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), OAuth2's common flows (implicit, password, application and access code) as defined in RFC6749, and OpenID Connect Discovery.

func (*SecurityScheme) MarshalJSON

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

MarshalJSON implements json.Marshaler for SecurityScheme.

type SecuritySchemeType

type SecuritySchemeType string

SecuritySchemeType represents the type of a Security Scheme Object. See https://spec.openapis.org/oas/v3.2.0.html#security-scheme-object

const (
	SecuritySchemeTypeAPIKey        SecuritySchemeType = "apiKey"
	SecuritySchemeTypeHTTP          SecuritySchemeType = "http"
	SecuritySchemeTypeMutualTLS     SecuritySchemeType = "mutualTLS" // OAS 3.2
	SecuritySchemeTypeOAuth2        SecuritySchemeType = "oauth2"
	SecuritySchemeTypeOpenIDConnect SecuritySchemeType = "openIdConnect"
)

type Server

type Server struct {
	VendorExtensible
	URL         string          `json:"url"`                   // REQUIRED. May contain {variables}.
	Name        *string         `json:"name,omitempty"`        // Optional (extension/common).
	Description string          `json:"description,omitempty"` // Keep string for easyjson compatibility.
	Variables   ServerVariables `json:"variables,omitempty"`
}

Server represents a server. See https://spec.openapis.org/oas/v3.2.0.html#server-object

easyjson:json

func (Server) MarshalEasyJSON

func (v Server) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Server) MarshalJSON

func (v Server) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Server) UnmarshalEasyJSON

func (v *Server) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Server) UnmarshalJSON

func (v *Server) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ServerVariable

type ServerVariable struct {
	VendorExtensible
	/*
		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"`
	/*
		REQUIRED. The default value to use for substitution,
		which SHALL be sent if an alternate value is not supplied.
		If the enum is defined, the value MUST exist in the enum’s values.
		Note that this behavior is different from the Schema Object’s default keyword,
		which documents the receiver’s behavior rather than inserting the value into the data.
	*/
	Default     string `json:"default"`
	Description string `json:"description,omitempty"`
}

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

func (ServerVariable) MarshalEasyJSON

func (v ServerVariable) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ServerVariable) MarshalJSON

func (v ServerVariable) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ServerVariable) UnmarshalEasyJSON

func (v *ServerVariable) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ServerVariable) UnmarshalJSON

func (v *ServerVariable) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type ServerVariables

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

ServerVariables is a map between a variable name and its value. The value is used for substitution in the server's URL template.

func NewServerVariables

func NewServerVariables() ServerVariables

NewServerVariables creates a new instance of ServerVariables with correct filter

func (*ServerVariables) ForEach

func (s *ServerVariables) ForEach(fn func(string, *ServerVariable) error) error

ForEach executes the function for each security requirement

func (*ServerVariables) Get

func (s *ServerVariables) Get(key string) *ServerVariable

Get gets the security requirement by key

func (*ServerVariables) GetOK

func (s *ServerVariables) GetOK(key string) (*ServerVariable, bool)

GetOK checks if the key exists in the security requirement

func (*ServerVariables) Keys

func (s *ServerVariables) Keys() []string

Keys gets the list of keys

func (ServerVariables) MarshalEasyJSON

func (v ServerVariables) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (ServerVariables) MarshalJSON

func (v ServerVariables) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*ServerVariables) Set

func (s *ServerVariables) Set(key string, val *ServerVariable) bool

Set sets the value to the security requirement

func (*ServerVariables) UnmarshalEasyJSON

func (v *ServerVariables) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*ServerVariables) UnmarshalJSON

func (v *ServerVariables) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Style

type Style string

Style represents how a parameter value will be serialized depending on the type of the parameter value. See https://spec.openapis.org/oas/v3.2.0.html#style-values

const (
	StyleMatrix         Style = "matrix"
	StyleLabel          Style = "label"
	StyleSimple         Style = "simple"
	StyleForm           Style = "form"
	StyleSpaceDelimited Style = "spaceDelimited"
	StylePipeDelimited  Style = "pipeDelimited"
	StyleDeepObject     Style = "deepObject"
	// StyleCookie is used with in: "cookie" parameters (analogous to form, following RFC 6265).
	StyleCookie Style = "cookie"
)

type Tag

type Tag struct {
	VendorExtensible

	Name         string                 `json:"name"`                  // REQUIRED.
	Summary      string                 `json:"summary,omitempty"`     // OAS 3.2: short summary for display.
	Description  string                 `json:"description,omitempty"` // CommonMark allowed.
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
	Parent       string                 `json:"parent,omitempty"` // OAS 3.2: name of a parent tag (must exist).
	Kind         string                 `json:"kind,omitempty"`   // OAS 3.2: e.g. "nav", "badge", "audience".
}

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. easyjson:json

func (Tag) MarshalEasyJSON

func (v Tag) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Tag) MarshalJSON

func (v Tag) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Tag) UnmarshalEasyJSON

func (v *Tag) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Tag) UnmarshalJSON

func (v *Tag) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type VendorExtensible

type VendorExtensible struct {
	Extensions Extensions
}

VendorExtensible composition block.

func (*VendorExtensible) AddExtension

func (v *VendorExtensible) AddExtension(key string, value interface{})

AddExtension adds an extension to this extensible object.

func (VendorExtensible) MarshalJSON

func (v VendorExtensible) MarshalJSON() ([]byte, error)

MarshalJSON marshals the extensions to json

func (*VendorExtensible) UnmarshalJSON

func (v *VendorExtensible) UnmarshalJSON(data []byte) error

UnmarshalJSON for this extensible object

type XML

type XML struct {
	VendorExtensible

	// NodeType (OAS 3.2) specifies the XML DOM node type: "element", "attribute", "text", "cdata", or "none".
	// Replaces the deprecated Attribute and Wrapped fields.
	NodeType  string `json:"nodeType,omitempty"`
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
	Prefix    string `json:"prefix,omitempty"`
	// Deprecated: Use NodeType: "attribute" instead. Kept for OAS 3.0/3.1 compatibility.
	Attribute bool `json:"attribute,omitempty"`
	// Deprecated: Use NodeType: "element" instead. Kept for OAS 3.0/3.1 compatibility.
	Wrapped bool `json:"wrapped,omitempty"`
}

XML a metadata object that allows for more fine-tuned XML model definitions.

func (XML) MarshalJSON

func (x XML) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler for XML.

Jump to

Keyboard shortcuts

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