openapi

package module
v0.0.0-...-8e9364c Latest Latest
Warning

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

Go to latest
Published: May 2, 2021 License: MIT Imports: 2 Imported by: 0

README

OpenAPI

Package openapi implements OpenAPI specification object model types.

Description

Release tags correspond to official OpenAPI specification release tags.

License

MIT. See included LICENSE file.

Documentation

Overview

Package openapi contains object model types for OpenAPI specification v3.1.0

OpenAPI Specification

Version 3.1.0

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 RFC2119 RFC8174 when, and only when, they appear in all capitals, as shown here.

This document is licensed under The Apache License, Version 2.0.

Introduction

The OpenAPI Specification (OAS) defines a standard, language-agnostic interface to HTTP APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection. When properly defined, a consumer can understand and interact with the remote service with a minimal amount of implementation logic.

An OpenAPI definition can then be used by documentation generation tools to display the API, code generation tools to generate servers and clients in various programming languages, testing tools, and many other use cases.

Definitions

OpenAPI Document

A self-contained or composite resource which defines or describes an API or elements of an API. The OpenAPI document MUST contain at least one paths field, a components field or a webhooks field. An OpenAPI document uses and conforms to the OpenAPI Specification.

Path Templating

Path 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 (#).

Media Types

Media type definitions are spread across several resources. The media type definitions SHOULD be in compliance with RFC6838.

Some examples of possible media type definitions:

text/plain; charset=utf-8
application/json
application/vnd.github+json
application/vnd.github.v3+json
application/vnd.github.v3.raw+json
application/vnd.github.v3.text+json
application/vnd.github.v3.html+json
application/vnd.github.v3.full+json
application/vnd.github.v3.diff
application/vnd.github.v3.patch

HTTP Status Codes

The HTTP Status Codes are used to indicate the status of the executed operation. The available status codes are defined by RFC7231 and registered status codes are listed in the IANA Status Code Registry.

Specification

Versions

The OpenAPI Specification is versioned using a major.minor.patch versioning scheme. The major.minor portion of the version string (for example 3.1) SHALL designate the OAS feature set. .patch versions address errors in, or provide clarifications to, this document, not the feature set. Tooling which supports OAS 3.1 SHOULD be compatible with all OAS 3.1.* versions. The patch version SHOULD NOT be considered by tooling, making no distinction between 3.1.0 and 3.1.1 for example.

Occasionally, non-backwards compatible changes may be made in minor versions of the OAS where impact is believed to be low relative to the benefit provided.

An OpenAPI document compatible with OAS 3.*.* contains a required openapi field which designates the version of the OAS that it uses.

Format

An OpenAPI document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either in JSON or YAML format.

For example, if a field has an array value, the JSON array representation will be used:

{
   "field": [ 1, 2, 3 ]
}

All field names in the specification are case sensitive. This includes all fields that are used as keys in a map, except where explicitly noted that keys are case insensitive.

The schema exposes two types of fields: Fixed fields, which have a declared name, and Patterned fields, which declare a regex pattern for the field name.

Patterned fields MUST have unique names within the containing object.

In order to preserve the ability to round-trip between YAML and JSON formats, YAML version 1.2 is RECOMMENDED along with some additional constraints:

Tags MUST be limited to those allowed by the JSON Schema ruleset. Keys used in YAML maps MUST be limited to a scalar string, as defined by the YAML Failsafe schema ruleset. Note: While APIs may be defined by OpenAPI documents in either YAML or JSON format, the API request and response bodies and other content are not required to be JSON or YAML.

Document Structure

An OpenAPI document MAY be made up of a single document or be divided into multiple, connected parts at the discretion of the author. In the latter case, Reference Objects and Schema Object $ref keywords are used.

It is RECOMMENDED that the root OpenAPI document be named: openapi.json or openapi.yaml.

Data Types

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.

As defined by the JSON Schema Validation vocabulary, data types can have an optional modifier property: format. OAS defines additional formats to provide fine detail for primitive data types.

The formats defined by the OAS are:

type	format	Comments
integer	int32	signed 32 bits
integer	int64	signed 64 bits (a.k.a long)
number	float
number	double
string	password	A hint to UIs to obscure input.

Rich Text Formatting

Throughout the specification description fields are noted as supporting CommonMark markdown formatting. Where OpenAPI tooling renders rich text it MUST support, at a minimum, markdown syntax as described by CommonMark 0.27. Tooling MAY choose to ignore some CommonMark features to address security concerns.

Relative References in URIs

Unless specified otherwise, all properties that are URIs MAY be relative references as defined by RFC3986.

Relative references, including those in Reference Objects, PathItem Object $ref fields, Link Object operationRef fields and Example Object externalValue fields, are resolved using the referring document as the Base URI according to RFC3986.

If a URI contains a fragment identifier, then the fragment should be resolved per the fragment resolution mechanism of the referenced document. If the representation of the referenced document is JSON or YAML, then the fragment identifier SHOULD be interpreted as a JSON-Pointer as per RFC6901.

Relative references in Schema Objects, including any that appear as $id values, use the nearest parent $id as a Base URI, as described by JSON Schema Specification Draft 2020-12. If no parent schema contains an $id, then the Base URI MUST be determined according to RFC3986.

Relative References in URLs

Unless specified otherwise, all properties that are URLs MAY be relative references as defined by RFC3986. Unless specified otherwise, relative references are resolved using the URLs defined in the Server Object as a Base URL. Note that these themselves MAY be relative to the referring document.

Schema

In the following description, if a field is not explicitly REQUIRED or described with a MUST or SHALL, it can be considered OPTIONAL.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callback

type Callback struct {
}

Callback Object 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.

type Components

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

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.

type Contact

type Contact struct {
	// The identifying name of the contact person/organization.
	Name string `json:"name,omitempty"`
	// The URL pointing to the contact information. MUST be in the format of a URL.
	URL string `json:"url,omitempty"`
	// The email address of the contact person/organization. MUST be in the
	// format of an email address.
	EMail string `json:"email,omitempty"`
}

Contact Object Contact information for the exposed API.

type Discriminator

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

Discriminator Object When request bodies or response payloads may be one of a number of different schemas, a discriminator object can be used to aid in serialization, deserialization, and validation. The discriminator is a specific object in a schema which is used to inform the consumer of the specification of an alternative schema based on the value associated with it.

When using the discriminator, inline schemas will not be considered.

type Encoding

type Encoding struct {
	// The Content-Type for encoding a specific property. Default value depends
	// on the property type: for string with format being
	// binary – application/octet-stream;
	// for other primitive types – text/plain;
	// for object - application/json;
	// for array – the default is defined based on the inner type. 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"`
	// Holds Map[string, Header Object | Reference Object]
	// A map allowing additional information to be provided as headers, for
	// example Content-Disposition. Content-Type is described separately and
	// SHALL be ignored in this section. This property SHALL be ignored if the
	// request body media type is not a multipart.
	Headers map[string]interface{} `json:"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.
	Style string `json:"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.
	Explode bool `json:"explode,omitempty"`
	// Determines whether the parameter value SHOULD allow reserved characters,
	// as defined by RFC3986 :/?#[]@!$&'()*+,;= to be included without
	// percent-encoding. The default value is false. This property SHALL be
	// ignored if the request body media type is not
	// application/x-www-form-urlencoded.
	AllowReserved bool `json:"allowReserved,omitempty"`
}

Encoding Object A single encoding definition applied to a single schema property.

type Example

type Example struct {
	// Short description for the example.
	Summary string `json:"summary,omitempty"`
	// Long description for the example. CommonMark syntax MAY be used for rich
	// text representation.
	Description string `json:"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 interface{} `json:"value,omitempty"`
	// A URL 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.
	ExternalValue string `json:"externalValue,omitempty"`
}

Example object

type ExternalDocumentation

type ExternalDocumentation struct {
	// A short description of the target documentation. CommonMark syntax MAY be
	// used for rich text representation.
	Description string `json:"description,omitempty"`
	// REQUIRED. The URL for the target documentation. Value MUST be in the
	// format of a URL.
	URL string `json:"url,omitempty"`
}

External Documentation Object Allows referencing an external resource for extended documentation.

type Header struct {
}

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

name MUST NOT be specified, it is given in the corresponding headers map. in MUST NOT be specified, it is implicitly in header. All traits that are affected by the location MUST be applicable to a location of header (for example, style). Header Object Example A simple header of type integer:

{
  "description": "The number of allowed requests in the current period",
  "schema": {
    "type": "integer"
  }
}

description: The number of allowed requests in the current period schema:

type: integer

type Info

type Info struct {
	// REQUIRED. The title of the API.
	Title string `json:"title,omitempty"`
	// A short summary of the API.
	Summary string `json:"summary,omitempty"`
	// A short description of the API. CommonMark syntax MAY be used for rich
	// text representation.
	Description string `json:"description,omitempty"`
	// A URL to the Terms of Service for the API. MUST be in the format of a URL.
	TermsOfService string `json:"termsOfService,omitempty"`
	// The contact information for the exposed API.
	Contact *Contact `json:"contact,omitempty"`
	// The license information for the exposed API.
	License *License `json:"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,omitempty"`
}

Info Object The 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.

type License

type License struct {
	// REQUIRED. The license name used for the API.
	Name string `json:"name,omitempty"`
	// An SPDX license expression for the API. The identifier field is mutually
	// exclusive of the url field.
	Identifier string `json:"identifier,omitempty"`
	// A URL to the license used for the API. MUST be in the format of a URL.
	URL string `json:"url,omitempty"`
}

License Object License information for the exposed API.

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.
	OperationRef string `json:"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"`
	// Holds Map[string, Any | {expression}]
	// A map representing parameters to pass to an operation as specified with
	// operationId or identified via operationRef. The key is the parameter name
	// to be used, whereas the value can be a constant or an expression to be
	// evaluated and passed to the linked operation. The parameter name can be
	// qualified using the parameter location [{in}.]{name} for operations that
	// use the same parameter name in different locations (e.g. path.id).
	Parameters map[string]interface{} `json:"parameters,omitempty"`
	// Any | {expression}
	// A literal value or {expression} to use as a request body when calling the
	// target operation.
	RequestBody interface{} `json:"requestBody,omitempty"`
	// A description of the link. CommonMark syntax MAY be used for rich text
	// representation.
	Description string `json:"description,omitempty"`
	// A server object to be used by the target operation.
	Server *Server `json:"server,omitempty"`
}

Link Object 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 is used for accessing values in an operation and using them as parameters while invoking the linked operation.

type MediaType

type MediaType struct {
	// Contains Schema or Reference object.
	// The schema defining the content of the request, response, or parameter.
	Schema interface{} `json:"schema,omitempty"`
	// Contains Any type.
	// 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 interface{} `json:"example,omitempty"`
	// Holds Map[ string, Example Object | Reference Object]
	// 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 map[string]interface{} `json:"examples,omitempty"`
	// Holds Map[string, Encoding Object]
	// A map between a property name and its encoding information. The key,
	// being the property name, MUST exist in the schema as a property. The
	// encoding object SHALL only apply to requestBody objects when the media
	// type is multipart or application/x-www-form-urlencoded.
	Encoding map[string]*Encoding `json:"encoding,omitempty"`
}

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

type OAuthFlow

type OAuthFlow struct {
	// Applies to: oauth2 ("implicit", "authorizationCode")
	// REQUIRED. The authorization URL to be used for this flow. This MUST be
	// in the form of a URL.
	AuthorizationURL string `json:"authorizationUrl,omitempty"`
	// Applies to: oauth2 ("password", "clientCredentials", "authorizationCode")
	// REQUIRED. The token URL to be used for this flow. This MUST be in the
	// form of a URL.
	TokenURL string `json:"tokenUrl,omitempty"`
	// Applies to: oauth2
	// The URL to be used for obtaining refresh tokens. This MUST be in the form
	// of a URL.
	RefreshURL string `json:"refreshUrl,omitempty"`
	// Applies to: oauth2
	// 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,omitempty"`
}

OAuth Flow Object Configuration details for a supported OAuth Flow

type OAuthFlows

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

OAuth Flows Object Allows configuration of the supported OAuth Flows.

type OpenAPI

type OpenAPI struct {
	// REQUIRED. This string MUST be the semantic version number of the OpenAPI
	// Specification version that the OpenAPI document uses. The openapi field
	// SHOULD be used by tooling specifications and clients to interpret the
	// OpenAPI document. This is not related to the API info.version string.
	OpenAPI string `json:"openapi,omitempty"`
	// REQUIRED. Provides metadata about the API. The metadata MAY be used by
	// tooling as required.
	Info *Info `json:"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.
	JsonSchemaDialect string `json:"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 []*Server `json:"servers,omitempty"`
	// REQUIRED. The available paths and operations for the API.
	Paths *Paths `json:"paths,omitempty"`
	// The incoming webhooks that MAY be received as part of this API and that
	// the API consumer MAY choose to implement. Closely related to the
	// callbacks feature, this section describes requests initiated other than
	// by an API call, for example by an out of band registration. The key name
	// is a unique string to refer to each webhook, while the
	// (optionally referenced) Path Item Object describes a request that may be
	// initiated by the API provider and the expected responses.
	// An example is available:
	// https://github.com/OAI/OpenAPI-Specification/blob/3.1.0/examples/v3.1/webhook-example.yaml
	WebHooks map[string]interface{} `json:"webhooks,omitempty"`
	// An element to hold various schemas for the specification.
	Components *Components `json:"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 []*SecurityRequirement `json:"security,omitempty"`
	// A list of tags used by the specification 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,omitempty"`
	// Additional external documentation.
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}

OpenAPI object. This is the root document object of the OpenAPI document.

func FromJSON

func FromJSON(data []byte) (result *OpenAPI, err error)

Returns an OpenAPI instance from JSON data or an error.

func FromYAML

func FromYAML(data []byte) (result *OpenAPI, err error)

Returns an OpenAPI instance from YAML data or an 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"`
	// A short summary of what the operation does.
	Summary string `json:"summary,omitempty"`
	// A verbose explanation of the operation behavior. CommonMark syntax MAY
	// be used for rich text representation.
	Description string `json:"description,omitempty"`
	// Additional external documentation for this operation.
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
	// Unique string used to identify the operation. The id MUST be unique among
	// all operations described in the API. The operationId value is
	// case-sensitive. Tools and libraries MAY use the operationId to uniquely
	// identify an operation, therefore, it is RECOMMENDED to follow common
	// programming naming conventions.
	OperationID string `json:"operationId,omitempty"`
	// Contains [Parameter Object | Reference Object]
	// 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 []interface{} `json:"parameters,omitempty"`
	// Contains Request Body Object | Reference Object
	// The request body applicable for this operation. The requestBody is only
	// 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, requestBody SHALL be ignored by consumers.
	RequestBody interface{} `json:"requestBody,omitempty"`
	// REQUIRED. The list of possible responses as they are returned from
	// executing this operation.
	Responses *Responses `json:"responses,omitempty"`
	// Contains Map[string, Callback Object | Reference Object]
	//
	// 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]interface{} `json:"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"`
	// A declaration of which security mechanisms can be used for this
	// operation. The list of values includes alternative security requirement
	// objects that can be used. Only one of the security requirement objects
	// need to be satisfied to authorize a request. To make security optional,
	// an empty security requirement ({}) can be included in the array. This
	// definition overrides any declared top-level security. To remove a
	// top-level security declaration, an empty array can be used.
	Security []*SecurityRequirement `json:"security,omitempty"`
	// 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 []*Server `json:"servers,omitempty"`
}

