openapi

package module
v0.0.0-...-91bac37 Latest Latest
Warning

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

Go to latest
Published: Dec 24, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const SecuritySchemeBearer = "bearer"

Variables

View Source
var ErrEmptyDocument = errors.New("document must contain at least one paths field, a components field or a webhooks field")

ErrEmptyDocument is thrown if the OpenAPI document does not contain at least one paths field, a components field or a webhooks field.

View Source
var ErrUnknownField = errors.New(`unknown field or extension without "x-" prefix`)

ErrUnknownField is returned when a field is not recognized and also doesn't have a "x-" prefix signifying it is an extension.

Functions

This section is empty.

Types

type Callback

type Callback map[RuntimeExpression]*PathItemRef

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 by the 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.

Note that according to the specification, this object MAY be extended with Specification Extensions, but we do not support that in this implementation. Note that we are not validating the runtime expression in this implementation.

func (Callback) ByIndex

ByIndex returns the keys of the map in the order of the index.

func (*Callback) MarshalJSONV2

func (c *Callback) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Callback) UnmarshalJSONV2

func (c *Callback) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Callback) Validate

func (c Callback) Validate() error

type CallbackRef

type CallbackRef = refOrValue[Callback, *Callback]

CallbackRef is a reference to a Callback or an actual Callback.

type CallbackRefs

type CallbackRefs map[string]*CallbackRef

func (CallbackRefs) ByIndex

func (cs CallbackRefs) ByIndex() iter.Seq2[string, *CallbackRef]

ByIndex returns the keys of the map in the order of the index.

func (*CallbackRefs) MarshalJSONV2

func (cs *CallbackRefs) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*CallbackRefs) UnmarshalJSONV2

func (cs *CallbackRefs) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (CallbackRefs) Validate

func (cs CallbackRefs) Validate() error

type Callbacks

type Callbacks map[string]Callback

Callbacks holds a set of reusable callbacks.

func (Callbacks) Validate

func (cs Callbacks) Validate() error

Validate the values of the map.

type Components

type Components struct {
	// An object to hold reusable Schema Objects.
	Schemas Schemas `json:"schemas,omitempty" yaml:"schemas,omitempty"`
	// An object to hold reusable Response Objects.
	Responses ResponsesByName `json:"responses,omitempty" yaml:"responses,omitempty"`
	// An object to hold reusable Parameter Objects.
	Parameters Parameters `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	// An object to hold reusable Example Objects.
	Examples Examples `json:"examples,omitempty" yaml:"examples,omitempty"`
	// An object to hold reusable Request Body Objects.
	RequestBodies RequestBodies `json:"requestBodies,omitempty" yaml:"requestBodies,omitempty"`
	// An object to hold reusable Header Objects.
	Headers Headers `json:"headers,omitempty" yaml:"headers,omitempty"`
	// An object to hold reusable Security Scheme Objects.
	SecuritySchemes SecuritySchemes `json:"securitySchemes,omitempty" yaml:"securitySchemes,omitempty"`
	// An object to hold reusable Link Objects.
	Links Links `json:"links,omitempty" yaml:"links,omitempty"`
	// An object to hold reusable Callback Objects.
	Callbacks CallbackRefs `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
	// An object to hold reusable Path Item Object.
	PathItems PathItems `json:"pathItems,omitempty" yaml:"pathItems,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

The Components object 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 referenced from properties outside the components object. (Specification)

All the fixed fields are objects that MUST use keys that match the regular expression:

^[a-zA-Z0-9\.\-_]+$

Field name examples:

User
User_1
User_Name
user-name
my.org.User

func (*Components) Validate

func (c *Components) Validate() error

type Contact

type Contact struct {
	// The identifying name of the contact person/organization.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// The URL pointing to the contact information. MUST be in the format of a URL.
	URL *url.URL `json:"url,omitempty" yaml:"url,omitempty"`
	// The email address of the contact person/organization. This MUST be in the form of an email address.
	Email types.Email `json:"email,omitempty" yaml:"email,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

Contact information for the exposed API. (Specification)

func (*Contact) Validate

func (c *Contact) Validate() error

Validate checks the contact for consistency.

type Content

type Content map[MediaRange]*MediaType

func (Content) ByIndex

func (c Content) ByIndex() iter.Seq2[MediaRange, *MediaType]

ByIndex returns the keys of the map in the order of the index.

func (*Content) MarshalJSONV2

func (c *Content) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Content) UnmarshalJSONV2

func (c *Content) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Content) Validate

func (c Content) Validate() error

type DataType

type DataType string

Data types in the OAS are based on the types supported by the JSON Schema Specification Draft 2020-12. Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part. Models are defined using the Schema Object, which is a superset of JSON Schema Specification Draft 2020-12.

(Specification)

const (
	TypeInteger DataType = "integer" // format: int32, int64
	TypeNumber  DataType = "number"  // format: float, double
	TypeString  DataType = "string"  // format: password
	TypeArray   DataType = "array"
	TypeBoolean DataType = "boolean"
	TypeObject  DataType = "object"
)

func (DataType) Validate

func (d DataType) Validate() error

type Document

