openapi

package
v0.1.12 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "3.1.0"

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback struct {
	Ref string `json:"$ref"`

	Extensions map[string]any
	// contains filtered or unexported fields
}

Callback The key that identifies the Path Item Object is a runtime expression that can be evaluated in the context of a runtime HTTP request/response to identify the URL to be used for the callback request. A simple example might be $request.body#/url. However, using a runtime expression the complete HTTP message can be accessed. This includes accessing any part of a body that a JSON Pointer RFC6901 can reference.

For example, given the following HTTP request:

POST /subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning HTTP/1.1 Host: example.org Content-Type: application/json Content-Length: 187

{
 "failedUrl" : "https://clientdomain.com/failed",
 "successUrls" : [
   "https://clientdomain.com/fast",
   "https://clientdomain.com/medium",
   "https://clientdomain.com/slow"
 ]
}

201 Created Location: https://example.org/subscription/1 The following examples show how the various expressions evaluate, assuming the callback operation has a path parameter named eventType and a query parameter named queryUrl.

Expression Value $url https://example.org/subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning $method POST $request.path.eventType myevent $request.query.queryUrl https://clientdomain.com/stillrunning $request.header.content-Type application/json $request.body#/failedUrl https://clientdomain.com/failed $request.body#/successUrls/2 https://clientdomain.com/medium $response.header.Location https://example.org/subscription/1 Callback Object Examples The following example uses the user provided queryUrl query string parameter to define the callback URL. This is an example of how to use a callback object to describe a WebHook callback that goes with the subscription operation to enable registering for the WebHook.

myCallback:

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

The following example shows a callback where the server is hard-coded, but the query string parameters are populated from the id and email property in the request body.

transactionCallback:

'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}':
  post:
    requestBody:
      description: Callback payload
      content:
        'application/json':
          schema:
            $ref: '#/components/schemas/SomePayload'
    responses:
      '200':
        description: callback successfully processed

func (*Callback) MarshalJSON

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

func (*Callback) Set

func (c *Callback) Set(path string, item *PathItem)

Set A Path Item Object, or a reference to one, used to define a callback request and expected responses. A complete example is available.

func (*Callback) UnmarshalJSON

func (c *Callback) UnmarshalJSON(buf []byte) (err error)

func (*Callback) Validate

func (c *Callback) Validate(openapi *OpenAPI) error

func (*Callback) Value

func (c *Callback) Value(path string) *PathItem

type Components

type Components struct {
	// An object to hold reusable Schema Objects.
	Schemas map[string]*Schema `json:"schemas"`

	// An object to hold reusable Response Objects.
	Responses map[string]*Response `json:"responses"`

	// An object to hold reusable Parameter Objects.
	Parameters map[string]*Parameter `json:"parameters"`

	// An object to hold reusable Example Objects.
	Examples map[string]*Example `json:"examples"`

	// An object to hold reusable Request Body Objects.
	RequestBodies map[string]*RequestBody `json:"requestBodies"`

	// An object to hold reusable Header Objects.
	Headers map[string]*Header `json:"headers"`

	// An object to hold reusable Security Scheme Objects.
	SecuritySchemes map[string]*SecurityScheme `json:"securitySchemes"`

	// An object to hold reusable Link Objects.
	Links map[string]*Link `json:"links"`

	// An object to hold reusable Callback Objects.
	Callbacks map[string]*Callback `json:"callbacks"`

	// An object to hold reusable Path Item Object.
	PathItems map[string]*PathItem `json:"pathItems"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Components) MarshalJSON

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

func (*Components) UnmarshalJSON

func (c *Components) UnmarshalJSON(buf []byte) (err error)

func (*Components) Validate

func (c *Components) Validate(openapi *OpenAPI) error

type Contact

type Contact struct {
	// The identifying name of the contact person/organization.
	Name string `json:"name"`

	// The URL pointing to the contact information. This MUST be in the form of a URL.
	URL string `json:"url"`

	// The email address of the contact person/organization. This MUST be in the form of an email address.
	Email string `json:"email"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Contact) MarshalJSON

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