Operation Object Describes a single API operation on a path.

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.
	// 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,omitempty"`
	// REQUIRED. The location of the parameter. Possible values are "query",
	// "header", "path" or "cookie".
	In string `json:"in,omitempty"`
	// 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"`
	// 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"`
	// Specifies that a parameter is deprecated and SHOULD be transitioned out
	// of usage. Default value is false.
	Deprecated bool `json:"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"`

	// 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,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"`
	// 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"`
	// Holds Schema Object | Reference Object
	//
	// The schema defining the type used for the parameter.
	Schema interface{} `json:"schema,omitempty"`
	// Holds Any object.
	//
	// 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 interface{} `json:"example,omitempty"`
	// Holds Map[ string, Example Object | Reference Object]
	//
	// 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 interface{} `json:"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 map[string]*MediaType `json:"content,omitempty"`
}

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

Parameter Locations There are four possible parameter locations specified by the in field:

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

type PathItem

type PathItem struct {
	// Allows for an external definition of this path item. The referenced
	// structure MUST be in the format of a Path Item Object. In case a Path
	// Item Object field appears both in the defined object and the referenced
	// object, the behavior is undefined.
	Ref string `json:"$ref,omitempty"`
	// An optional, string summary, intended to apply to all operations in this
	// path.
	Summary string `json:"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"`
	// A definition of a GET operation on this path.
	Get *Operation `json:"get,omitempty"`
	// A definition of a PUT operation on this path.
	Put *Operation `json:"put,omitempty"`
	// A definition of a POST operation on this path.
	Post *Operation `json:"post,omitempty"`
	// A definition of a DELETE operation on this path.
	Delete *Operation `json:"delete,omitempty"`
	// A definition of a OPTIONS operation on this path.
	Options *Operation `json:"options,omitempty"`
	// A definition of a HEAD operation on this path.
	Head *Operation `json:"head,omitempty"`
	// A definition of a PATCH operation on this path.
	Patch *Operation `json:"patch,omitempty"`
	// A definition of a TRACE operation on this path.
	Trace *Operation `json:"trace,omitempty"`
	// An alternative server array to service all operations in this path.
	Servers []*Server `json:"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 []interface{} `json:"parameters,omitempty"`
}

Path Item Object 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.

type Paths

type Paths struct {
}

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

type Reference

type Reference struct {
	// REQUIRED. The reference string.
	Ref string `json:"$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"`
	// 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"`
}