type Document struct {
	// 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.
	OpenAPI string `json:"openapi" yaml:"openapi"`
	// REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required.
	Info *Info `json:"info,omitempty" yaml:"info,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.
	// Default: "https://spec.openapis.org/oas/3.1/dialect/base"
	// NOTE: Anything other than the default value is not supported.
	JSONSchemaDialect *url.URL `json:"jsonSchemaDialect,omitempty" yaml:"jsonSchemaDialect,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 Servers `json:"servers,omitempty" yaml:"servers,omitempty"`
	// The available paths and operations for the API.
	Paths 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.
	Webhooks Webhooks `json:"webhooks,omitempty" yaml:"webhooks,omitempty"`
	// An element to hold various schemas for the document.
	Components Components `json:"components,omitempty" yaml:"components,omitempty"`
	// 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 SecurityRequirements `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 Tags `json:"tags,omitempty" yaml:"tags,omitempty"`
	// Additional external documentation.
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

Document is an OpenAPI document, the root object. It is a self-contained or composite resource which defines or describes an API or elements of an API. An OpenAPI document uses and conforms to the OpenAPI Specification. (Specification)

func LoadFromData

func LoadFromData(data []byte) (*Document, error)

func LoadFromDataJSON

func LoadFromDataJSON(data []byte) (*Document, error)

LoadFromDataJSON reads an OpenAPI specification from a byte array in JSON format and parses it into a structured format.

func LoadFromDataYAML

func LoadFromDataYAML(data []byte) (*Document, error)

LoadFromDataYAML reads an OpenAPI specification from a byte array in YAML format and parses it into a structured format.

func LoadFromFile

func LoadFromFile(location string) (*Document, error)

LoadFromFile reads an OpenAPI specification from a file and parses it into a structured format

func LoadFromReader

func LoadFromReader(r io.Reader) (*Document, error)

LoadFromReader reads an OpenAPI specification from an io.Reader and parses it into a structured format. It will try to determine the format of the data and load it accordingly. If you know the format of the data, use LoadFromReaderJSON or LoadFromReaderYAML instead.

func (*Document) ToJSON

func (d *Document) ToJSON() ([]byte, error)

func (*Document) Validate

func (d *Document) Validate() error

Validate checks the OpenAPI document for correctness.

func (Document) WriteJSON

func (d Document) WriteJSON(w io.Writer) error

func (*Document) WriteToFile

func (d *Document) WriteToFile(path string) error

type Encoding

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.
	ContentType string `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 Headers `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.
	Style ParameterStyle `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.
	Explode bool `json:"explode,omitzero" yaml:"explode,omitzero"`
	// 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.
	AllowReserved bool `json:"allowReserved,omitzero" yaml:"allowReserved,omitzero"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
	// contains filtered or unexported fields
}

Encoding is a single encoding definition applied to a single schema property.

func (*Encoding) Validate

func (e *Encoding) Validate() error

type Encodings

type Encodings map[string]*Encoding

Encodings is a map between a property name and its encoding information.

func (Encodings) ByIndex

func (e Encodings) ByIndex() iter.Seq2[string, *Encoding]

ByIndex returns the keys of the map in the order of the index.

func (*Encodings) MarshalJSONV2

func (c *Encodings) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Encodings) UnmarshalJSONV2

func (c *Encodings) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Encodings) Validate

func (es Encodings) Validate() error

type Example

type Example struct {
	// Short description for the example.
	Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
	// Long description for the example. CommonMark syntax MAY be used for rich text representation.
	Description string `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.
	Value jsontext.Value `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](#relative-references-in-uris).
	ExternalValue *url.URL `json:"externalValue,omitempty" yaml:"externalValue,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:"-"`
}

Example represents an example of a schema.

In all cases, the example value 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.

func (*Example) Validate

func (ex *Example) Validate() error

type ExampleRef

type ExampleRef = refOrValue[Example, *Example]

ExampleRef is a reference to an Example or an actual Example.

type Examples

type Examples map[string]*ExampleRef

Examples is a map of examples.

func (Examples) ByIndex

func (ex Examples) ByIndex() iter.Seq2[string, *ExampleRef]

ByIndex returns the keys of the map in the order of the index.

func (*Examples) MarshalJSONV2

func (ex *Examples) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Examples) UnmarshalJSONV2

func (ex *Examples) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Examples) Validate

func (exs Examples) Validate() error

Validate validates the map of examples.

type Extensions

type Extensions = jsontext.Value

Extensions represents additional fields that can be added to OpenAPI objects.

While the OpenAPI Specification tries to accommodate most use cases, additional data can be added to extend the specification at certain points.

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. (Specification)

It is here an alias of jsontext.Value to allow inlining within structs, enabling seamless marshalling and unmarshalling. Using jsontext.Value preserves the order of fields, preventing unnecessary changes when parsing and writing OpenAPI specifications. Although a map could be used, it doesn't maintain the order, leading to potential inconsistencies in the output. Custom marshalling for an inlined object is not possible, which prevents the use of an ordered map.

Note: For convenience, certain common extensions are implemented as fields directly within the respective structs.

type ExternalDocs