func (*Contact) UnmarshalJSON

func (c *Contact) UnmarshalJSON(buf []byte) (err error)

func (*Contact) Validate

func (c *Contact) Validate() error

type Discriminator

type Discriminator struct {
	// REQUIRED. The name of the property in the payload that will hold the discriminator value.
	PropertyName string `json:"propertyName"`

	// An object to hold mappings between payload values and schema names or references.
	Mapping map[string]string `json:"mapping"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Discriminator) MarshalJSON

func (d *Discriminator) MarshalJSON() ([]byte, error)

func (*Discriminator) UnmarshalJSON

func (d *Discriminator) UnmarshalJSON(buf []byte) (err error)

func (*Discriminator) Validate

func (d *Discriminator) Validate() error

type Encoding

type Encoding struct {
	// The Content-Type for encoding a specific property. Default value depends on the property type: for - ;
	// for – the default is defined based on the inner type; for all other cases the default  is . The value
	// can be a specific media type (e.g. ), a wildcard media type (e.g. ), or a comma-separated list of
	// the two types.object application/json array application/octet-stream application/json image/*
	ContentType string `json:"contentType"`

	// A map allowing additional information to be provided as headers, for example . is described separately
	// and SHALL be ignored in this section. This property SHALL be ignored if the request body media
	// type is not a .Content-Disposition Content-Type multipart
	Headers map[string]*Header `json:"headers"`

	// 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 parameters,
	// including default values. This property SHALL be ignored if the request body media type is not or .
	// If a value is explicitly defined, then the value of contentType (implicit or explicit) SHALL be
	// ignored .query application/x-www-form-urlencoded multipart/form-data
	Style string `json:"style"`

	// When this is true, property values of type or 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 , the default value is . For all other styles, the default value is . This property
	// SHALL be ignored if the request body media type is not or . If a value is explicitly defined, then
	// the value of contentType (implicit or explicit) SHALL be ignored .array object form true false
	// application/x-www-form-urlencoded multipart/form-data
	Explode bool `json:"explode"`

	// Determines whether the parameter value SHOULD allow reserved characters, as defined by RFC3986
	// to be included without percent-encoding. The default value is . This property SHALL be ignored if
	// the request body media type is not or . If a value is explicitly defined, then the value of
	// contentType (implicit or explicit) SHALL be ignored.:/?#[]@!$&'()*+,;=false
	// application/x-www-form-urlencoded multipart/form-data
	AllowReserved bool `json:"allowReserved"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Encoding) MarshalJSON

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

func (*Encoding) UnmarshalJSON

func (e *Encoding) UnmarshalJSON(buf []byte) (err error)

func (*Encoding) Validate

func (e *Encoding) Validate(openapi *OpenAPI) error

type Example

type Example struct {
	Ref string `json:"$ref"`

	// Short description for the example.
	Summary string `json:"summary"`

	// Long description for the example. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// Embedded literal example. The field and 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 externalValue
	Value any `json:"value"`

	// 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 field and field are mutually exclusive.
	// See the rules for resolving Relative References. value externalValue
	ExternalValue string `json:"externalValue"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Example) MarshalJSON

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

func (*Example) UnmarshalJSON

func (e *Example) UnmarshalJSON(buf []byte) (err error)

func (*Example) Validate

func (e *Example) Validate(openapi *OpenAPI) error

type ExternalDocumentation

type ExternalDocumentation struct {
	// A description of the target documentation. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// REQUIRED. The URL for the target documentation. This MUST be in the form of a URL.
	URL string `json:"url"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*ExternalDocumentation) MarshalJSON

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

func (*ExternalDocumentation) UnmarshalJSON

func (e *ExternalDocumentation) UnmarshalJSON(buf []byte) (err error)

func (*ExternalDocumentation) Validate

func (e *ExternalDocumentation) Validate() error
type Header Parameter