Reference Object A simple object to allow referencing other components in the specification,

internally and externally.

The Reference Object is defined by JSON Reference and follows the same structure, behavior and rules.

For this specification, reference resolution is accomplished as defined by the JSON Reference specification and not by the JSON Schema specification.

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"`
	// 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,omitempty"`
	// Determines if the request body is required in the request. Defaults to
	// false.
	Required bool `json:"required,omitempty"`
}

Request Body Object Describes a single request body.

type Response

type Response struct {
	// REQUIRED. A short description of the response. CommonMark syntax MAY be
	// used for rich text representation.
	Description string `json:"description,omitempty"`
	// Holds Map[string, Header Object | Reference Object]
	//
	// Maps a header name to its definition. RFC7230 states header names are
	// case insensitive. If a response header is defined with the name
	// "Content-Type", it SHALL be ignored.
	Headers map[string]interface{} `json:"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 map[string]*MediaType `json:"content,omitempty"`
	// Holds Map[string, Link Object | Reference Object]
	//
	// 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]interface{} `json:"links,omitempty"`
}

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

type Responses

type Responses struct {
	// Contains Response Object | Reference Object
	//
	// The documentation of responses other than the ones declared for specific
	// HTTP response codes. Use this field to cover undeclared responses. A
	// Reference Object can link to a response that the OpenAPI Object's
	// components/responses section defines.
	Default interface{}
}

Responses Object 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 specification.

The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call.

type Schema

type Schema struct {
	// Adds support for polymorphism. The discriminator is an object name that
	// is used to differentiate between other schemas which may satisfy the
	// payload description. See Composition and Inheritance for more details.
	Discriminator *Discriminator `json:"discriminator,omitempty"`
	// 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,omitempty"`
	// Additional external documentation for this schema.
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
	// A free-form property to include an example of an instance for this
	// schema. To represent examples that cannot be naturally represented in
	// JSON or YAML, a string value can be used to contain the example with
	// escaping where necessary.
	//
	// Deprecated: The example property has been deprecated in favor of the
	// JSON Schema examples keyword. Use of example is discouraged, and later
	// versions of this specification may remove it.
	Example interface{} `json:"example,omitempty"`
}