type ExternalDocs struct {
	// A description of the target documentation. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// REQUIRED. The URL for the target documentation. This MUST be in the form of a URL.
	URL *url.URL `json:"url,omitempty" yaml:"url,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

ExternalDocs allows referencing an external resource for extended documentation. (Specification)

func (*ExternalDocs) Validate

func (ed *ExternalDocs) Validate() error

Validate checks the external documentation for consistency.

type Format

type Format string

Format defines additional formats to provide fine detail for primitive data types.

const (
	// FormatInt32 represents a signed 32 bits integer.
	FormatInt32 Format = "int32"
	// FormatInt64 represents a signed 64 bits integer.
	FormatInt64 Format = "int64"
	// FormatFloat represents a float number.
	FormatFloat Format = "float"
	// FormatDouble represents a double number.
	FormatDouble Format = "double"
	// FormatByte represents a byte.
	FormatByte Format = "byte"
	// FormatBinary represents a binary.
	FormatBinary Format = "binary"
	// FormatDate represents a date.
	FormatDate Format = "date"
	// FormatDateTime represents a date-time.
	FormatDateTime Format = "date-time"
	// FormatDuration represents a duration.
	FormatDuration Format = "duration"
	// FormatEmail represents an email.
	FormatEmail Format = "email"
	// FormatPassword represents a password. It's a hint to UIs to obscure input.
	FormatPassword Format = "password"
	// FormatUUID represents a UUID.
	FormatUUID Format = "uuid"
	// FormatURI represents a URI.
	FormatURI Format = "uri"
	// FormatURIRef represents a URI reference.
	FormatURIRef Format = "uriref"
	// FormatZipCode represents a zip code.
	FormatZipCode Format = "zip-code"
	// FormatIPv4 represents an IPv4 address.
	FormatIPv4 Format = "ipv4"
	// FormatIPv6 represents an IPv6 address.
	FormatIPv6 Format = "ipv6"
)

func (Format) Validate

func (f Format) Validate() error

Validate validates the format.

type Header struct {
	// A brief description of the parameter. This could contain examples of use. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,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`.
	Required bool `json:"required,omitempty,omitzero" yaml:"required,omitempty"`
	// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`.
	Deprecated bool `json:"deprecated,omitempty,omitzero" yaml:"deprecated,omitempty"`
	// The schema defining the type used for the parameter.
	Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
	// Describes how the parameter value will be serialized depending on the type of the parameter value. Default values is `simple`.
	Style ParameterStyle `json:"style,omitempty" yaml:"style,omitempty"`
	// 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`.
	Explode bool `json:"explode,omitempty,omitzero" yaml:"explode,omitempty"`
	// 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.
	Example jsontext.Value `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 Examples `json:"examples,omitempty" yaml:"examples,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 Content `json:"content,omitempty" yaml:"content,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:"-"`
}

Header represents a single header parameter to be included in the operation.

func (*Header) Validate

func (h *Header) Validate() error

type HeaderRef

type HeaderRef = refOrValue[Header, *Header]

HeaderRef is a reference to a Header or an actual Header.

type Headers

type Headers map[string]*HeaderRef

func (Headers) ByIndex

func (h Headers) ByIndex() iter.Seq2[string, *HeaderRef]

ByIndex returns the keys of the map in the order of the index.

func (*Headers) MarshalJSONV2

func (h *Headers) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Headers) UnmarshalJSONV2

func (h *Headers) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Headers) Validate

func (hs Headers) Validate() error

type Info

type Info struct {
	// REQUIRED. The title of the API.
	Title string `json:"title" yaml:"title"`
	// A short summary of the API.
	Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
	// A description of the API. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// A URL to the Terms of Service for the API.
	TermsOfService *url.URL `json:"termsOfService,omitempty" yaml:"termsOfService,omitempty"`
	// The contact information for the exposed API.
	Contact *Contact `json:"contact,omitempty" yaml:"contact,omitempty"`
	// The license information for the exposed API.
	License *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).
	Version string `json:"version" yaml:"version"`
	// The object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

The Info object 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. (Specification)

func (*Info) Validate

func (i *Info) Validate() error

type License

type License struct {
	// REQUIRED. The license name used for the API.
	Name string `json:"name" yaml:"name"`
	// An SPDX license expression for the API. The identifier field is mutually exclusive of the url field.
	// See: https://spdx.org/licenses/
	Identifier string `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.
	URL *url.URL `json:"url,omitempty" yaml:"url,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

License information for the exposed API. (Specification)

func (*License) Validate

func (l *License) Validate() error
type Link struct {
	// 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.
	// Note that in the use of `operationRef`, the _escaped forward-slash_ is necessary when using JSON references.
	// Because of the potential for name clashes, the `operationRef` syntax is preferred for OpenAPI documents with external references.
	OperationRef string `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.
	OperationID string `json:"operationId,omitempty" yaml:"operationId,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 LinkParameters `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	// A literal value or {expression} to use as a request body when calling the target operation.
	RequestBody RuntimeExpression `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
	// A description of the link. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:"-"`
}

The `Link object` 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](#runtime-expressions) is used for accessing values in an operation and using them as parameters while invoking the linked operation.

Clients follow all links at their discretion. Neither permissions, nor the capability to make a successful call to that link, is guaranteed solely by the existence of a relationship.

func (*Link) Validate

func (l *Link) Validate() error

type LinkParameter

type LinkParameter struct {
	Expression RuntimeExpression
	// contains filtered or unexported fields
}

LinkParameter is an expression that is the value of a parameter map in a Link Object.

func (*LinkParameter) MarshalJSONV2

func (p *LinkParameter) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marschals the link parameter into its appropriate type. NOTE: For now, we only implemented the case of it being a runtime expression.

func (*LinkParameter) UnmarshalJSONV2

func (p *LinkParameter) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarschals the link parameter into its appropriate type. NOTE: For now, we only implemented the case of it being a runtime expression.

func (*LinkParameter) Validate

func (p *LinkParameter) Validate() error

Validate validates the link parameter.

type LinkParameters

type LinkParameters map[string]*LinkParameter

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

func (LinkParameters) ByIndex

func (ps LinkParameters) ByIndex() iter.Seq2[string, *LinkParameter]

ByIndex returns the keys of the map in the order of the index.

func (*LinkParameters) MarshalJSONV2

func (ps *LinkParameters) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*LinkParameters) UnmarshalJSONV2

func (ps *LinkParameters) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (LinkParameters) Validate

func (ps LinkParameters) Validate() error

type LinkRef

type LinkRef = refOrValue[Link, *Link]

LinkRef is a reference to a Link or an actual Link.

type Links map[string]*LinkRef

func (Links) ByIndex

func (l Links) ByIndex() iter.Seq2[string, *LinkRef]

ByIndex returns the keys of the map in the order of the index.

func (*Links) MarshalJSONV2

func (l *Links) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Links) UnmarshalJSONV2

func (l *Links) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Links) Validate

func (ls Links) Validate() error

type MediaRange

type MediaRange string