The Header Object follows the structure of the Parameter Object with the following changes:

  1. name MUST NOT be specified, it is given in the corresponding map.headers
  2. in MUST NOT be specified, it is implicitly in .header
  3. All traits that are affected by the location MUST be applicable to a location of (for example, style).header

func (*Header) MarshalJSON

func (h *Header) MarshalJSON() ([]byte, error)

func (*Header) UnmarshalJSON

func (h *Header) UnmarshalJSON(buf []byte) (err error)

func (*Header) Validate

func (h *Header) Validate(openapi *OpenAPI) error

type Info

type Info struct {
	// REQUIRED. The title of the API.
	Title string `json:"title"`

	// A short summary of the API.
	Summary string `json:"summary"`

	// A description of the API. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// A URL to the Terms of Service for the API. This MUST be in the form of a URL.
	TermsOfService string `json:"termsOfService"`

	// The contact information for the exposed API.
	Contact *Contact `json:"contact"`

	// The license information for the exposed API.
	License *License `json:"license"`

	// REQUIRED. The version of the OpenAPI document (which is distinct from the OpenAPI Specification
	// version or the API implementation version).
	Version string `json:"version"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Info) MarshalJSON

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

func (*Info) UnmarshalJSON

func (i *Info) UnmarshalJSON(buf []byte) (err error)

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"`

	// An SPDX license expression for the API. The field is mutually exclusive of the field.identifierurl
	Identifier string `json:"identifier"`

	// A URL to the license used for the API. This MUST be in the form of a URL. The field is mutually
	// exclusive of the field.urlidentifier
	URL string `json:"url"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*License) MarshalJSON

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

func (*License) UnmarshalJSON

func (l *License) UnmarshalJSON(buf []byte) (err error)

func (*License) Validate

func (l *License) Validate() error
type Link struct {
	Ref string `json:"$ref"`

	// A relative or absolute URI reference to an OAS operation. This field is mutually exclusive of
	// the field, and MUST point to an Operation Object. Relative values MAY be used to locate an
	// existing Operation Object in the OpenAPI definition. See the rules for resolving Relative
	// References. operationId operationRef
	OperationRef string `json:"operationRef"`

	// The name of an existing, resolvable OAS operation, as defined with a unique . This field is
	// mutually exclusive of the field. operationId operationRef
	OperationId string `json:"operationId"`
	// A map representing parameters to pass to an operation as specified with or identified via .
	// 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 for operations that use the same parameter name in different locations
	// (e.g. path.id). operationId operationRef [{in}.]{name}
	Parameters map[string]any `json:"parameters"`

	// A literal value or {expression} to use as a request body when calling the target operation.
	RequestBody any `json:"requestBody"`

	// A description of the link. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// A server object to be used by the target operation.
	Server *Server `json:"server"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Link) MarshalJSON

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

func (*Link) UnmarshalJSON

func (l *Link) UnmarshalJSON(buf []byte) (err error)

func (*Link) Validate

func (l *Link) Validate(openapi *OpenAPI) error

type MediaType