Schema Object 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.

Properties The OpenAPI Schema Object dialect is defined as requiring the OAS base vocabulary, in addition to the vocabularies as specified in the JSON Schema draft 2020-12 general purpose meta-schema.

The OpenAPI Schema Object dialect for this version of the specification is identified by the URI https://spec.openapis.org/oas/3.1/dialect/base (the "OAS dialect schema id").

The following properties are taken from the JSON Schema specification but their definitions have been extended by the OAS:

description - CommonMark syntax MAY be used for rich text representation. format - See Data Type Formats for further details. While relying on JSON Schema's defined formats, the OAS offers a few additional predefined formats. In addition to the JSON Schema properties comprising the OAS dialect, the Schema Object supports keywords from any other vocabularies, or entirely arbitrary properties.

The OpenAPI Specification's base vocabulary is comprised of the following keywords:

type SecurityRequirement

type SecurityRequirement struct {
}

Security Requirement Object 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.

type SecurityScheme

type SecurityScheme struct {
	// Applies to Any.
	// REQUIRED. The type of the security scheme. Valid values are "apiKey",
	// "http", "oauth2", "openIdConnect".
	Type string `json:"type,omitempty"`
	// Applies to Any.
	// A short description for security scheme. CommonMark syntax MAY be used
	// for rich text representation.
	Description string `json:"description,omitempty"`
	// Applies to: apiKey.
	// REQUIRED. The name of the header, query or cookie parameter to be used.
	Name string `json:"name,omitempty"`
	// Applies to: apiKey.
	// REQUIRED. The location of the API key. Valid values are "query", "header"
	// or "cookie".
	In string `json:"in,omitempty"`
	// Applies to: http
	// 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,omitempty"`
	// Applies to: http ("bearer")
	// 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,omitempty"`
	// Applies to: oauth2
	// REQUIRED. An object containing configuration information for the flow
	// types supported.
	Flows *OAuthFlows `json:"flows,omitempty"`
	// Applies to: openIdConnect
	// REQUIRED. OpenId Connect URL to discover OAuth2 configuration values.
	// This MUST be in the form of a URL.
	OpenIDConnectURL string `json:"openIdConnectUrl,omitempty"`
}