MediaRange represents a media type or media type range. It is the key type in the Content map. See [RFC7231 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/*

func (MediaRange) Validate

func (mr MediaRange) Validate() error

type MediaType

type MediaType struct {
	// The schema defining the content of the request, response, or parameter.
	Schema *SchemaRef `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.
	Example jsontext.Value `json:"example,omitempty" yaml:"example,omitempty"`
	// Examples of the media type.
	// Each example object SHOULD match the media type and specified schema if present.
	// The `examples` field is mutually exclusive of the `example` field.  Furthermore, if referencing a `schema` which contains an example, the `examples` value SHALL _override_ the example provided by the schema.
	Examples Examples `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 Encodings `json:"encoding,omitempty" yaml:"encoding,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
	// contains filtered or unexported fields
}

Each Media Type Object provides schema and examples for the media type identified by its key.

(Specification)

func (*MediaType) Validate

func (mt *MediaType) Validate() error

type OAuthFlowAuthorizationCode

type OAuthFlowAuthorizationCode struct {
	// 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.
	AuthorizationURL *url.URL `json:"authorizationUrl" yaml:"authorizationUrl"`
	// 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.
	TokenURL *url.URL `json:"tokenUrl" yaml:"tokenUrl"`
	// 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.
	RefreshURL *url.URL `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"`
	// 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.
	Scopes Scopes `json:"scopes" yaml:"scopes"`

	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

OAuthFlowAuthorizationCode allows configuration details for the OAuth Authorization Code flow.

func (*OAuthFlowAuthorizationCode) Validate

func (f *OAuthFlowAuthorizationCode) Validate() error

type OAuthFlowClientCredentials

type OAuthFlowClientCredentials = OAuthFlowPassword

OAuthFlowClientCredentials allows configuration details for the OAuth Client Credentials flow.

type OAuthFlowImplicit

type OAuthFlowImplicit struct {
	// 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.
	AuthorizationURL *url.URL `json:"authorizationUrl" yaml:"authorizationUrl"`
	// 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.
	RefreshURL *url.URL `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"`
	// 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.
	Scopes Scopes `json:"scopes" yaml:"scopes"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

OAuthFlowImplicit allows configuration details for the OAuth Implicit flow.

func (*OAuthFlowImplicit) Validate

func (f *OAuthFlowImplicit) Validate() error

type OAuthFlowPassword

type OAuthFlowPassword struct {
	// 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.
	TokenURL *url.URL `json:"tokenUrl" yaml:"tokenUrl"`
	// 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.
	RefreshURL *url.URL `json:"refreshUrl,omitempty" yaml:"refreshUrl,omitempty"`
	// 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.
	Scopes Scopes `json:"scopes" yaml:"scopes"`

	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

OAuthFlowPassword allows configuration details for the OAuth Resource Owner Password flow.

func (*OAuthFlowPassword) Validate

func (f *OAuthFlowPassword) Validate() error

type OAuthFlows

type OAuthFlows struct {
	// Configuration for the OAuth Implicit flow
	Implicit *OAuthFlowImplicit `json:"implicit,omitempty" yaml:"implicit,omitempty"`
	// Configuration for the OAuth Resource Owner Password flow
	Password *OAuthFlowPassword `json:"password,omitempty" yaml:"password,omitempty"`
	// Configuration for the OAuth Client Credentials flow.
	// Previously called `application` in OpenAPI 2.0.
	ClientCredentials *OAuthFlowClientCredentials `json:"clientCredentials,omitempty" yaml:"clientCredentials,omitempty"`
	// Configuration for the OAuth Authorization Code flow.
	// Previously called `accessCode` in OpenAPI 2.0.
	AuthorizationCode *OAuthFlowAuthorizationCode `json:"authorizationCode,omitempty" yaml:"authorizationCode,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

The OAuthFlows object allows configuration of the supported OAuth Flows. (Specification)

func (*OAuthFlows) Validate

func (f *OAuthFlows) Validate() error

type Operation

type Operation struct {
	// 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 short summary of what the operation does.
	Summary string `json:"summary,omitempty" yaml:"summary,omitempty"`
	// A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Additional external documentation for this operation.
	ExternalDocs *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.
	OperationID string `json:"operationId,omitempty" yaml:"operationId,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 ParameterList `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	// 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, HEAD and DELETE), `requestBody` is permitted but does not have well-defined semantics and SHOULD be avoided if possible.
	RequestBody *RequestBodyRef `json:"requestBody,omitempty" yaml:"requestBody,omitempty"`
	// The list of possible responses as they are returned from executing this operation.
	Responses OperationResponses `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 Callbacks `json:"callbacks,omitempty" yaml:"callbacks,omitempty"`
	// Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the declared operation. Default value is `false`.
	Deprecated bool `json:"deprecated,omitempty,omitzero" yaml:"deprecated,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 SecurityRequirements `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 Servers `json:"servers,omitempty" yaml:"servers,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

Operation describes a single API operation on a path. (Specification)

func (*Operation) Validate

func (o *Operation) Validate() error

Validate validates the operation.

type OperationResponses

type OperationResponses = Responses[StatusCode]

OperationsResponses 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 provided it SHOULD be the response for a successful operation call.

Note that according to the specification, this object MAY be extended with Specification Extensions, but we do not support that in this implementation.

type Parameter

type Parameter struct {
	//	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. TODO
	// - 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.
	Name string `json:"name" yaml:"name"`
	// REQUIRED. The location of the parameter. Possible values are `"query"`, `"header"`, `"path"` or `"cookie"`.
	In ParameterLocation `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.
	Description string `json:"description,omitempty" yaml:"description,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`.
	Required bool `json:"required,omitempty,omitzero" yaml:"required,omitempty"`
	// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`.
	Deprecated bool `json:"deprecated,omitempty,omitzero" yaml:"deprecated,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.
	AllowEmptyValue bool `json:"allowEmptyValue,omitempty,omitzero" yaml:"allowEmptyValue,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`.
	Style ParameterStyle `json:"style,omitempty" yaml:"style,omitempty"`
	// 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`.
	Explode bool `json:"explode,omitempty,omitzero" 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`.
	AllowReserved bool `json:"allowReserved,omitempty,omitzero" yaml:"allowReserved,omitempty"`
	// The schema defining the type used for the parameter.
	Schema *Schema `json:"schema,omitempty" yaml:"schema,omitempty"`
	// 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.
	Example jsontext.Value `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 Examples `json:"examples,omitempty" yaml:"examples,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 Content `json:"content,omitempty" yaml:"content,omitempty"`

	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:"-"`
}

Parameter describes a single operation parameter.

A unique parameter is defined by a combination of a name and location.

The rules for serialization of the parameter are specified in one of two ways:

  1. For simpler scenarios, a `schema` and `style` can describe the structure and syntax of the parameter.
  2. For more complex scenarios, the content property can define the media type and schema of the parameter.

A parameter MUST contain either a schema property, or a content property, but not both. When example or examples are provided in conjunction with the schema object, the example MUST follow the prescribed serialization strategy for the parameter.

(Specification)

func (*Parameter) Validate

func (p *Parameter) Validate() error

Validate checks the parameter for correctness.

type ParameterList

type ParameterList []*ParameterRef

ParameterList is a list of parameter references.

func (ParameterList) In

In is a convenience function to filter by a specific parameter location.

func (ParameterList) InPath

func (p ParameterList) InPath() ParameterList

InPath returns all path parameters from the list.

func (ParameterList) InQuery

func (p ParameterList) InQuery() ParameterList

InQuery returns all query parameters from the list.

func (ParameterList) Validate

func (p ParameterList) Validate() error

type ParameterLocation

type ParameterLocation string

ParameterLocation defines the location of the parameter. There are four possible parameter locations specified by the `in` field of a Parameter.

const (
	// 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`.
	ParameterLocationPath ParameterLocation = "path"
	// Parameters that are appended to the URL. For example, in `/items?id=###`, the query parameter is `id`.
	ParameterLocationQuery ParameterLocation = "query"
	// Custom headers that are expected as part of the request. Note that RFC7230 states header names are case insensitive.
	ParameterLocationHeader ParameterLocation = "header"
	// Used to pass a specific cookie value to the API.
	ParameterLocationCookie ParameterLocation = "cookie"
)

func (ParameterLocation) Validate

func (p ParameterLocation) Validate() error

type ParameterRef

type ParameterRef = refOrValue[Parameter, *Parameter]

ParameterRef is a reference to a Parameter or an actual Parameter.

type ParameterStyle

type ParameterStyle string

In order to support common ways of serializing simple parameters, a set of `style` values are defined. Assume a parameter named `color` has one of the following values:

string -> "blue"
array -> ["blue","black","brown"]
object -> { "R": 100, "G": 200, "B": 150 }

The following table shows examples of rendering differences for each value.

| `style`        | `explode` | `empty` | `string`    | `array`                             | `object`                               |
|----------------|-----------|---------|-------------|-------------------------------------|----------------------------------------|
| matrix         | false     | ;color  | ;color=blue | ;color=blue,black,brown             | ;color=R,100,G,200,B,150               |
| matrix         | true      | ;color  | ;color=blue | ;color=blue;color=black;color=brown | ;R=100;G=200;B=150                     |
| label          | false     | .       | .blue       | .blue.black.brown                   | .R.100.G.200.B.150                     |
| label          | true      | .       | .blue       | .blue.black.brown                   | .R=100.G=200.B=150                     |
| form           | false     | color=  | color=blue  | color=blue,black,brown              | color=R,100,G,200,B,150                |
| form           | true      | color=  | color=blue  | color=blue&color=black&color=brown  | R=100&G=200&B=150                      |
| simple         | false     | n/a     | blue        | blue,black,brown                    | R,100,G,200,B,150                      |
| simple         | true      | n/a     | blue        | blue,black,brown                    | R=100,G=200,B=150                      |
| spaceDelimited | false     | n/a     | n/a         | blue%20black%20brown                | R%20100%20G%20200%20B%20150            |
| pipeDelimited  | false     | n/a     | n/a         | blue|black|brown                    | R|100|G|200|B|150                      |
| deepObject     | true      | n/a     | n/a         | n/a                                 | color[R]=100&color[G]=200&color[B]=150 |
const (
	ParameterStyleMatrix ParameterStyle = "matrix"
	ParameterStyleLabel  ParameterStyle = "label"
	ParameterStyleForm   ParameterStyle = "form"
	ParameterStyleSimple ParameterStyle = "simple"
	// Space separated array or object values. This option replaces `collectionFormat` equal to `ssv` from OpenAPI 2.0.
	ParameterStyleSpaceDelimited ParameterStyle = "spaceDelimited"
	// Pipe separated array or object values. This option replaces `collectionFormat` equal to `pipes` from OpenAPI 2.0.
	ParameterStylePipeDelimited ParameterStyle = "pipeDelimited"
	// Provides a simple way of rendering nested objects using form parameters.
	ParameterStyleDeepObject ParameterStyle = "deepObject"
)

func (ParameterStyle) Validate

func (s ParameterStyle) Validate() error

type Parameters

type Parameters map[string]*ParameterRef

func (Parameters) ByIndex

func (ss Parameters) ByIndex() iter.Seq2[string, *ParameterRef]

ByIndex returns the keys of the map in the order of the index.

func (*Parameters) MarshalJSONV2

func (ss *Parameters) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Parameters) UnmarshalJSONV2

func (ss *Parameters) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Parameters) Validate

func (ps Parameters) Validate() error

type Path

type Path string

Path represents a URL path template.

Templating refers to the usage of template expressions, delimited by curly braces ({}), to mark a section of a URL path as replaceable using path parameters.

Each template expression in the path MUST correspond to a path parameter that is included in the Path Item itself and/or in each of the Path Item's Operations. An exception is if the path item is empty, for example due to ACL constraints, matching path parameters are not required.

The value for these path parameters MUST NOT contain any unescaped "generic syntax" characters described by RFC3986: forward slashes (/), question marks (?), or hashes (#). (Specification)

func (Path) Validate

func (p Path) Validate() error

Validate checks the path for correctness.

type PathItem

type PathItem struct {
	// An optional, string summary, intended to apply to all operations in this path.
	Summary string `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.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// An alternative `server` array to service all operations in this path.
	Servers Servers `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 ParameterList `json:"parameters,omitempty" yaml:"parameters,omitempty"`
	// A definition of a GET operation on this path.
	Get *Operation `json:"get,omitempty" yaml:"get,omitempty"`
	// A definition of a PUT operation on this path.
	Put *Operation `json:"put,omitempty" yaml:"put,omitempty"`
	// A definition of a POST operation on this path.
	Post *Operation `json:"post,omitempty" yaml:"post,omitempty"`
	// A definition of a DELETE operation on this path.
	Delete *Operation `json:"delete,omitempty" yaml:"delete,omitempty"`
	// A definition of a OPTIONS operation on this path.
	Options *Operation `json:"options,omitempty" yaml:"options,omitempty"`
	// A definition of a HEAD operation on this path.
	Head *Operation `json:"head,omitempty" yaml:"head,omitempty"`
	// A definition of a PATCH operation on this path.
	Patch *Operation `json:"patch,omitempty" yaml:"patch,omitempty"`
	// A definition of a TRACE operation on this path.
	Trace *Operation `json:"trace,omitempty" yaml:"trace,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:"-"`
	// contains filtered or unexported fields
}

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. (Specification)

func (*PathItem) Operations

func (p *PathItem) Operations(yield func(string, *Operation) bool)

Operations iterates over all operations in the path item.

func (*PathItem) SetOperation

func (p *PathItem) SetOperation(method string, op *Operation)

SetOperation sets the operation for the given method.

func (*PathItem) Validate

func (p *PathItem) Validate() error

Validate validates the path item.

type PathItemRef

type PathItemRef = refOrValue[PathItem, *PathItem]

PathItemRef is a reference to a PathItem or an actual PathItem.

type PathItems

type PathItems map[string]*PathItemRef

func (PathItems) ByIndex

func (ps PathItems) ByIndex() iter.Seq2[string, *PathItemRef]

ByIndex returns the keys of the map in the order of the index.

func (*PathItems) MarshalJSONV2

func (ps *PathItems) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*PathItems) UnmarshalJSONV2

func (ps *PathItems) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (PathItems) Validate

func (ps PathItems) Validate() error

type Paths

type Paths map[Path]*PathItem

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.

Note that according to the specification, this object MAY be extended with Specification Extensions, but we do not support that in this implementation. (Specification)

func (Paths) ByIndex

func (ps Paths) ByIndex() iter.Seq2[Path, *PathItem]

ByIndex returns the keys of the map in the order of the index.

func (*Paths) MarshalJSONV2

func (ps *Paths) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Paths) UnmarshalJSONV2

func (ps *Paths) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Paths) Validate

func (ps Paths) Validate() error

type Reference

type Reference struct {
	// REQUIRED. The reference identifier. This MUST be in the form of a URI.
	Identifier string `json:"$ref,omitempty" yaml:"$ref,omitempty"`
	// 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.
	Summary string `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.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
}

Reference 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.

(Specification)

func (*Reference) Validate

func (r *Reference) Validate() error

type RequestBodies

type RequestBodies map[string]*RequestBodyRef

func (RequestBodies) ByIndex

func (rs RequestBodies) ByIndex() iter.Seq2[string, *RequestBodyRef]

ByIndex returns the keys of the map in the order of the index.

func (*RequestBodies) MarshalJSONV2

func (rs *RequestBodies) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*RequestBodies) UnmarshalJSONV2

func (rs *RequestBodies) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (RequestBodies) Validate

func (rs RequestBodies) Validate() error

type RequestBody

type RequestBody struct {
	// A brief description of the request body. This could contain examples of use.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Determines if the request body is required in the request. Defaults to `false`.
	Required bool `json:"required,omitempty,omitzero" yaml:"required,omitempty"`
	// REQUIRED. The content of the request body. The key is a media type or media type range 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 Content `json:"content" yaml:"content"`

	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

RequestBody describes a single request body.

(Specification)

func (*RequestBody) Validate

func (r *RequestBody) Validate() error

type RequestBodyRef

type RequestBodyRef = refOrValue[RequestBody, *RequestBody]

RequestBodyRef is a reference to a RequestBody or an actual RequestBody.

type Response

type Response struct {
	// REQUIRED. A description of the response. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description" yaml:"description"`
	// 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 Headers `json:"headers,omitempty" yaml:"headers,omitempty"`
	// A map containing descriptions of potential response payloads. The key is a media type or media type range 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 Content `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 Links `json:"links,omitempty" yaml:"links,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

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

(Specification)

func (*Response) Validate

func (r *Response) Validate() error

type ResponseRef

type ResponseRef = refOrValue[Response, *Response]

ResponseRef is a reference to a Response or an actual Response.

type Responses

type Responses[K ~string] map[K]*ResponseRef

Responses is a map of either response name or status code to a response object.

func (Responses[K]) ByIndex

func (rs Responses[K]) ByIndex() iter.Seq2[K, *ResponseRef]

ByIndex returns the keys of the map in the order of the index.

func (*Responses[_]) MarshalJSONV2

func (r *Responses[_]) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Responses[_]) UnmarshalJSONV2

func (r *Responses[_]) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Responses[K]) Validate

func (rs Responses[K]) Validate() error

Validate checks that each response is valid. It does not check the validity of the keys as they could be either status codes or response names.

type ResponsesByName

type ResponsesByName = Responses[string]

ResponsesByName is a map of response names to response objects.

type RuntimeExpression

type RuntimeExpression string

Runtime expressions allow defining values based on information that will only be available within the HTTP message in an actual API call. This mechanism is used by Link Objects and Callback Objects.

The runtime expression is defined by the following ABNF syntax

expression = ( "$url" / "$method" / "$statusCode" / "$request." source / "$response." source )
source = ( header-reference / query-reference / path-reference / body-reference )
header-reference = "header." token
query-reference = "query." name
path-reference = "path." name
body-reference = "body" ["#" json-pointer ]
json-pointer    = *( "/" reference-token )
reference-token = *( unescaped / escaped )
unescaped       = %x00-2E / %x30-7D / %x7F-10FFFF
   ; %x2F ('/') and %x7E ('~') are excluded from 'unescaped'
escaped         = "~" ( "0" / "1" )
  ; representing '~' and '/', respectively
name = *( CHAR )
token = 1*tchar
tchar = "!" / "#" / "$" / "%" / "&" / "'" / "*" / "+" / "-" / "." /
  "^" / "_" / "`" / "|" / "~" / DIGIT / ALPHA

Here, `json-pointer` is taken from RFC6901, `char` from RFC7159 and `token` from RFC7230.

The `name` identifier is case-sensitive, whereas `token` is not.

The table below provides examples of runtime expressions and examples of their use in a value:

| Source Location       | example expression         | notes                                                                                                                                               |
|-----------------------|-:--------------------------|-:---------------------------------------------------------------------------------------------------------------------------------------------------|
| HTTP Method           | `$method`                  | The allowable values for the `$method` will be those for the HTTP operation.                                                                        |
| Requested media type  | `$request.header.accept`   |                                                                                                                                                     |
| Request parameter     | `$request.path.id`         | Request parameters MUST be declared in the `parameters` section of the parent operation or they cannot be evaluated. This includes request headers. |
| Request body property | `$request.body#/user/uuid` | In operations which accept payloads, references may be made to portions of the `requestBody` or the entire body.                                    |
| Request URL           | `$url`                     |                                                                                                                                                     |
| Response value        | `$response.body#/status`   | In operations which return payloads, references may be made to portions of the response body or the entire body.                                    |
| Response header       | `$response.header.Server`  | Single header values only are available                                                                                                             |

Runtime expressions preserve the type of the referenced value. Expressions can be embedded into string values by surrounding the expression with `{}` curly braces.

func (RuntimeExpression) Validate

func (expr RuntimeExpression) Validate() error

type Schema

type Schema struct {
	// The name of the schema.
	Title string `json:"title,omitempty" yaml:"title,omitempty"`
	// A short description of the schema.
	// CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// Specifies the data type of the property.
	Type DataType `json:"type,omitempty" yaml:"type,omitempty"`
	// Further refines the data type.
	Format Format `json:"format,omitempty" yaml:"format,omitempty"`

	// AllOf takes an array of object definitions that are validated independently but together compose a single object.
	AllOf SchemaRefList `json:"allOf,omitempty" yaml:"allOf,omitempty"`

	// The minimum value of the number.
	Min *float64 `json:"minimum,omitempty" yaml:"minimum,omitempty"`
	// The maximum value of the number.
	Max *float64 `json:"maximum,omitempty" yaml:"maximum,omitempty"`

	// The pattern is used to validate the string.
	// This string SHOULD be a valid regular expression, according to the Ecma-262 Edition 5.1 regular expression dialect.
	// NOTE: We simply use text unmarshalling for this field. This guarantees that the regular expression is valid or we can't unmarshal.
	Pattern *regexp.Regexp `json:"pattern,omitempty" yaml:"pattern,omitempty"`
	// A list of possible values.
	Enum []string `json:"enum,omitempty" yaml:"enum,omitempty"`

	// The minimum number of items in the array.
	MinItems uint `json:"minItems,omitzero" yaml:"minItems,omitzero"`
	// The maximum number of items in the array.
	MaxItems *uint `json:"maxItems,omitempty" yaml:"maxItems,omitempty"`
	// The items of the array. When the type is array, this property is REQUIRED.
	// The empty schema for `items` indicates a media type of `application/octet-stream`.
	Items *SchemaRef `json:"items,omitzero" yaml:"items,omitzero"`

	// For object types, defines the properties of the object
	Properties SchemaRefs `json:"properties,omitzero" yaml:"properties,omitzero"`
	// Which properties are required.
	Required             []string   `json:"required,omitempty" yaml:"required,omitempty"`
	AdditionalProperties *SchemaRef `json:"additionalProperties,omitempty" yaml:"additionalProperties,omitempty"`

	// special encoding for binary data
	ContentMediaType string `json:"contentMediaType,omitempty" yaml:"contentMediaType,omitempty"`
	ContentEncoding  string `json:"contentEncoding,omitempty" yaml:"contentEncoding,omitempty"`

	// Specifies the default value of the property if no value is provided.
	Default any `json:"default,omitempty" yaml:"default,omitempty"`

	Example jsontext.Value `json:"example,omitempty" yaml:"example,omitempty"`
	// contains filtered or unexported fields
}

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.

(Specification)

func (*Schema) Validate

func (s *Schema) Validate() error

type SchemaRef

type SchemaRef = refOrValue[Schema, *Schema]

SchemaRef is a reference to a Schema or an actual Schema.

type SchemaRefList

type SchemaRefList []*SchemaRef

SchemaRefList is a slice of SchemaRef.

type SchemaRefs

type SchemaRefs map[string]*SchemaRef

func (SchemaRefs) ByIndex

func (ss SchemaRefs) ByIndex() iter.Seq2[string, *SchemaRef]

ByIndex returns the keys of the map in the order of the index.

func (*SchemaRefs) MarshalJSONV2

func (ss *SchemaRefs) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*SchemaRefs) UnmarshalJSONV2

func (ss *SchemaRefs) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (SchemaRefs) Validate

func (ss SchemaRefs) Validate() error

type Schemas

type Schemas map[string]*Schema

func (Schemas) ByIndex

func (ss Schemas) ByIndex() iter.Seq2[string, *Schema]

ByIndex returns the keys of the map in the order of the index.

func (*Schemas) MarshalJSONV2

func (ss *Schemas) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Schemas) UnmarshalJSONV2

func (ss *Schemas) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (Schemas) Validate

func (ss Schemas) Validate() error

type Scopes

type Scopes map[string]*String

func (Scopes) ByIndex

func (ps Scopes) ByIndex() iter.Seq2[string, *String]

ByIndex returns the keys of the map in the order of the index.

func (*Scopes) MarshalJSONV2

func (ps *Scopes) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*Scopes) UnmarshalJSONV2

func (ps *Scopes) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

type SecurityRequirement

type SecurityRequirement map[SecuritySchemeName][]string

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.

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.

(Specification)

func (SecurityRequirement) Validate

func (sr SecurityRequirement) Validate() error

type SecurityRequirements

type SecurityRequirements []SecurityRequirement

func (SecurityRequirements) Validate

func (ss SecurityRequirements) Validate() error

type SecurityScheme

type SecurityScheme struct {
	Type        SecuritySchemeType `json:"type" yaml:"type"`
	Description string             `json:"description,omitempty" yaml:"description,omitempty"`
	// The name of the API key.
	Name string `json:"name,omitempty" yaml:"name,omitempty"`
	// The location of the API key.
	In SecuritySchemeIn `json:"in,omitempty" yaml:"in,omitempty"`
	// The HTTP scheme to use, e.g. "bearer".
	Scheme string `json:"scheme,omitempty" yaml:"scheme,omitempty"`
	// The format of the bearer token, e.g. "jwt".
	BearerFormat string `json:"bearerFormat,omitempty" yaml:"bearerFormat,omitempty"`
	// The flows supported by the OAuth2 security scheme.
	Flows *OAuthFlows `json:"flows,omitempty" yaml:"flows,omitempty"`
	// The OpenID connect URL to use
	OpenIdConnectURL *url.URL `json:"openIdConnectUrl,omitempty" yaml:"openIdConnectUrl,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

func (*SecurityScheme) Validate

func (s *SecurityScheme) Validate() error

type SecuritySchemeIn

type SecuritySchemeIn string
const (
	SecuritySchemeInQuery  SecuritySchemeIn = "query"
	SecuritySchemeInHeader SecuritySchemeIn = "header"
	SecuritySchemeInCookie SecuritySchemeIn = "cookie"
)

func (SecuritySchemeIn) Validate

func (s SecuritySchemeIn) Validate() error

Validate validates the security location.

type SecuritySchemeName

type SecuritySchemeName string

SecuritySchemeName is the name of a security scheme defined in the Security Schemes under the Components Object.

type SecuritySchemeRef

type SecuritySchemeRef = refOrValue[SecurityScheme, *SecurityScheme]

SecuritySchemeRef is a reference to a SecurityScheme or an actual SecurityScheme.

type SecuritySchemeType

type SecuritySchemeType string
const (
	SecuritySchemeTypeAPIKey        SecuritySchemeType = "apiKey"
	SecuritySchemeTypeHTTP          SecuritySchemeType = "http"
	SecuritySchemeTypeMutualTLS     SecuritySchemeType = "mutualTLS"
	SecuritySchemeTypeOAuth2        SecuritySchemeType = "oauth2"
	SecuritySchemeTypeOpenIDConnect SecuritySchemeType = "openIdConnect"
)

func (SecuritySchemeType) Validate

func (tp SecuritySchemeType) Validate() error

Validate validates the security scheme type.

type SecuritySchemes

type SecuritySchemes map[string]*SecuritySchemeRef

func (SecuritySchemes) ByIndex

ByIndex returns the keys of the map in the order of the index.

func (*SecuritySchemes) MarshalJSONV2

func (c *SecuritySchemes) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*SecuritySchemes) UnmarshalJSONV2

func (ss *SecuritySchemes) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (SecuritySchemes) Validate

func (ss SecuritySchemes) Validate() error

type Server

type Server struct {
	// 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}.
	URL string `json:"url" yaml:"url"`

	// An optional string describing the host designated by the URL. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// A map between a variable name and its value. The value is used for substitution in the server's URL template.
	Variables ServerVariables `json:"variables,omitempty" yaml:"variables,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

Server is an object representing a Server. (Specification)

func (*Server) Validate

func (s *Server) Validate() error

type ServerVariable

type ServerVariable struct {
	// 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"`
	// 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 field is defined, the value MUST exist in the enum's values.
	Default string `json:"default" yaml:"default"`
	// An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty" yaml:"description,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
	// contains filtered or unexported fields
}

An object representing a Server Variable for server URL template substitution. (Specification)

func (*ServerVariable) Validate

func (s *ServerVariable) Validate() error

type ServerVariables

type ServerVariables map[string]*ServerVariable

ServerVariables is an ordered map of server variable.

func (ServerVariables) ByIndex

func (vars ServerVariables) ByIndex() iter.Seq2[string, *ServerVariable]

ByIndex returns the keys of the map in the order of the index.

func (ServerVariables) MarshalJSONV2

func (sv ServerVariables) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the map to JSON in the order of the index.

func (*ServerVariables) UnmarshalJSONV2

func (sv *ServerVariables) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the map from JSON and sets the index of each variable.

func (ServerVariables) Validate

func (vars ServerVariables) Validate() error

Validate validates each server variable.

type Servers

type Servers []Server

Servers is a list of server objects.

func (Servers) Validate

func (ss Servers) Validate() error

Validate validates each server.

type StatusCode

type StatusCode string

StatusCode is used as a key in the Responses map to describe the expected response for that HTTP status code. Any HTTP status code can be used, but only one property per code, to describe the expected response for that HTTP status code. 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.

const (
	// Use default to documentat responses other than the ones declared for specific HTTP response codes. Use as a field in the Responses map to cover undeclared responses.
	StatusCodeDefault StatusCode = "default"
)

func (StatusCode) IsSuccess

func (sc StatusCode) IsSuccess() bool

func (StatusCode) StatusText

func (sc StatusCode) StatusText() string

StatusText returns the text representation of the status code. If the status code is `"default"` or an invalid status code, it returns an empty string.

func (StatusCode) Validate

func (sc StatusCode) Validate() error

type String

type String struct {
	Value string
	// contains filtered or unexported fields
}

func (*String) MarshalJSONV2

func (s *String) MarshalJSONV2(enc *jsontext.Encoder, opts json.Options) error

MarshalJSONV2 marshals the value of the String.

func (*String) UnmarshalJSONV2

func (s *String) UnmarshalJSONV2(dec *jsontext.Decoder, opts json.Options) error

UnmarshalJSONV2 unmarshals the value of the String.

type Tag

type Tag struct {
	Name         string        `json:"name,omitempty" yaml:"name,omitempty"`
	Description  string        `json:"description,omitempty" yaml:"description,omitempty"`
	ExternalDocs *ExternalDocs `json:"externalDocs,omitempty" yaml:"externalDocs,omitempty"`
	// This object MAY be extended with Specification Extensions.
	Extensions Extensions `json:",inline" yaml:",inline"`
}

func (*Tag) Validate

func (t *Tag) Validate() error

type Tags

type Tags []*Tag

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.

func (Tags) Validate

func (tags Tags) Validate() error

type Webhooks

type Webhooks map[string]*PathItemRef

Webhooks 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) Path Item Object describes a request that may be initiated by the API provider and the expected responses.

func (Webhooks) Validate

func (ws Webhooks) Validate() error

Validate checks the Webhooks for correctness.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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