type MediaType struct {
	// The schema defining the content of the request, response, or parameter.
	Schema *Schema `json:"schema"`

	// Example of the media type. The example object SHOULD be in the correct format as specified by the media
	// type. The field is mutually exclusive of the field. Furthermore, if referencing a which contains an
	// example, the value SHALL override the example provided by the schema.example examples schema example
	Example any `json:"example"`

	// Examples of the media type. Each example object SHOULD match the media type and specified schema if
	// present. The field is mutually exclusive of the field. Furthermore, if referencing a which contains
	// an example, the value SHALL override the example provided by the schema.examples example schema examples
	Examples map[string]*Example `json:"examples"`

	// 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 objects when the
	// media type is or .requestBody multipart application/x-www-form-urlencoded
	Encoding map[string]*Encoding `json:"encoding"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*MediaType) MarshalJSON

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

func (*MediaType) UnmarshalJSON

func (m *MediaType) UnmarshalJSON(buf []byte) (err error)

func (*MediaType) Validate

func (m *MediaType) Validate(openapi *OpenAPI) error

type OAuthFlow

type OAuthFlow 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 string `json:"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 string `json:"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 string `json:"refreshUrl"`

	// 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 map[string]string `json:"scopes"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*OAuthFlow) MarshalJSON

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

func (*OAuthFlow) UnmarshalJSON

func (o *OAuthFlow) UnmarshalJSON(buf []byte) (err error)

func (*OAuthFlow) Validate

func (o *OAuthFlow) Validate(applyTo string) error

type OAuthFlows

type OAuthFlows struct {
	// Configuration for the OAuth Implicit flow
	Implicit *OAuthFlow `json:"implicit"`

	// Configuration for the OAuth Resource Owner Password flow
	Password *OAuthFlow `json:"password"`

	// Configuration for the OAuth Client Credentials flow. Previously called in OpenAPI 2.0. application
	ClientCredentials *OAuthFlow `json:"clientCredentials"`

	// Configuration for the OAuth Authorization Code flow. Previously called in OpenAPI 2.0. accessCode
	AuthorizationCode *OAuthFlow `json:"authorizationCode"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*OAuthFlows) MarshalJSON

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

func (*OAuthFlows) UnmarshalJSON

func (o *OAuthFlows) UnmarshalJSON(buf []byte) (err error)

func (*OAuthFlows) Validate

func (o *OAuthFlows) Validate() error

type OpenAPI

type OpenAPI struct {
	// REQUIRED. This string MUST be the version number of the OpenAPI Specification that the
	// OpenAPI document uses. The field SHOULD be used by tooling to interpret the OpenAPI
	// document. This is not related to the API info.version string.openapi
	OpenAPI string `json:"openapi"`

	// REQUIRED. Provides metadata about the API. The metadata MAY be used by tooling as required.
	Info *Info `json:"info"`

	// The default value for the keyword within Schema Objects contained within this OAS document.
	// This MUST be in the form of a URI.$schema
	JSONSchemaDialect string `json:"jsonSchemaDialect"`

	// An array of Server Objects, which provide connectivity information to a target server.
	// If the property is not provided, or is an empty array, the default value would be a Server
	// Object with a url value of .servers/
	Servers []*Server `json:"servers"`

	// The available paths and operations for the API.
	Paths *Paths `json:"paths"`

	// 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 feature, this section describes requests initiated
	// other than by an API call, for example by an out of band registration. The key name is a unique
	// string to refer to each webhook, while the (optionally referenced) Path Item Object describes
	// a request that may be initiated by the API provider and the expected responses. An example is
	// available.callbacks
	Webhooks map[string]*PathItem `json:"webhooks"`

	// An element to hold various schemas for the document.
	Components *Components `json:"components"`

	// A declaration of which security mechanisms can be used across the API. The list of values includes
	// alternative security requirement objects that can be used. Only one of the security requirement
	// objects need to be satisfied to authorize a request. Individual operations can override this definition.
	// To make security optional, an empty security requirement () can be included in the array.{}
	Security []*SecurityRequirement `json:"security"`

	// 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 []*Tag `json:"tags"`

	// Additional external documentation.
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

OpenAPI is the root of an OpenAPI v3.1.0 document See https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md

func (*OpenAPI) MarshalJSON

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

func (*OpenAPI) UnmarshalJSON

func (o *OpenAPI) UnmarshalJSON(buf []byte) (err error)

func (*OpenAPI) Validate

func (o *OpenAPI) 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"`

	// A short summary of what the operation does.
	Summary string `json:"summary"`

	// A verbose explanation of the operation behavior. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// Additional external documentation for this operation.
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`

	// 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"`

	// 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 []*Parameter `json:"parameters"`

	// The request body applicable for this operation. The 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), is permitted but does not have
	// well-defined semantics and SHOULD be avoided if possible.requestBodyrequestBody
	RequestBody *RequestBody `json:"requestBody"`

	// The list of possible responses as they are returned from executing this operation.
	Responses *Responses `json:"responses"`

	// A map of possible out-of band callbacks related to the parent operation. The key is a unique
	// identifier for the Callback Object. Each value in the map is a Callback Object that describes a
	// request that may be initiated by the API provider and the expected responses.
	Callbacks map[string]*Callback `json:"callbacks"`

	// Declares this operation to be deprecated. Consumers SHOULD refrain from usage of the
	// declared operation. Default value is .false
	Deprecated bool `json:"deprecated"`

	// A declaration of which security mechanisms can be used for this operation. The list of values
	// includes alternative security requirement objects that can be used. Only one of the security
	// requirement objects need to be satisfied to authorize a request. To make security optional, an
	// empty security requirement () can be included in the array. This definition overrides any declared
	// top-level security. To remove a top-level security declaration, an empty array can be used.{}
	Security []*SecurityRequirement `json:"security"`

	// An alternative array to service this operation. If an alternative object is specified at the
	// Path Item Object or Root level, it will be overridden by this value.serverserver
	Servers []*Server `json:"servers"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Operation) MarshalJSON

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

func (*Operation) UnmarshalJSON

func (o *Operation) UnmarshalJSON(buf []byte) (err error)

func (*Operation) Validate

func (o *Operation) Validate(openapi *OpenAPI, path string) error

type Parameter

type Parameter struct {
	Ref string `json:"$ref"`

	// REQUIRED. The name of the parameter. Parameter names are case sensitive.
	//   If in is "path", the name field MUST correspond to a template expression occurring within
	//     the path field in the Paths Object. See Path Templating for further information.
	//   If in is "header" and the name field is "Accept", "Content-Type" or "Authorization",
	//     the parameter definition SHALL be ignored.
	//   For all other cases, the name corresponds to the parameter name used by the in property.
	Name string `json:"name"`

	// REQUIRED. The location of the parameter. Possible values are , , or ."query""header""path""cookie"
	In string `json:"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"`

	// 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"`

	// Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is .false
	Deprecated bool `json:"deprecated"`

	// Sets the ability to pass empty-valued parameters. This is valid only for parameters and allows
	// sending a parameter with an empty value. Default value is . If style is used, and if behavior is
	// (cannot be serialized), the value of SHALL be ignored. Use of this property is NOT RECOMMENDED,
	// as it is likely to be removed in a later revision.queryfalsen/aallowEmptyValue
	AllowEmptyValue bool `json:"allowEmptyValue"`

	// 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 string `json:"style"`

	// When this is true, parameter values of type or 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 , the default value is . For all other styles, the default value is
	// .array object form true false
	Explode bool `json:"explode"`

	// 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
	// value of . The default value is .:/?#[]@!$&'()*+,;=in query false
	AllowReserved bool `json:"allowReserved"`

	// The schema defining the type used for the parameter.
	Schema *Schema `json:"schema"`

	// Example of the parameter's potential value. The example SHOULD match the specified schema and
	// encoding properties if present. The field is mutually exclusive of the field. Furthermore, if
	// referencing a that contains an example, the 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 examples schema example
	Example any `json:"example"`
	// Examples of the parameter's potential value. Each example SHOULD contain a value in the correct
	// format as specified in the parameter encoding. The field is mutually exclusive of the field.
	// Furthermore, if referencing a that contains an example, the value SHALL override the example
	// provided by the schema.examples example schema examples
	Examples map[string]*Example `json:"examples"`

	// A map containing the representations for the parameter. The key is the media type and the
	// value describes it. The map MUST only contain one entry.
	Content map[string]*MediaType `json:"content"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Parameter) MarshalJSON

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

func (*Parameter) UnmarshalJSON

func (p *Parameter) UnmarshalJSON(buf []byte) (err error)

func (*Parameter) Validate

func (p *Parameter) Validate(openapi *OpenAPI, path string) error

type PathItem

type PathItem struct {
	Ref string `json:"$ref"`

	// An optional, string summary, intended to apply to all operations in this path.
	Summary string `json:"summary"`

	// 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"`

	// A definition of a GET operation on this path.
	Get *Operation `json:"get"`

	// A definition of a PUT operation on this path.
	Put *Operation `json:"put"`

	// A definition of a POST operation on this path.
	Post *Operation `json:"post"`

	// A definition of a DELETE operation on this path.
	Delete *Operation `json:"delete"`

	// A definition of a OPTIONS operation on this path.
	Options *Operation `json:"options"`

	// A definition of a HEAD operation on this path.
	Head *Operation `json:"head"`

	// A definition of a PATCH operation on this path.
	Patch *Operation `json:"patch"`

	// A definition of a TRACE operation on this path.
	Trace *Operation `json:"trace"`

	// An alternative array to service all operations in this path.server
	Servers []*Server `json:"servers"`

	// 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 []*Parameter `json:"parameters"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*PathItem) MarshalJSON

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

func (*PathItem) UnmarshalJSON

func (p *PathItem) UnmarshalJSON(buf []byte) (err error)

func (*PathItem) Validate

func (p *PathItem) Validate(openapi *OpenAPI, path string) error

type Paths

type Paths struct {
	Extensions map[string]any
	// contains filtered or unexported fields
}

func (*Paths) MarshalJSON

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

func (*Paths) Set

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

Set A relative path to an individual endpoint. The field name MUST begin with a forward slash (). The path is appended (no relative URL resolution) to the expanded URL from the Server Object's field in order to construct the full URL. Path templating is allowed. When matching URLs, concrete (non-templated) paths would be matched before their templated counterparts. Templated paths with the same hierarchy but different templated names MUST NOT exist as they are identical. In case of ambiguous matching, it's up to the tooling to decide which one to use./url

func (*Paths) UnmarshalJSON

func (p *Paths) UnmarshalJSON(buf []byte) (err error)

func (*Paths) Validate

func (p *Paths) Validate(openapi *OpenAPI) error

func (*Paths) Value

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

type RequestBody

type RequestBody struct {
	Ref string `json:"$ref"`

	// 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"`

	// 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 map[string]*MediaType `json:"content"`

	// Determines if the request body is required in the request. Defaults to .false
	Required bool `json:"required"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*RequestBody) MarshalJSON

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

func (*RequestBody) UnmarshalJSON

func (r *RequestBody) UnmarshalJSON(buf []byte) (err error)

func (*RequestBody) Validate

func (r *RequestBody) Validate(openapi *OpenAPI) error

type Response

type Response struct {
	Ref string `json:"$ref"`

	// REQUIRED. A description of the response. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// Maps a header name to its definition. RFC7230 states header names are case insensitive.
	// If a response header is defined with the name , it SHALL be ignored."Content-Type"
	Headers map[string]*Header `json:"headers"`

	// 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 map[string]*MediaType `json:"content"`

	// A map of operations links that can be followed from the response. The key of the map is a short
	// name for the link, following the naming constraints of the names for Component Objects.
	Links map[string]*Link `json:"links"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Response) MarshalJSON

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

func (*Response) UnmarshalJSON

func (r *Response) UnmarshalJSON(buf []byte) (err error)

func (*Response) Validate

func (r *Response) Validate(openapi *OpenAPI) error

type Responses

type Responses struct {

	// The documentation of responses other than the ones declared for specific HTTP response codes.
	// Use this field to cover undeclared responses.
	Default *Response `json:"default"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
	// contains filtered or unexported fields
}

func (*Responses) MarshalJSON

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

func (*Responses) Set

func (r *Responses) Set(status string, response *Response)

Set Any HTTP status code can be used as the property name, but only one property per code, to describe the expected response for that HTTP status code. This field MUST be enclosed in quotation marks (for example, "200") for compatibility between JSON and YAML. To define a range of response codes, this field MAY contain the uppercase wildcard character . For example, represents all response codes between . Only the following range definitions are allowed: , , , , and . If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code. X 2XX [200-299] 1XX 2XX 3XX 4XX 5XX

func (*Responses) UnmarshalJSON

func (r *Responses) UnmarshalJSON(buf []byte) (err error)

func (*Responses) Validate

func (r *Responses) Validate(openapi *OpenAPI) error

func (*Responses) Value

func (r *Responses) Value(status string) *Response

type Schema

type Schema struct {
	Ref string `json:"$ref"`
	// json schema
	Type   string `json:"type"` // Value MUST be a string. Multiple types via an array are not supported.
	Format string `json:"format"`
	Enum   []any  `json:"enum"`
	Const  any    `json:"const"` // Use of this keyword is functionally equivalent to an "enum"
	// basic
	Title       string `json:"title"`
	Description string `json:"description"`
	Default     any    `json:"default"`
	Deprecated  bool   `json:"deprecated"`
	ReadOnly    bool   `json:"readOnly"`
	WriteOnly   bool   `json:"writeOnly"`
	Examples    []any  `json:"examples"`
	// number
	MultipleOf       *float64 `json:"multipleOf"`
	Maximum          *float64 `json:"maximum"`          // <=
	ExclusiveMaximum *float64 `json:"exclusiveMaximum"` // <
	Minimum          *float64 `json:"minimum"`          // >=
	ExclusiveMinimum *float64 `json:"exclusiveMinimum"` // >
	// string
	MaxLength        *uint64        `json:"maxLength"`
	MinLength        uint64         `json:"minLength"`
	Pattern          string         `json:"pattern"`
	ContentEncoding  string         `json:"contentEncoding"`
	ContentMediaType string         `json:"contentMediaType"`
	ContentSchema    map[string]any `json:"contentSchema"`
	// array
	Items       *Schema `json:"items"`
	MaxItems    *uint64 `json:"maxItems"`
	MinItems    uint64  `json:"minItems"`
	UniqueItems bool    `json:"uniqueItems"`
	MaxContains *uint64 `json:"maxContains"`
	MinContains *uint64 `json:"minContains"`
	// object
	Properties        map[string]*Schema  `json:"properties"`
	MaxProperties     *uint64             `json:"maxProperties"`
	MinProperties     uint64              `json:"minProperties"`
	Required          []string            `json:"required"`
	DependentRequired map[string][]string `json:"dependentRequired"`

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

	// Adds support for polymorphism. The discriminator is an object name that is used to differentiate between
	// other schemas which may satisfy the payload description. See Composition and Inheritance for more details.
	Discriminator *Discriminator `json:"discriminator"`

	// This MAY be used only on properties schemas. It has no effect on root schemas. Adds additional metadata
	// to describe the XML representation of this property.
	XML *XML `json:"xml"`

	// Additional external documentation for this schema.
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`

	// A free-form property to include an example of an instance for this schema. To represent examples that
	// cannot be naturally represented in JSON or YAML, a string value can be used to contain the example with
	// escaping where necessary.
	// Deprecated: The property has been deprecated in favor of the JSON Schema keyword. Use of is discouraged,
	// and later versions of this specification may remove it. example examples example
	Example any `json:"example"`

	// This object MAY be extended with Specification Extensions, though as noted, additional properties
	// MAY omit the prefix within this object.x-
	Extensions map[string]any
}

func (*Schema) MarshalJSON

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

func (*Schema) UnmarshalJSON

func (s *Schema) UnmarshalJSON(buf []byte) (err error)

func (*Schema) Validate

func (s *Schema) Validate(openapi *OpenAPI) error

type SecurityRequirement

type SecurityRequirement map[string][]string

type SecurityScheme

type SecurityScheme struct {
	Ref string `json:"$ref"`

	// REQUIRED. The type of the security scheme. Valid values are "apiKey" "http" "mutualTLS" "oauth2" "openIdConnect"
	Type string `json:"type"`

	// A description for security scheme. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// REQUIRED. The name of the header, query or cookie parameter to be used.
	Name string `json:"name"`

	// REQUIRED. The location of the API key. Valid values are , or "query" "header" "cookie"
	In string `json:"in"`

	// REQUIRED. The name of the HTTP Authorization scheme to be used in the Authorization header as
	// defined in RFC7235. The values used SHOULD be registered in the IANA Authentication Scheme registry.
	Scheme string `json:"scheme"`

	// A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually
	// generated by an authorization server, so this information is primarily for documentation purposes.
	BearerFormat string `json:"bearerFormat"`

	// REQUIRED. An object containing configuration information for the flow types supported.
	Flows *OAuthFlows `json:"flows"`

	// REQUIRED. OpenId Connect URL to discover OAuth2 configuration values. This MUST be in the
	// form of a URL. The OpenID Connect standard requires the use of TLS.
	OpenIdConnectUrl string `json:"openIdConnectUrl"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*SecurityScheme) MarshalJSON

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

func (*SecurityScheme) UnmarshalJSON

func (s *SecurityScheme) UnmarshalJSON(buf []byte) (err error)

func (*SecurityScheme) Validate

func (s *SecurityScheme) Validate(openapi *OpenAPI) 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"`

	// An optional string describing the host designated by the URL. CommonMark syntax MAY be used
	// for rich text representation.
	Description string `json:"description"`

	// A map between a variable name and its value. The value is used for substitution in the server's URL template.
	Variables map[string]*ServerVariable `json:"variables"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Server) MarshalJSON

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

func (*Server) UnmarshalJSON

func (s *Server) UnmarshalJSON(buf []byte) (err error)

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"`

	// REQUIRED. The default value to use for substitution, which SHALL be sent if an alternate value
	// is not supplied. Note this behavior is different than the Schema Object's treatment of default
	// values, because in those cases parameter values are optional. If the enum is defined, the value
	// MUST exist in the enum's values.
	Default string `json:"default"`

	// An optional description for the server variable. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*ServerVariable) MarshalJSON

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

func (*ServerVariable) UnmarshalJSON

func (s *ServerVariable) UnmarshalJSON(buf []byte) (err error)

func (*ServerVariable) Validate

func (s *ServerVariable) Validate() error

type Tag

type Tag struct {
	// REQUIRED. The name of the tag.
	Name string `json:"name"`

	// A description for the tag. CommonMark syntax MAY be used for rich text representation.
	Description string `json:"description"`

	// Additional external documentation for this tag.
	ExternalDocs *ExternalDocumentation `json:"externalDocs"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*Tag) MarshalJSON

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

func (*Tag) UnmarshalJSON

func (t *Tag) UnmarshalJSON(buf []byte) (err error)

func (*Tag) Validate

func (t *Tag) Validate() error

type XML

type XML struct {
	// Replaces the name of the element/attribute used for the described schema property. When defined
	// within , it will affect the name of the individual XML elements within the list. When defined
	// alongside being (outside the ), it will affect the wrapping element and only if is . If is , it
	// will be ignored. items type array items wrapped true wrapped false
	Name string `json:"name"`

	// The URI of the namespace definition. This MUST be in the form of an absolute URI.
	Namespace string `json:"namespace"`

	// The prefix to be used for the name.
	Prefix string `json:"prefix"`

	// Declares whether the property definition translates to an attribute instead of an element.
	// Default value is. false
	Attribute bool `json:"attribute"`

	// MAY be used only for an array definition. Signifies whether the array is wrapped (for example, ) or
	// unwrapped (). Default value is . The definition takes effect only when defined alongside being
	// (outside the ). false type array items
	Wrapped bool `json:"wrapped"`

	// This object MAY be extended with Specification Extensions.
	Extensions map[string]any
}

func (*XML) MarshalJSON

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

func (*XML) UnmarshalJSON

func (x *XML) UnmarshalJSON(buf []byte) (err error)

func (*XML) Validate

func (x *XML) Validate() error

Jump to

Keyboard shortcuts

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