Security Scheme Object Defines a security scheme that can be used by the operations. Supported schemes are HTTP authentication, an API key (either as a header, a cookie parameter or as a query parameter), OAuth2's common flows (implicit, password, client credentials and authorization code) as defined in RFC6749, and OpenID Connect Discovery.

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,omitempty"`
	// An optional string describing the host designated by the URL. CommonMark
	// syntax MAY be used for rich text representation.
	Description string `json:"description,omitempty"`
	// 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,omitempty"`
}

Server Object An object representing a Server.

type ServerVariable

type ServerVariable struct {
	// An enumeration of string values to be used if the substitution options
	// are from a limited set. The array SHOULD NOT be empty.
	Enum []string `json:"enum,omitempty"`
	// REQUIRED. The default value to use for substitution, which SHALL be sent
	// if an alternate value is not supplied. 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
	// SHOULD exist in the enum's values.
	Default string `json:"default,omitempty"`
	// An optional description for the server variable. CommonMark syntax MAY
	// be used for rich text representation.
	Description string `json:"description,omitempty"`
}

Server Variable Object An object representing a Server Variable for server URL template substitution.

type Tag

type Tag struct {
	// REQUIRED. The name of the tag.
	Name string `json:"name,omitempty"`
	// A short description for the tag. CommonMark syntax MAY be used for rich
	// text representation.
	Description string `json:"description,omitempty"`
	// Additional external documentation for this tag.
	ExternalDocs *ExternalDocumentation `json:"externalDocs,omitempty"`
}

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

type XML

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

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

When using arrays, XML element names are not inferred (for singular/plural forms) and the name property SHOULD be used to add that information. See examples for expected behavior.

Jump to

Keyboard shortcuts

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