Movatterモバイル変換


[0]ホーム

URL:


OpenAPI Initiative

OpenAPI Specification v3.1.2

Version 3.1.2

More details about this document
This version:
https://spec.openapis.org/oas/v3.1.2.html
Latest published version:
https://spec.openapis.org/oas/latest.html
Latest editor's draft:
https://github.com/OAI/OpenAPI-Specification/
Editors:
Henry Andrews
Jeremy Whitlock
Karen Etheridge
Lorna Mitchell
Marsh Gardiner
Miguel Quintero
Mike Kistler
Ralf Handl
Vincent Biret
Former editors:
Ron Ratovsky
Darrel Miller
Mike Ralphson
Uri Sarid
Jason Harmon
Tony Tam
Other versions:
https://spec.openapis.org/oas/v3.2.0.html
https://spec.openapis.org/oas/v3.1.1.html
https://spec.openapis.org/oas/v3.1.0.html
https://spec.openapis.org/oas/v3.0.4.html
https://spec.openapis.org/oas/v3.0.3.html
https://spec.openapis.org/oas/v3.0.2.html
https://spec.openapis.org/oas/v3.0.1.html
https://spec.openapis.org/oas/v3.0.0.html
https://spec.openapis.org/oas/v2.0.html
Participate
GitHub OAI/OpenAPI-Specification
File a bug
Commit history
Pull requests

Copyright © 2025 the Linux Foundation


What is the OpenAPI Specification?

The OpenAPI Specification (OAS) defines a standard, programming language-agnostic interface description for HTTP APIs, which allows both humans and computers to discover and understand the capabilities of a service without requiring access to source code, additional documentation, or inspection of network traffic. When properly defined via OpenAPI, a consumer can understand and interact with the remote service with a minimal amount of implementation logic. Similar to what interface descriptions have done for lower-level programming, the OpenAPI Specification removes guesswork in calling a service.

Status of This Document

The source-of-truth for this specification is the HTML file referenced above asThis version.

1.OpenAPI Specification

1.1Version 3.1.2

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 inBCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.

This document is licensed underThe Apache License, Version 2.0.

2.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 Description 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.

For examples of OpenAPI usage and additional documentation, please visit [OpenAPI-Learn].

For extension registries and other specifications published by the OpenAPI Initiative, as well as the authoritative rendering of this specification, please visitspec.openapis.org.

3.Definitions

3.1OpenAPI Description

An OpenAPI Description (OAD) formally describes the surface of an API and its semantics. It is composed of anentry document, which must be an OpenAPI Document, and any/all of its referenced documents. An OAD uses and conforms to the OpenAPI Specification, andMUST contain at least onepaths field,components field, orwebhooks field.

3.2OpenAPI Document

An OpenAPI Document is a single JSON or YAML document that conforms to the OpenAPI Specification. An OpenAPI Document compatible with OAS 3.*.* contains a requiredopenapi field which designates the version of the OAS that it uses.

3.3Schema

A “schema” is a formal description of syntax and structure.This document serves as theschema for the OpenAPI Specification format; a non-authoritative JSON Schema based on this document is also provided onspec.openapis.org for informational purposes.This specification alsouses schemas in the form of theSchema Object.

3.4Object

When capitalized, the word “Object” refers to any of the Objects that are named by section headings in this document.

3.5Path 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 pathMUST correspond to a path parameter that is included in thePath Item itself and/or in each of the Path Item’sOperations. 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 parametersMUST NOT contain any unescaped “generic syntax” characters described by [RFC3986]Section 3: forward slashes (/), question marks (?), or hashes (#).SeeURL Percent-Encoding for additional guidance on escaping characters.

3.6Media Types

Media type definitions are spread across several resources.The media type definitionsSHOULD 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

3.7HTTP Status Codes

The HTTP Status Codes are used to indicate the status of the executed operation.Status codesSHOULD be selected from the available status codes registered in theIANA Status Code Registry.

3.8Case Sensitivity

As most field names and values in the OpenAPI Specification are case-sensitive, this document endeavors to call out any case-insensitive names and values.However, the case sensitivity of field names and values that map directly to HTTP concepts follow the case sensitivity rules of HTTP, even if this document does not make a note of every concept.

3.9Undefined and Implementation-Defined Behavior

This specification deems certain situations to have eitherundefined orimplementation-defined behavior.

Behavior described asundefined is likely, at least in some circumstances, to result in outcomes that contradict the specification.This description is used when detecting the contradiction is impossible or impractical.ImplementationsMAY support undefined scenarios for historical reasons, including ambiguous text in prior versions of the specification.This support might produce correct outcomes in many cases, but relying on it isNOT RECOMMENDED as there is no guarantee that it will work across all tools or with future specification versions, even if those versions are otherwise strictly compatible with this one.

Behavior described asimplementation-defined allows implementations to choose which of several different-but-compliant approaches to a requirement to implement.This documents ambiguous requirements that API description authors areRECOMMENDED to avoid in order to maximize interoperability.Unlike undefined behavior, it is safe to rely on implementation-defined behavior ifand only if it can be guaranteed that all relevant tools support the same behavior.

4.Specification

4.1Versions

The OpenAPI Specification is versioned using amajor.minor.patch versioning scheme. Themajor.minor portion of the version string (for example3.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.1SHOULD be compatible with all OAS 3.1.* versions. The patch versionSHOULD NOT be considered by tooling, making no distinction between3.1.0 and3.1.1 for example.

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

4.2Format

An OpenAPI Document that conforms to the OpenAPI Specification is itself a JSON object, which may be represented either inJSON orYAML 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 arecase sensitive.This includes all fields that are used as keys in a map, except where explicitly noted that keys arecase insensitive.

Theschema exposes two types of fields:fixed fields, which have a declared name, andpatterned fields, which have a declared pattern for the field name.

Patterned fieldsMUST 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 isRECOMMENDED along with some additional constraints:

Note: While APIs may be described by OpenAPI Descriptions in either YAML or JSON format, the API request and response bodies and other content are not required to be JSON or YAML.

4.3OpenAPI Description Structure

An OpenAPI Description (OAD)MAY be made up of a single JSON or YAML document or be divided into multiple, connected parts at the discretion of the author. In the latter case,Reference Object,Path Item Object andSchema Object$ref fields, as well as theLink ObjectoperationRef field, and the URI form of theDiscriminator Objectmapping field, are used to identify the referenced elements.

In a multi-document OAD, the document containing the OpenAPI Object where parsing begins is known as that OAD’sentry document.

It isRECOMMENDED that the entry document of an OAD be named:openapi.json oropenapi.yaml.

4.3.1Parsing Documents

In order to properly handleSchema Objects, OAS 3.1 inherits the parsing requirements ofJSON Schema Specification Draft 2020-12, with appropriate modifications regarding base URIs as specified inRelative References In URIs.

This includes a requirement to parse complete documents before deeming a Schema Object reference to be unresolvable, in order to detect keywords that might provide the reference target or impact the determination of the appropriate base URI.

ImplementationsMAY support complete-document parsing in any of the following ways:

  • Detecting OpenAPI or JSON Schema documents using media types
  • Detecting OpenAPI documents through the rootopenapi field
  • Detecting JSON Schema documents through detecting keywords or otherwise successfully parsing the document in accordance with the JSON Schema specification
  • Detecting a document containing a referenceable Object at its root based on the expected type of the reference
  • Allowing users to configure the type of documents that might be loaded due to a reference to a non-root Object

Implementations that parse referenced fragments of OpenAPI content without regard for the content of the rest of the containing document will miss keywords that change the meaning and behavior of the reference target.In particular, failing to take into account keywords that change the base URI introduces security risks by causing references to resolve to unintended URIs, with unpredictable results.While some implementations support this sort of parsing due to the requirements of past versions of this specification, in version 3.1, the result of parsing fragments in isolation isundefined and likely to contradict the requirements of this specification.

While it is possible to structure certain OpenAPI Descriptions to ensure that they will behave correctly when references are parsed as isolated fragments, depending on this isNOT RECOMMENDED.This specification does not explicitly enumerate the conditions under which such behavior is safe and provides no guarantee for continued safety in any future versions of the OAS.

A special case of parsing fragments of OAS content would be if such fragments are embedded in another format, referred to as anembedding format with respect to the OAS.Note that the OAS itself is an embedding format with respect to JSON Schema, which is embedded as Schema Objects.It is the responsibility of an embedding format to define how to parse embedded content, and OAS implementations that do not document support for an embedding format cannot be expected to parse embedded OAS content correctly.

4.3.2Structural Interoperability

JSON or YAML objects within an OAD are interpreted as specific Objects (such asOperation Objects,Response Objects,Reference Objects, etc.) based on their context. Depending on how references are arranged, a given JSON or YAML object can be interpreted in multiple different contexts:

  • As the root object of theentry document, which is always interpreted as an OpenAPI Object
  • As the Object type implied by its parent Object within the document
  • As a reference target, with the Object type matching the reference source’s context

If the same JSON/YAML object is parsed multiple times and the respective contexts require it to be parsed asdifferent Object types, the resulting behavior isimplementation defined, andMAY be treated as an error if detected. An example would be referencing an empty Schema Object under#/components/schemas where a Path Item Object is expected, as an empty object is valid for both types. For maximum interoperability, it isRECOMMENDED that OpenAPI Description authors avoid such scenarios.

4.3.3Resolving Implicit Connections

Several features of this specification require resolution of non-URI-based connections to some other part of the OpenAPI Description (OAD).

These connections are unambiguously resolved in single-document OADs, but the resolution process in multi-document OADs isimplementation-defined, within the constraints described in this section.In some cases, an unambiguous URI-based alternative is available, and OAD authors areRECOMMENDED to always use the alternative:

SourceTargetAlternative
Security Requirement Object{name}Security Scheme Object name under theComponents Objectn/a
Discriminator Objectmapping(implicit, or explicit name syntax)Schema Object name under the Components Objectmapping(explicit URI syntax)
Operation ObjecttagsTag Objectname (in theOpenAPI Object’stags array)n/a
Link ObjectoperationIdOperation ObjectoperationIdoperationRef

A fifth implicit connection involves appending the templated URL paths of thePaths Object to the appropriateServer Object’surl field.This is unambiguous because only the entry document’s Paths Object contributes URLs to the described API.

It isRECOMMENDED to consider all Operation Objects from all parsed documents when resolving any Link ObjectoperationId.This requires parsing all referenced documents prior to determining anoperationId to be unresolvable.

The implicit connections in the Security Requirement Object and Discriminator Object rely on thecomponent name, which is the name of the property holding the component in the appropriately typed sub-object of the Components Object.For example, the component name of the Schema Object at#/components/schemas/Foo isFoo.The implicit connection oftags in the Operation Object uses thename field of Tag Objects, which (like the Components Object) are found under the root OpenAPI Object.This means resolving component names and tag names both depend on starting from the correct OpenAPI Object.

For resolving component and tag name connections from a referenced (non-entry) document, it isRECOMMENDED that tools resolve from the entry document, rather than the current document.This allows Security Scheme Objects and Tag Objects to be defined next to the API’s deployment information (the top-level array of Server Objects), and treated as an interface for referenced documents to access.

The interface approach can also work for Discriminator Objects and Schema Objects, but it is also possible to keep the Discriminator Object’s behavior within a single document using the relative URI-reference syntax ofmapping.

There are no URI-based alternatives for the Security Requirement Object or for the Operation Object’stags field.These limitations are expected to be addressed in a future release.

SeeAppendix F: Resolving Security Requirements in a Referenced Document for an example of the possible resolutions, including which one is recommended by this section.The behavior for Discriminator Object non-URI mappings and for the Operation Object’stags field operate on the same principles.

Note that no aspect of implicit connection resolution changes howURIs are resolved, or restricts their possible targets.

4.4Data Types

Data types in the OAS are based on the types defined by theJSON Schema Validation Specification Draft 2020-12:“null”, “boolean”, “object”, “array”, “number”, “string”, or “integer”.Models are defined using theSchema Object, which is a superset of the JSON Schema Specification Draft 2020-12.

JSON Schema keywords andformat values operate on JSON “instances” which may be one of the six JSON data types, “null”, “boolean”, “object”, “array”, “number”, or “string”, with certain keywords and formats only applying to a specific type. For example, thepattern keyword and thedate-time format only apply to strings, and treat any instance of the other five types asautomatically valid. This means JSON Schema keywords and formats doNOT implicitly require the expected type. Use thetype keyword to explicitly constrain the type.

Note that thetype keyword allows"integer" as a value for convenience, but keyword and format applicability does not recognize integers as being of a distinct JSON type from other numbers becauseJSON itself does not make that distinction. Since there is no distinct JSON integer type, JSON Schema defines integers mathematically. This means that both1 and1.0 areequivalent, and are both considered to be integers.

4.4.1Data Type Format

As defined by theJSON Schema Validation specification, data types can have an optional modifier keyword:format. As described in that specification,format is treated as a non-validating annotation by default; the ability to validateformat varies across implementations.

The OpenAPI Initiative also hosts aFormat Registry for formats defined by OAS users and other specifications. Support for any registered format is strictlyOPTIONAL, and support for one registered format does not imply support for any others.

Types that are not accompanied by aformat keyword follow the type definition in the JSON Schema. Tools that do not recognize a specificformatMAY default back to thetype alone, as if theformat is not specified.For the purpose ofJSON Schema validation, each format should specify the set of JSON data types for which it applies. In this registry, these types are shown in the “JSON Data Type” column.

The formats defined by the OAS are:

formatJSON Data TypeComments
int32numbersigned 32 bits
int64numbersigned 64 bits (a.k.a long)
floatnumber
doublenumber
passwordstringA hint to obscure the value.

As noted underData Type, bothtype: number andtype: integer are considered to be numbers in the data model.

4.4.2Working with Binary Data

The OAS can describe eitherraw orencoded binary data.

  • raw binary is used where unencoded binary data is allowed, such as when sending a binary payload as the entire HTTP message body, or as part of amultipart/* payload that allows binary parts
  • encoded binary is used where binary data is embedded in a text-only format such asapplication/json orapplication/x-www-form-urlencoded (either as a message body or in the URL query string).

In the following table showing how to use Schema Object keywords for binary data, we useimage/png as an example binary media type. Any binary media type, includingapplication/octet-stream, is sufficient to indicate binary content.

KeywordRawEncodedComments
typeomitstringraw binary isoutside oftype
contentMediaTypeimage/pngimage/pngcan sometimes be omitted if redundant (see below)
contentEncodingomitbase64 or base64urlother encodings areallowed

Note that the encoding indicated bycontentEncoding, which inflates the size of data in order to represent it as 7-bit ASCII text, is unrelated to HTTP’sContent-Encoding header, which indicates whether and how a message body has been compressed and is applied after all content serialization described in this section has occurred. Since HTTP allows unencoded binary message bodies, there is no standardized HTTP header for indicating base64 or similar encoding of an entire message body.

Using acontentEncoding ofbase64url ensures that URL encoding (as required in the query string and in message bodies of typeapplication/x-www-form-urlencoded) does not need to further encode any part of the already-encoded binary data.

ThecontentMediaType keyword is redundant if the media type is already set:

If theSchema Object will be processed by a non-OAS-aware JSON Schema implementation, it may be useful to includecontentMediaType even if it is redundant. However, ifcontentMediaType contradicts a relevant Media Type Object or Encoding Object, thencontentMediaTypeSHALL be ignored.

ThemaxLength keywordMAY be used to set an expected upper bound on the length of a streaming payload. The keyword can be applied to either string data, including encoded binary data, or to unencoded binary data. For unencoded binary, the length is the number of octets.

4.4.2.1Migrating binary descriptions from OAS 3.0

The following table shows how to migrate from OAS 3.0 binary data descriptions, continuing to useimage/png as the example binary media type:

OAS < 3.1OAS 3.1Comments
type: string
format: binary
contentMediaType: image/pngif redundant, can be omitted, often resulting in an emptySchema Object
type: string
format: byte
type: string
contentMediaType: image/png
contentEncoding: base64
note thatbase64url can be used to avoid re-encoding the base64 string to be URL-safe

4.5Rich Text Formatting

Throughout the specificationdescription fields are noted as supporting [CommonMark] markdown formatting.Where OpenAPI tooling renders rich text itMUST support, at a minimum, markdown syntax as described by [CommonMark-0.27]. ToolingMAY choose to ignore some CommonMark or extension features to address security concerns.

While the framing of CommonMark 0.27 as a minimum requirement means that toolingMAY choose to implement extensions on top of it, note that any such extensions are by definition implementation-defined and will not be interoperable.OpenAPI Description authorsSHOULD consider how text using such extensions will be rendered by tools that offer only the minimum support.

4.6Relative References in API Description URIs

URIs used as references within an OpenAPI Description, or to external documentation or other supplementary information such as a license, are resolved asidentifiers, and described by this specification asURIs.As noted underParsing Documents, this specification inherits JSON Schema Specification Draft 2020-12’s requirements forloading documents and associating them with their expected URIs, which might not match their current location.This feature is used both for working in development or test environments without having to change the URIs, and for working within restrictive network configurations or security policies.

Note that some URI fields are namedurl for historical reasons, but the descriptive text for those fields uses the correct “URI” terminology.

Unless specified otherwise, all fields that are URIsMAY be relative references as defined by [RFC3986]Section 4.2.

Relative references inSchema Objects, including any that appear as$id values, use the nearest parent$id as a Base URI, as described byJSON Schema Specification Draft 2020-12.

Relative URI references in other Objects, and in Schema Objects where no parent schema contains an$id,MUST be resolved using the referring document’s base URI, which is determined in accordance with [RFC3986]Section 5.1.2 – 5.1.4.In practice, this is usually the retrieval URI of the document, whichMAY be determined based on either its current actual location or a user-supplied expected location.

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 identifierSHOULD be interpreted as a JSON-Pointer as per [RFC6901].

Relative references in CommonMark hyperlinks are resolved in their rendered context, which might differ from the context of the API description.

4.7Relative References in API URLs

API endpoints are by definition accessed as locations, and are described by this specification asURLs.

Unless specified otherwise, all fields that are URLsMAY be relative references as defined by [RFC3986]Section 4.2.Unless specified otherwise, relative references are resolved using the URLs defined in theServer Object as a Base URL. Note that these themselvesMAY be relative to the referring document.

4.8Schema

This section describes the structure of the OpenAPI Description format.This text is the only normative description of the format.A JSON Schema is hosted onspec.openapis.org for informational purposes.If the JSON Schema differs from this section, then this sectionMUST be considered authoritative.

In the following description, if a field is not explicitlyREQUIRED or described with aMUST orSHALL, it can be consideredOPTIONAL.

4.8.1OpenAPI Object

This is the root object of theOpenAPI Description.

4.8.1.1Fixed Fields
Field NameTypeDescription
openapistringREQUIRED. This stringMUST be theversion number of the OpenAPI Specification that the OpenAPI Document uses. Theopenapi fieldSHOULD be used by tooling to interpret the OpenAPI Document. This isnot related to theinfo.version string, which is the version of the OpenAPI Document.
infoInfo ObjectREQUIRED. Provides metadata about the API. The metadataMAY be used by tooling as required.
jsonSchemaDialectstringThe default value for the$schema keyword withinSchema Objects contained within this OAS document. ThisMUST be in the form of a URI.
servers[Server Object]An array of Server Objects, which provide connectivity information to a target server. If theservers field is not provided, or is an empty array, the default value would be aServer Object with aurl value of/.
pathsPaths ObjectThe available paths and operations for the API.
webhooksMap[string,Path Item Object]The incoming webhooks thatMAY be received as part of this API and that the API consumerMAY choose to implement. Closely related to thecallbacks 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. Anexample is available.
componentsComponents ObjectAn element to hold various Objects for the OpenAPI Description.
security[Security Requirement Object]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. The list can be incomplete, up to being empty or absent. To make security explicitly optional, an empty security requirement ({}) can be included in the array.
tags[Tag Object]A list of tags used by the OpenAPI Description 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 theOperation Object must be declared. The tags that are not declaredMAY be organized randomly or based on the tools’ logic. Each tag name in the listMUST be unique.
externalDocsExternal Documentation ObjectAdditional external documentation.

This objectMAY be extended withSpecification Extensions.

4.8.2Info Object

The object provides metadata about the API.The metadataMAY be used by the clients if needed, andMAY be presented in editing or documentation generation tools for convenience.

4.8.2.1Fixed Fields
Field NameTypeDescription
titlestringREQUIRED. The title of the API.
summarystringA short summary of the API.
descriptionstringA description of the API. [CommonMark] syntaxMAY be used for rich text representation.
termsOfServicestringA URI for the Terms of Service for the API. ThisMUST be in the form of a URI.
contactContact ObjectThe contact information for the exposed API.
licenseLicense ObjectThe license information for the exposed API.
versionstringREQUIRED. The version of the OpenAPI Document (which is distinct from theOpenAPI Specification version or the version of the API being described or the version of the OpenAPI Description).

This objectMAY be extended withSpecification Extensions.

4.8.2.2Info Object Example
{"title":"Example Pet Store App","summary":"A pet store manager.","description":"This is an example server for a pet store.","termsOfService":"https://example.com/terms/","contact":{"name":"API Support","url":"https://www.example.com/support","email":"support@example.com"},"license":{"name":"Apache 2.0","url":"https://www.apache.org/licenses/LICENSE-2.0.html"},"version":"1.0.1"}
title:ExamplePetStoreAppsummary:Apetstoremanager.description:Thisisanexampleserverforapetstore.termsOfService:https://example.com/terms/contact:name:APISupporturl:https://www.example.com/supportemail:support@example.comlicense:name:Apache2.0url:https://www.apache.org/licenses/LICENSE-2.0.htmlversion:1.0.1

4.8.3Contact Object

Contact information for the exposed API.

4.8.3.1Fixed Fields
Field NameTypeDescription
namestringThe identifying name of the contact person/organization.
urlstringThe URI for the contact information. ThisMUST be in the form of a URI.
emailstringThe email address of the contact person/organization. ThisMUST be in the form of an email address.

This objectMAY be extended withSpecification Extensions.

4.8.3.2Contact Object Example
{"name":"API Support","url":"https://www.example.com/support","email":"support@example.com"}
name:APISupporturl:https://www.example.com/supportemail:support@example.com

4.8.4License Object

License information for the exposed API.

4.8.4.1Fixed Fields
Field NameTypeDescription
namestringREQUIRED. The license name used for the API.
identifierstringAn [SPDX-Licenses] expression for the API. Theidentifier field is mutually exclusive of theurl field.
urlstringA URI for the license used for the API. ThisMUST be in the form of a URI. Theurl field is mutually exclusive of theidentifier field.

This objectMAY be extended withSpecification Extensions.

4.8.4.2License Object Example
{"name":"Apache 2.0","identifier":"Apache-2.0"}
name:Apache2.0identifier:Apache-2.0

4.8.5Server Object

An object representing a Server.

4.8.5.1Fixed Fields
Field NameTypeDescription
urlstringREQUIRED. A URL to the target host. This URL supports Server Variables andMAY be relative, to indicate that the host location is relative to the location where the document containing the Server Object is being served. Query and fragmentMUST NOT be part of this URL. Variable substitutions will be made when a variable is named in{braces}.
descriptionstringAn optional string describing the host designated by the URL. [CommonMark] syntaxMAY be used for rich text representation.
variablesMap[string,Server Variable Object]A map between a variable name and its value. The value is used for substitution in the server’s URL template.

This objectMAY be extended withSpecification Extensions.

4.8.5.2Server Object Example

A single server would be described as:

{"url":"https://development.gigantic-server.com/v1","description":"Development server"}
url:https://development.gigantic-server.com/v1description:Developmentserver

The following shows how multiple servers can be described, for example, at the OpenAPI Object’sservers:

{"servers":[{"url":"https://development.gigantic-server.com/v1","description":"Development server"},{"url":"https://staging.gigantic-server.com/v1","description":"Staging server"},{"url":"https://api.gigantic-server.com/v1","description":"Production server"}]}
servers:-url:https://development.gigantic-server.com/v1description:Developmentserver-url:https://staging.gigantic-server.com/v1description:Stagingserver-url:https://api.gigantic-server.com/v1description:Productionserver

The following shows how variables can be used for a server configuration:

{"servers":[{"url":"https://{username}.gigantic-server.com:{port}/{basePath}","description":"The production API server","variables":{"username":{"default":"demo","description":"A user-specific subdomain. Use `demo` for a free sandbox environment."},"port":{"enum":["8443","443"],"default":"8443"},"basePath":{"default":"v2"}}}]}
servers:-url:https://{username}.gigantic-server.com:{port}/{basePath}description:TheproductionAPIservervariables:username:# note! no enum here means it is an open valuedefault:demodescription:Auser-specificsubdomain.Use`demo`forafreesandboxenvironment.port:enum:-'8443'-'443'default:'8443'basePath:# open meaning there is the opportunity to use special base paths as assigned by the provider, default is "v2"default:v2

4.8.6Server Variable Object

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

4.8.6.1Fixed Fields
Field NameTypeDescription
enum[string]An enumeration of string values to be used if the substitution options are from a limited set. The arrayMUST NOT be empty.
defaultstringREQUIRED. The default value to use for substitution, whichSHALL be sent if an alternate value isnot supplied. If theenum is defined, the valueMUST exist in the enum’s values. Note that this behavior is different from theSchema Object’sdefault keyword, which documents the receiver’s behavior rather than inserting the value into the data.
descriptionstringAn optional description for the server variable. [CommonMark] syntaxMAY be used for rich text representation.

This objectMAY be extended withSpecification Extensions.

4.8.7Components 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 outside the Components Object.

4.8.7.1Fixed Fields
Field NameTypeDescription
schemasMap[string,Schema Object]An object to hold reusableSchema Objects.
responsesMap[string,Response Object |Reference Object]An object to hold reusableResponse Objects.
parametersMap[string,Parameter Object |Reference Object]An object to hold reusableParameter Objects.
examplesMap[string,Example Object |Reference Object]An object to hold reusableExample Objects.
requestBodiesMap[string,Request Body Object |Reference Object]An object to hold reusableRequest Body Objects.
headersMap[string,Header Object |Reference Object]An object to hold reusableHeader Objects.
securitySchemesMap[string,Security Scheme Object |Reference Object]An object to hold reusableSecurity Scheme Objects.
linksMap[string,Link Object |Reference Object]An object to hold reusableLink Objects.
callbacksMap[string,Callback Object |Reference Object]An object to hold reusableCallback Objects.
pathItemsMap[string,Path Item Object]An object to hold reusablePath Item Objects.

This objectMAY be extended withSpecification Extensions.

All the fixed fields declared above are objects thatMUST use keys that match the regular expression:^[a-zA-Z0-9\.\-_]+$.

Field Name Examples:

UserUser_1User_Nameuser-namemy.org.User
4.8.7.2Components Object Example
"components":{"schemas":{"GeneralError":{"type":"object","properties":{"code":{"type":"integer","format":"int32"},"message":{"type":"string"}}},"Category":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}}},"Tag":{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}}}},"parameters":{"skipParam":{"name":"skip","in":"query","description":"number of items to skip","required":true,"schema":{"type":"integer","format":"int32"}},"limitParam":{"name":"limit","in":"query","description":"max records to return","required":true,"schema":{"type":"integer","format":"int32"}}},"responses":{"NotFound":{"description":"Entity not found."},"IllegalInput":{"description":"Illegal input for operation."},"GeneralError":{"description":"General Error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/GeneralError"}}}}},"securitySchemes":{"api_key":{"type":"apiKey","name":"api-key","in":"header"},"petstore_auth":{"type":"oauth2","flows":{"implicit":{"authorizationUrl":"https://example.org/api/oauth/dialog","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}}}}}}
components:schemas:GeneralError:type:objectproperties:code:type:integerformat:int32message:type:stringCategory:type:objectproperties:id:type:integerformat:int64name:type:stringTag:type:objectproperties:id:type:integerformat:int64name:type:stringparameters:skipParam:name:skipin:querydescription:numberofitemstoskiprequired:trueschema:type:integerformat:int32limitParam:name:limitin:querydescription:maxrecordstoreturnrequired:trueschema:type:integerformat:int32responses:NotFound:description:Entitynotfound.IllegalInput:description:Illegalinputforoperation.GeneralError:description:GeneralErrorcontent:application/json:schema:$ref:'#/components/schemas/GeneralError'securitySchemes:api_key:type:apiKeyname:api-keyin:headerpetstore_auth:type:oauth2flows:implicit:authorizationUrl:https://example.org/api/oauth/dialogscopes:write:pets:modifypetsinyouraccountread:pets:readyourpets

4.8.8Paths Object

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

4.8.8.1Patterned Fields
Field PatternTypeDescription
/{path}Path Item ObjectA relative path to an individual endpoint. The field nameMUST begin with a forward slash (/). The path isappended (no relative URL resolution) to the expanded URL from theServer Object’surl 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 namesMUST NOT exist as they are identical. In case of ambiguous matching, it’s up to the tooling to decide which one to use.

This objectMAY be extended withSpecification Extensions.

4.8.8.2Path Templating Matching

Assuming the following paths, the concrete definition,/pets/mine, will be matched first if used:

  /pets/{petId}  /pets/mine

The following paths are considered identical and invalid:

  /pets/{petId}  /pets/{name}

The following may lead to ambiguous resolution:

  /{entity}/me  /books/{id}
4.8.8.3Paths Object Example
{"/pets":{"get":{"description":"Returns all pets from the system that the user has access to","responses":{"200":{"description":"A list of pets.","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/pet"}}}}}}}}}
/pets:get:description:Returnsallpetsfromthesystemthattheuserhasaccesstoresponses:'200':description:Alistofpets.content:application/json:schema:type:arrayitems:$ref:'#/components/schemas/pet'

4.8.9Path Item Object

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

4.8.9.1Fixed Fields
Field NameTypeDescription
$refstringAllows for a referenced definition of this path item. The valueMUST be in the form of a URI, and the referenced structureMUST be in the form of aPath Item Object. In case a Path Item Object field appears both in the defined object and the referenced object, the behavior is undefined. See the rules for resolvingRelative References.

Note: The behavior of$ref with adjacent properties is likely to change in future versions of this specification to bring it into closer alignment with the behavior of theReference Object.
summarystringAn optional string summary, intended to apply to all operations in this path.
descriptionstringAn optional string description, intended to apply to all operations in this path. [CommonMark] syntaxMAY be used for rich text representation.
getOperation ObjectA definition of a GET operation on this path.
putOperation ObjectA definition of a PUT operation on this path.
postOperation ObjectA definition of a POST operation on this path.
deleteOperation ObjectA definition of a DELETE operation on this path.
optionsOperation ObjectA definition of a OPTIONS operation on this path.
headOperation ObjectA definition of a HEAD operation on this path.
patchOperation ObjectA definition of a PATCH operation on this path.
traceOperation ObjectA definition of a TRACE operation on this path.
servers[Server Object]An alternativeservers array to service all operations in this path. If aservers array is specified at theOpenAPI Object level, it will be overridden by this value.
parameters[Parameter Object |Reference Object]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 listMUST NOT include duplicated parameters. A unique parameter is defined by a combination of aname andlocation. The list can use theReference Object to link to parameters that are defined in theOpenAPI Object’scomponents.parameters.

This objectMAY be extended withSpecification Extensions.

4.8.9.2Path Item Object Example
{"get":{"description":"Returns pets based on ID","summary":"Find pets by ID","operationId":"getPetsById","responses":{"200":{"description":"pet response","content":{"*/*":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/Pet"}}}}},"default":{"description":"error payload","content":{"text/html":{"schema":{"$ref":"#/components/schemas/ErrorModel"}}}}}},"parameters":[{"name":"id","in":"path","description":"ID of pet to use","required":true,"schema":{"type":"array","items":{"type":"string"}},"style":"simple"}]}
get:description:ReturnspetsbasedonIDsummary:FindpetsbyIDoperationId:getPetsByIdresponses:'200':description:petresponsecontent:'*/*':schema:type:arrayitems:$ref:'#/components/schemas/Pet'default:description:errorpayloadcontent:text/html:schema:$ref:'#/components/schemas/ErrorModel'parameters:-name:idin:pathdescription:IDofpettouserequired:trueschema:type:arrayitems:type:stringstyle:simple

4.8.10Operation Object

Describes a single API operation on a path.

4.8.10.1Fixed Fields
Field NameTypeDescription
tags[string]A list of tags for API documentation control. Tags can be used for logical grouping of operations by resources or any other qualifier.
summarystringA short summary of what the operation does.
descriptionstringA verbose explanation of the operation behavior. [CommonMark] syntaxMAY be used for rich text representation.
externalDocsExternal Documentation ObjectAdditional external documentation for this operation.
operationIdstringUnique string used to identify the operation. The idMUST be unique among all operations described in the API. The operationId value iscase-sensitive. Tools and librariesMAY use the operationId to uniquely identify an operation, therefore, it isRECOMMENDED to follow common programming naming conventions.
parameters[Parameter Object |Reference Object]A list of parameters that are applicable for this operation. If a parameter is already defined at thePath Item, the new definition will override it but can never remove it. The listMUST NOT include duplicated parameters. A unique parameter is defined by a combination of aname andlocation. The list can use theReference Object to link to parameters that are defined in theOpenAPI Object’scomponents.parameters.
requestBodyRequest Body Object |Reference ObjectThe request body applicable for this operation. TherequestBody is fully supported in HTTP methods where the HTTP 1.1 specification [RFC7231]Section 4.3.1 has explicitly defined semantics for request bodies. In other cases where the HTTP spec is vague (such asGET,HEAD andDELETE),requestBody is permitted but does not have well-defined semantics andSHOULD be avoided if possible.
responsesResponses ObjectThe list of possible responses as they are returned from executing this operation.
callbacksMap[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 aCallback Object that describes a request that may be initiated by the API provider and the expected responses.
deprecatedbooleanDeclares this operation to be deprecated. ConsumersSHOULD refrain from usage of the declared operation. Default value isfalse.
security[Security Requirement Object]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-levelsecurity. To remove a top-level security declaration, an empty array can be used.
servers[Server Object]An alternativeservers array to service this operation. If aservers array is specified at thePath Item Object orOpenAPI Object level, it will be overridden by this value.

This objectMAY be extended withSpecification Extensions.

4.8.10.2Operation Object Example
{"tags":["pet"],"summary":"Updates a pet in the store with form data","operationId":"updatePetWithForm","parameters":[{"name":"petId","in":"path","description":"ID of pet that needs to be updated","required":true,"schema":{"type":"string"}}],"requestBody":{"content":{"application/x-www-form-urlencoded":{"schema":{"type":"object","properties":{"name":{"description":"Updated name of the pet","type":"string"},"status":{"description":"Updated status of the pet","type":"string"}},"required":["status"]}}}},"responses":{"200":{"description":"Pet updated.","content":{"application/json":{},"application/xml":{}}},"405":{"description":"Method Not Allowed","content":{"application/json":{},"application/xml":{}}}},"security":[{"petstore_auth":["write:pets","read:pets"]}]}
tags:-petsummary:UpdatesapetinthestorewithformdataoperationId:updatePetWithFormparameters:-name:petIdin:pathdescription:IDofpetthatneedstobeupdatedrequired:trueschema:type:stringrequestBody:content:application/x-www-form-urlencoded:schema:type:objectproperties:name:description:Updatednameofthepettype:stringstatus:description:Updatedstatusofthepettype:stringrequired:-statusresponses:'200':description:Petupdated.content:application/json: {}application/xml: {}'405':description:MethodNotAllowedcontent:application/json: {}application/xml: {}security:-petstore_auth:-write:pets-read:pets

4.8.11External Documentation Object

Allows referencing an external resource for extended documentation.

4.8.11.1Fixed Fields
Field NameTypeDescription
descriptionstringA description of the target documentation. [CommonMark] syntaxMAY be used for rich text representation.
urlstringREQUIRED. The URI for the target documentation. ThisMUST be in the form of a URI.

This objectMAY be extended withSpecification Extensions.

4.8.11.2External Documentation Object Example
{"description":"Find more info here","url":"https://example.com"}
description:Findmoreinfohereurl:https://example.com

4.8.12Parameter Object

Describes a single operation parameter.

A unique parameter is defined by a combination of aname andlocation.

SeeAppendix E for a detailed examination of percent-encoding concerns, including interactions with theapplication/x-www-form-urlencoded query string format.

4.8.12.1Parameter Locations

There are four possible parameter locations specified by thein field:

  • path - Used together withPath 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 isitemId.
  • query - Parameters that are appended to the URL. For example, in/items?id=###, the query parameter isid.
  • header - Custom headers that are expected as part of the request. Note that [RFC7230]Section 3.2 states header names are case insensitive.
  • cookie - Used to pass a specific cookie value to the API.
4.8.12.2Fixed Fields

The rules for serialization of the parameter are specified in one of two ways.Parameter ObjectsMUST include either acontent field or aschema field, but not both.SeeAppendix B for a discussion of converting values of various types to string representations.

4.8.12.2.1Common Fixed Fields

These fieldsMAY be used with eithercontent orschema.

Field NameTypeDescription
namestringREQUIRED. The name of the parameter. Parameter names arecase sensitive.
  • Ifin is"path", thename fieldMUST correspond to a template expression occurring within thepath field in thePaths Object. SeePath Templating for further information.
  • Ifin is"header" and thename field is"Accept","Content-Type" or"Authorization", the parameter definitionSHALL be ignored.
  • For all other cases, thename corresponds to the parameter name used by thein field.
instringREQUIRED. The location of the parameter. Possible values are"query","header","path" or"cookie".
descriptionstringA brief description of the parameter. This could contain examples of use. [CommonMark] syntaxMAY be used for rich text representation.
requiredbooleanDetermines whether this parameter is mandatory. If theparameter location is"path", this field isREQUIRED and its valueMUST betrue. Otherwise, the fieldMAY be included and its default value isfalse.
deprecatedbooleanSpecifies that a parameter is deprecated andSHOULD be transitioned out of usage. Default value isfalse.
allowEmptyValuebooleanIftrue, clientsMAY pass a zero-length string value in place of parameters that would otherwise be omitted entirely, which the serverSHOULD interpret as the parameter being unused. Default value isfalse. Ifstyle is used, and ifbehavior isn/a (cannot be serialized), the value ofallowEmptyValueSHALL be ignored. Interactions between this field and the parameter’sSchema Object are implementation-defined. This field is valid only forquery parameters. Use of this field isNOT RECOMMENDED, and it is likely to be removed in a later revision.

This objectMAY be extended withSpecification Extensions.

Note that while"Cookie" as aname is not forbidden ifin is"header", the effect of defining a cookie parameter that way is undefined; usein: "cookie" instead.

4.8.12.2.2Fixed Fields for use withschema

For simpler scenarios, aschema andstyle can describe the structure and syntax of the parameter.Whenexample orexamples are provided in conjunction with theschema field, the exampleSHOULD match the specified schema and follow the prescribed serialization strategy for the parameter.Theexample andexamples fields are mutually exclusive, and if either is present itSHALLoverride anyexample in the schema.

When serializingin: "header" parameters withschema, URI percent-encodingMUST NOT be applied; if using an RFC6570 implementation that automatically applies it, itMUST be removed before use.ImplementationsMUST pass header values through unchanged rather than attempting to automatically quote header values, as the quoting rules vary too widely among different headers; seeAppendix D for guidance on quoting and escaping.

Serializing withschema isNOT RECOMMENDED forin: "cookie" parameters; seeAppendix D for details.

Field NameTypeDescription
stylestringDescribes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value ofin): for"query" -"form"; for"path" -"simple"; for"header" -"simple"; for"cookie" -"form".
explodebooleanWhen this is true, parameter values of typearray orobject generate separate parameters for each value of the array or key-value pair of the map. For other types of parameters this field has no effect. Whenstyle is"form", the default value istrue. For all other styles, the default value isfalse. Note that despitefalse being the default fordeepObject, the combination offalse withdeepObject is undefined.
allowReservedbooleanWhen this is true, parameter values are serialized using reserved expansion, as defined by [RFC6570]Section 3.2.3, which allowsRFC3986’s reserved character set, as well as percent-encoded triples, to pass through unchanged, while still percent-encoding all other disallowed characters (including% outside of percent-encoded triples). Applications are still responsible for percent-encoding reserved characters that arenot allowed in the query string ([,],#), or have a special meaning inapplication/x-www-form-urlencoded (-,&,+); seeURL Percent-Encoding for details. This field only applies to parameters with anin value ofquery. The default value isfalse.
schemaSchema ObjectThe schema defining the type used for the parameter.
exampleAnyExample of the parameter’s potential value; seeWorking With Examples.
examplesMap[string,Example Object |Reference Object]Examples of the parameter’s potential value; seeWorking With Examples.

See alsoAppendix C: Using RFC6570-Based Serialization for additional guidance.

4.8.12.2.3Fixed Fields for use withcontent

For more complex scenarios, thecontent field can define the media type and schema of the parameter, as well as give examples of its use.Usingcontent with atext/plain media type isRECOMMENDED forin: "cookie" parameters where theschema strategy’s percent-encoding and/or delimiter rules are not appropriate.

Field NameTypeDescription
contentMap[string,Media Type Object]A map containing the representations for the parameter. The key is the media type and the value describes it. The mapMUST only contain one entry.
4.8.12.3Style Values

In order to support common ways of serializing simple parameters, a set ofstyle values are defined.

styletypeinComments
matrixprimitive,array,objectpathPath-style parameters defined by [RFC6570]Section 3.2.7
labelprimitive,array,objectpathLabel style parameters defined by [RFC6570]Section 3.2.5
simpleprimitive,array,objectpath,headerSimple style parameters defined by [RFC6570]Section 3.2.2. This option replacescollectionFormat with acsv value from OpenAPI 2.0.
formprimitive,array,objectquery,cookieForm style parameters defined by [RFC6570]Section 3.2.8. This option replacescollectionFormat with acsv (whenexplode is false) ormulti (whenexplode is true) value from OpenAPI 2.0.
spaceDelimitedarray,objectquerySpace separated array values or object properties and values. This option replacescollectionFormat equal tossv from OpenAPI 2.0.
pipeDelimitedarray,objectqueryPipe separated array values or object properties and values. This option replacescollectionFormat equal topipes from OpenAPI 2.0.
deepObjectobjectqueryAllows objects with scalar properties to be represented using form parameters. The representation of array or object properties is not defined.
4.8.12.4URL Percent-Encoding

All API URLsMUST successfully parse and percent-decode using [RFC3986] rules.

Content in theapplication/x-www-form-urlencoded format, including query strings produced byParameter Objects within: "query",MUST also successfully parse and percent-decode using [RFC1866] rules, including treating non-percent-encoded+ as an escaped space character.

These requirements are specified in terms of percent-decoding rules, which are consistently tolerant across different versions of the various standards that apply to URIs.

Percent-encoding is performed in several places:

  • By [RFC6570] implementations (or simulations thereof; seeAppendix C)
  • By the Parameter orEncoding Objects when incorporating a value serialized with aMedia Type Object for a media type that does not already incorporate URI percent-encoding
  • By the user, prior to passing data through RFC6570’s reserved expansion process

When percent-encoding, the safest approach is to percent-encode all characters not in RFC3986’s “unreserved” set, and forform-urlencoded to also percent-encode the tilde character (~) to align with the historical requirements of [RFC1738], which is cited by RFC1866.This approach is used in examples in this specification.

Forform-urlencoded, while the encoding algorithm given by RFC1866 requires escaping the space character as+, percent-encoding it as%20 also meets the above requirements.Examples in this specification will prefer%20 when using RFC6570’s default (non-reserved) form-style expansion, and+ otherwise.

Reserved charactersMUST NOT be percent-encoded when being used for reserved purposes such as&=+ forform-urlencoded or, for delimiting non-exploded array and object values in RFC6570 expansions.The result of inserting non-percent-encoded delimiters into data using manual percent-encoding, including via RFC6570’s reserved expansion rules, is undefined and will likely prevent implementations from parsing the results back into the correct data structures.In some cases, such as inserting/ into path parameter values, doing so isexplicitly forbidden by this specification.

SeeAppendix E for a thorough discussion of percent-encoding options, compatibility, and OAS-defined delimiters that are not allowed by RFC3986, andAppendix C for guidance on using RFC6570 implementations.

4.8.12.5Serialization and Examples

The rules in this section apply to both the Parameter andHeader Objects, both of which use the same mechanisms.

When showing serialized examples using theexample field orExample Objects, in most cases the value to show is just the value, with all relevant percent-encoding or other encoding/escaping applied, and also including any delimiters produced by thestyle andexplode configuration.

In cases where the name is an inherent part of constructing the serialization, such as thename=value pairs produced bystyle: "form" or the combination ofstyle: "simple", explode: true, the name and any delimiter between the name and valueMUST be included.

Thematrix andlabel styles produce a leading delimiter which is always a valid part of the serialization andMUST be included.The RFC6570 operators corresponding tostyle: "form" produce a leading delimiter of either? or& depending on the exact syntax used.As the suitability of either delimiter depends on where in the query string the parameter occurs, as well as whether it is in a URI or inapplication/x-www-form-urlencoded content, this leading delimiterMUST NOT be included in examples of individual parameters or media type documents.Forin: "cookie", style: "form", neither the& nor? delimiters are ever correct; seeAppendix D: Serializing Headers and Cookies for more details.

For headers, the header nameMUST NOT be included as part of the serialization, as it is never part of the RFC6570-derived result.However, names produced bystyle: "simple", explode: "true" are included as they appear within the header value, not as separate headers.

The following section illustrates these rules.

4.8.12.6Style Examples

Assume a parameter namedcolor has one of the following values:

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

The following table shows serialized examples, as would be shown with theexample orexamples keywords, of the different serializations for each value.

  • The valueempty denotes the empty string, and is unrelated to theallowEmptyValue field.
  • The behavior of combinations markedn/a is undefined.
  • Theundefined column replaces theempty column in previous versions of this specification in order to better align with [RFC6570]Section 2.3 terminology, which describes certain values including but not limited tonull as “undefined” values with special handling; notably, the empty string isnot undefined.
  • Forform and the non-RFC6570 query string stylesspaceDelimited,pipeDelimited, anddeepObject, seeAppendix C for more information on constructing query strings from multiple parameters, andAppendix D for warnings regardingform and cookie parameters.
  • The examples are percent-encoded as explained in theURL Percent-Encoding section above; seeAppendix E for a thorough discussion of percent-encoding concerns, including why unencoded| (%7C),[ (%5B), and] (%5D) seem to work in some environments despite not being compliant.
styleexplodeundefinedstringarrayobject
matrixfalse;color;color=blue;color=blue,black,brown;color=R,100,G,200,B,150
matrixtrue;color;color=blue;color=blue;color=black;color=brown;R=100;G=200;B=150
labelfalse..blue.blue,black,brown.R,100,G,200,B,150
labeltrue..blue.blue.black.brown.R=100.G=200.B=150
simplefalseemptyblueblue,black,brownR,100,G,200,B,150
simpletrueemptyblueblue,black,brownR=100,G=200,B=150
formfalsecolor=color=bluecolor=blue,black,browncolor=R,100,G,200,B,150
formtruecolor=color=bluecolor=blue&color=black&color=brownR=100&G=200&B=150
spaceDelimitedfalsen/an/acolor=blue%20black%20browncolor=R%20100%20G%20200%20B%20150
spaceDelimitedtruen/an/an/an/a
pipeDelimitedfalsen/an/acolor=blue%7Cblack%7Cbrowncolor=R%7C100%7CG%7C200%7CB%7C150
pipeDelimitedtruen/an/an/an/a
deepObjectfalsen/an/an/an/a
deepObjecttruen/an/an/acolor%5BR%5D=100&color%5BG%5D=200&color%5BB%5D=150
4.8.12.7Parameter Object Examples

A header parameter with an array of 64-bit integer numbers:

{"name":"token","in":"header","description":"token to be passed as a header","required":true,"schema":{"type":"array","items":{"type":"integer","format":"int64"}},"style":"simple"}
name:tokenin:headerdescription:tokentobepassedasaheaderrequired:trueschema:type:arrayitems:type:integerformat:int64style:simple

A path parameter of a string value:

{"name":"username","in":"path","description":"username to fetch","required":true,"schema":{"type":"string"}}
name:usernamein:pathdescription:usernametofetchrequired:trueschema:type:string

An optional query parameter of a string value, allowing multiple values by repeating the query parameter:

{"name":"id","in":"query","description":"ID of the object to fetch","required":false,"schema":{"type":"array","items":{"type":"string"}},"style":"form","explode":true}
name:idin:querydescription:IDoftheobjecttofetchrequired:falseschema:type:arrayitems:type:stringstyle:formexplode:true

A free-form query parameter, allowing undefined parameters of a specific type:

{"in":"query","name":"freeForm","schema":{"type":"object","additionalProperties":{"type":"integer"}},"style":"form"}
in:queryname:freeFormschema:type:objectadditionalProperties:type:integerstyle:form

A complex parameter usingcontent to define serialization:

{"in":"query","name":"coordinates","content":{"application/json":{"schema":{"type":"object","required":["lat","long"],"properties":{"lat":{"type":"number"},"long":{"type":"number"}}}}}}
in:queryname:coordinatescontent:application/json:schema:type:objectrequired:-lat-longproperties:lat:type:numberlong:type:number

4.8.13Request Body Object

Describes a single request body.

4.8.13.1Fixed Fields
Field NameTypeDescription
descriptionstringA brief description of the request body. This could contain examples of use. [CommonMark] syntaxMAY be used for rich text representation.
contentMap[string,Media Type Object]REQUIRED. The content of the request body. The key is a media type or media type range, see [RFC7231]Appendix D, and the value describes it. The mapSHOULD have at least one entry; if it does not, the behavior is implementation-defined. For requests that match multiple keys, only the most specific key is applicable. e.g."text/plain" overrides"text/*"
requiredbooleanDetermines if the request body is required in the request. Defaults tofalse.

This objectMAY be extended withSpecification Extensions.

4.8.13.2Request Body Examples

A request body with a referenced schema definition.

{"description":"user to add to the system","content":{"application/json":{"schema":{"$ref":"#/components/schemas/User"},"examples":{"user":{"summary":"User Example","externalValue":"https://foo.bar/examples/user-example.json"}}},"application/xml":{"schema":{"$ref":"#/components/schemas/User"},"examples":{"user":{"summary":"User example in XML","externalValue":"https://foo.bar/examples/user-example.xml"}}},"text/plain":{"examples":{"user":{"summary":"User example in Plain text","externalValue":"https://foo.bar/examples/user-example.txt"}}},"*/*":{"examples":{"user":{"summary":"User example in other format","externalValue":"https://foo.bar/examples/user-example.whatever"}}}}}
description:usertoaddtothesystemcontent:application/json:schema:$ref:'#/components/schemas/User'examples:user:summary:UserexampleexternalValue:https://foo.bar/examples/user-example.jsonapplication/xml:schema:$ref:'#/components/schemas/User'examples:user:summary:UserexampleinXMLexternalValue:https://foo.bar/examples/user-example.xmltext/plain:examples:user:summary:UserexampleinplaintextexternalValue:https://foo.bar/examples/user-example.txt'*/*':examples:user:summary:UserexampleinotherformatexternalValue:https://foo.bar/examples/user-example.whatever

4.8.14Media Type Object

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

Whenexample orexamples are provided, the exampleSHOULD match the specified schema and be in the correct format as specified by the media type and its encoding.Theexample andexamples fields are mutually exclusive, and if either is present itSHALLoverride anyexample in the schema.SeeWorking With Examples for further guidance regarding the different ways of specifying examples, including non-JSON/YAML values.

4.8.14.1Fixed Fields
Field NameTypeDescription
schemaSchema ObjectThe schema defining the content of the request, response, parameter, or header.
exampleAnyExample of the media type; seeWorking With Examples.
examplesMap[string,Example Object |Reference Object]Examples of the media type; seeWorking With Examples.
encodingMap[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. Theencoding fieldSHALL only apply toRequest Body Objects, and only when the media type ismultipart orapplication/x-www-form-urlencoded. If no Encoding Object is provided for a property, the behavior is determined by the default values documented for the Encoding Object.

This objectMAY be extended withSpecification Extensions.

4.8.14.2Media Type Examples
{"application/json":{"schema":{"$ref":"#/components/schemas/Pet"},"examples":{"cat":{"summary":"An example of a cat","value":{"name":"Fluffy","petType":"Cat","color":"White","gender":"male","breed":"Persian"}},"dog":{"summary":"An example of a dog with a cat's name","value":{"name":"Puma","petType":"Dog","color":"Black","gender":"Female","breed":"Mixed"}},"frog":{"$ref":"#/components/examples/frog-example"}}}}
application/json:schema:$ref:'#/components/schemas/Pet'examples:cat:summary:Anexampleofacatvalue:name:FluffypetType:Catcolor:Whitegender:malebreed:Persiandog:summary:Anexampleofadogwithacat'snamevalue:name:PumapetType:Dogcolor:Blackgender:Femalebreed:Mixedfrog:$ref:'#/components/examples/frog-example'
4.8.14.3Considerations for File Uploads

In contrast to OpenAPI 2.0,file input/output content in OAS 3.x is described with the same semantics as any other schema type.

In contrast to OAS 3.0, theformat keyword has no effect on the content-encoding of the schema in OAS 3.1. Instead, JSON Schema’scontentEncoding andcontentMediaType keywords are used. SeeWorking With Binary Data for how to model various scenarios with these keywords, and how to migrate from the previousformat usage.

Examples:

Content transferred in binary (octet-stream)MAY omitschema:

# a PNG image as a binary file:content:image/png: {}
# an arbitrary binary file:content:application/octet-stream: {}
# arbitrary JSON without constraints beyond being syntactically valid:content:application/json: {}

These examples apply to either input payloads of file uploads or response payloads.

ArequestBody for submitting a file in aPOST operation may look like the following example:

requestBody:content:application/octet-stream: {}

In addition, specific media typesMAY be specified:

# multiple, specific media types may be specified:requestBody:content:# a binary file of type png or jpegimage/jpeg: {}image/png: {}

To upload multiple files, amultipart media typeMUST be used as shown underExample: Multipart Form with Multiple Files.

4.8.14.4Support for x-www-form-urlencoded Request Bodies

SeeEncoding thex-www-form-urlencoded Media Type for guidance and examples, both with and without theencoding field.

4.8.14.5Special Considerations formultipart Content

SeeEncodingmultipart Media Types for further guidance and examples, both with and without theencoding field.

4.8.15Encoding Object

A single encoding definition applied to a single schema property.SeeAppendix B for a discussion of converting values of various types to string representations.

Properties are correlated withmultipart parts using thename parameter ofContent-Disposition: form-data, and withapplication/x-www-form-urlencoded using the query string parameter names.In both cases, their order is implementation-defined.

SeeAppendix E for a detailed examination of percent-encoding concerns for form media types.

4.8.15.1Fixed Fields
4.8.15.1.1Common Fixed Fields

These fieldsMAY be used either with or without the RFC6570-style serialization fields defined in the next section below.

Field NameTypeDescription
contentTypestringTheContent-Type for encoding a specific property. The value is a comma-separated list, each element of which is either a specific media type (e.g.image/png) or a wildcard media type (e.g.image/*). Default value depends on the property type as shown in the table below.
headersMap[string,Header Object |Reference Object]A map allowing additional information to be provided as headers.Content-Type is described separately andSHALL be ignored in this section. This fieldSHALL be ignored if the request body media type is not amultipart.

This objectMAY be extended withSpecification Extensions.

The default values forcontentType are as follows, where ann/a in thecontentEncoding column means that the presence or value ofcontentEncoding is irrelevant:

typecontentEncodingDefaultcontentType
absentn/aapplication/octet-stream
stringpresentapplication/octet-stream
stringabsenttext/plain
number,integer, orbooleann/atext/plain
objectn/aapplication/json
arrayn/aaccording to thetype of theitems schema

Determining how to handle atype value ofnull depends on hownull values are being serialized.Ifnull values are entirely omitted, then thecontentType is irrelevant.SeeAppendix B for a discussion of data type conversion options.

4.8.15.1.2Fixed Fields for RFC6570-style Serialization
Field NameTypeDescription
stylestringDescribes how a specific property value will be serialized depending on its type. SeeParameter Object for details on thestyle field. The behavior follows the same values asquery parameters, including the default value of"form" which applies only whencontentType isnot being used due to one or both ofexplode orallowReserved being explicitly specified. Note that the initial? used in query strings is not used inapplication/x-www-form-urlencoded message bodies, andMUST be removed (if using an RFC6570 implementation) or simply not added (if constructing the string manually). This fieldSHALL be ignored if the request body media type is notapplication/x-www-form-urlencoded ormultipart/form-data. If a value is explicitly defined, then the value ofcontentType (implicit or explicit)SHALL be ignored.
explodebooleanWhen this is true, property values of typearray orobject generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this field has no effect. Whenstyle is"form", the default value istrue. For all other styles, the default value isfalse. Note that despitefalse being the default fordeepObject, the combination offalse withdeepObject is undefined. This fieldSHALL be ignored if the request body media type is notapplication/x-www-form-urlencoded ormultipart/form-data. If a value is explicitly defined, then the value ofcontentType (implicit or explicit)SHALL be ignored.
allowReservedbooleanWhen this is true, parameter values are serialized using reserved expansion, as defined by [RFC6570]Section 3.2.3, which allowsRFC3986’s reserved character set, as well as percent-encoded triples, to pass through unchanged, while still percent-encoding all other disallowed characters (including% outside of percent-encoded triples). Applications are still responsible for percent-encoding reserved characters that arenot allowed in the query string ([,],#), or have a special meaning inapplication/x-www-form-urlencoded (-,&,+); seeURL Percent-Encoding for details. The default value isfalse. This fieldSHALL be ignored if the request body media type is notapplication/x-www-form-urlencoded ormultipart/form-data. If a value is explicitly defined, then the value ofcontentType (implicit or explicit)SHALL be ignored.

When using RFC6570-style serialization formultipart/form-data, URI percent-encodingMUST NOT be applied, and the value ofallowReserved has no effect.See alsoAppendix C: Using RFC6570 Implementations for additional guidance.

Note that the presence of at least one ofstyle,explode, orallowReserved with an explicit value is equivalent to usingschema within: "query" Parameter Objects.The absence of all three of those fields is the equivalent of usingcontent, but with the media type specified incontentType rather than through a Media Type Object.

4.8.15.2Encoding thex-www-form-urlencoded Media Type

To submit content using form url encoding via [RFC1866], use theapplication/x-www-form-urlencoded media type in theMedia Type Object under theRequest Body Object.This configuration means that the request bodyMUST be encoded per [RFC1866] when passed to the server, after any complex objects have been serialized to a string representation.

SeeAppendix E for a detailed examination of percent-encoding concerns for form media types.

4.8.15.2.1Example: URL Encoded Form with JSON Values

When there is noencoding field, the serialization strategy is based on the Encoding Object’s default values:

requestBody:content:application/x-www-form-urlencoded:schema:type:objectproperties:id:type:stringformat:uuidaddress:# complex types are stringified to support RFC 1866type:objectproperties: {}

With this example, consider anid off81d4fae-7dec-11d0-a765-00a0c91e6bf6 and a US-style address (with ZIP+4) as follows:

{"streetAddress":"123 Example Dr.","city":"Somewhere","state":"CA","zip":"99999+1234"}

Assuming the most compact representation of the JSON value (with unnecessary whitespace removed), we would expect to see the following request body, where space characters have been replaced with+ and+,",:,,,{, and} have been percent-encoded to%2B,%22,%3A,%2C,%7B, and%7D, respectively:

id=f81d4fae-7dec-11d0-a765-00a0c91e6bf6&address=%7B%22streetAddress%22%3A%22123+Example+Dr.%22%2C%22city%22%3A%22Somewhere%22%2C%22state%22%3A%22CA%22%2C%22zip%22%3A%2299999%2B1234%22%7D

Note that theid keyword is treated astext/plain per theEncoding Object’s default behavior, and is serialized as-is.If it were treated asapplication/json, then the serialized value would be a JSON string including quotation marks, which would be percent-encoded as%22.

Here is theid parameter (withoutaddress) serialized asapplication/json instead oftext/plain, and then encoded per RFC1866:

id=%22f81d4fae-7dec-11d0-a765-00a0c91e6bf6%22
4.8.15.2.2Example: URL Encoded Form with Binary Values

Note thatapplication/x-www-form-urlencoded is a text format, which requires base64-encoding any binary data:

requestBody:content:application/x-www-form-urlencoded:schema:type:objectproperties:name:type:stringicon:# The default content type with `contentEncoding` present# is "application/octet-stream", so we need to set the correct# image media type(s) in the Encoding Object.type:stringcontentEncoding:base64urlencoding:icon:contentType:image/png,image/jpeg

Given a name ofexample and a solid red 2x2-pixel PNG foricon, thiswould produce a request body of:

name=example&icon=iVBORw0KGgoAAAANSUhEUgAAAAIAAAACCAIAAAD91JpzAAAABGdBTUEAALGPC_xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAAqADAAQAAAABAAAAAgAAAADO0J6QAAAAEElEQVQIHWP8zwACTGCSAQANHQEDqtPptQAAAABJRU5ErkJggg%3D%3D

Note that the= padding characters at the end need to be percent-encoded, even with the “URL safe”contentEncoding: base64url.Some base64-decoding implementations may be able to use the string without the padding per [RFC4648]Section 3.2.However, this is not guaranteed, so it may be more interoperable to keep the padding and rely on percent-decoding.

4.8.15.3Encodingmultipart Media Types

It is common to usemultipart/form-data as aContent-Type when transferring forms as request bodies. In contrast to OpenAPI 2.0, aschema isREQUIRED to define the input parameters to the operation when usingmultipart content. This supports complex structures as well as supporting mechanisms for multiple file uploads.

Theform-data disposition and itsname parameter are mandatory formultipart/form-data ([RFC7578]Section 4.2).Array properties are handled by applying the samename to multiple parts, as is recommended by [RFC7578]Section 4.3 for supplying multiple values per form field.See [RFC7578]Section 5 for guidance regarding non-ASCII part names.

Various othermultipart types, most notablemultipart/mixed ([RFC2046]Section 5.1.3) neither require nor forbid specificContent-Disposition values, which means care must be taken to ensure that any values used are supported by all relevant software.It is not currently possible to correlate schema properties with unnamed, ordered parts in media types such asmultipart/mixed, but implementationsMAY choose to support such types whenContent-Disposition: form-data is used with aname parameter.

Note that there are significant restrictions on what headers can be used withmultipart media types in general ([RFC2046]Section 5.1) andmulti-part/form-data in particular ([RFC7578]Section 4.8).

Note also thatContent-Transfer-Encoding is deprecated formultipart/form-data ([RFC7578]Section 4.7) where binary data is supported, as it is in HTTP.

UsingcontentEncoding for a multipart field is equivalent to specifying anEncoding Object with aheaders field containingContent-Transfer-Encoding with a schema that requires the value used incontentEncoding.IfcontentEncoding is used for a multipart field that has an Encoding Object with aheaders field containingContent-Transfer-Encoding with a schema that disallows the value fromcontentEncoding, the result is undefined for serialization and parsing.

Note that as stated inWorking with Binary Data, if the Encoding Object’scontentType, whether set explicitly or implicitly through its default value rules, disagrees with thecontentMediaType in a Schema Object, thecontentMediaTypeSHALL be ignored.Because of this, and because the Encoding Object’scontentType defaulting rules do not take the Schema Object’scontentMediaType into account, the use ofcontentMediaType with an Encoding Object isNOT RECOMMENDED.

SeeAppendix E for a detailed examination of percent-encoding concerns for form media types.

4.8.15.3.1Example: Basic Multipart Form

When theencoding field isnot used, the encoding is determined by the Encoding Object’s defaults:

requestBody:content:multipart/form-data:schema:type:objectproperties:# default content type for a string without `contentEncoding`# is "text/plain"id:type:stringformat:uuid# default content type for a schema without `type`# is "application/octet-stream"profileImage: {}# default content type for arrays is based on the type# in the `items` subschema, which is an object here,# so the default content type for each item is "application/json"addresses:type:arrayitems:$ref:'#/components/schemas/Address'
4.8.15.3.2Example: Multipart Form with Encoding Objects

Usingencoding, we can set more specific types for binary data, or non-JSON formats for complex values.We can also describe headers for each part:

requestBody:content:multipart/form-data:schema:type:objectproperties:# No Encoding Object, so use default "text/plain"id:type:stringformat:uuid# Encoding Object overrides the default "application/json" content type# for each item in the array with "application/xml; charset=utf-8"addresses:description:addressesinXMLformattype:arrayitems:$ref:'#/components/schemas/Address'# Encoding Object accepts only PNG or JPEG, and also describes# a custom header for just this part in the multipart formatprofileImage: {}encoding:addresses:contentType:application/xml;charset=utf-8profileImage:contentType:image/png,image/jpegheaders:X-Rate-Limit-Limit:description:Thenumberofallowedrequestsinthecurrentperiodschema:type:integer
4.8.15.3.3Example: Multipart Form with Multiple Files

In accordance with [RFC7578]Section 4.3, multiple files for a single form field are uploaded using the same name (file in this example) for each file’s part:

requestBody:content:multipart/form-data:schema:properties:# The property name `file` will be used for all files.file:type:arrayitems: {}

As seen in theEncoding Object’scontentType field documentation, the empty schema foritems indicates a media type ofapplication/octet-stream.

4.8.16Responses 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.

ThedefaultMAY be used as a default Response Object for all HTTP codesthat are not covered individually by the Responses Object.

The Responses ObjectMUST contain at least one response code, and if only oneresponse code is provided itSHOULD be the response for a successful operationcall.

4.8.16.1Fixed Fields
Field NameTypeDescription
defaultResponse Object |Reference ObjectThe documentation of responses other than the ones declared for specific HTTP response codes. Use this field to cover undeclared responses.
4.8.16.2Patterned Fields
Field PatternTypeDescription
HTTP Status CodeResponse Object |Reference ObjectAnyHTTP 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 fieldMUST be enclosed in quotation marks (for example, “200”) for compatibility between JSON and YAML. To define a range of response codes, this fieldMAY contain the uppercase wildcard characterX. For example,2XX represents all response codes between200 and299. Only the following range definitions are allowed:1XX,2XX,3XX,4XX, and5XX. If a response is defined using an explicit code, the explicit code definition takes precedence over the range definition for that code.

This objectMAY be extended withSpecification Extensions.

4.8.16.3Responses Object Example

A 200 response for a successful operation and a default response for others (implying an error):

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

4.8.17Response Object

Describes a single response from an API operation, including design-time, staticlinks to operations based on the response.

4.8.17.1Fixed Fields
Field NameTypeDescription
descriptionstringREQUIRED. A description of the response. [CommonMark] syntaxMAY be used for rich text representation.
headersMap[string,Header Object |Reference Object]Maps a header name to its definition. [RFC7230]Section 3.2 states header names are case insensitive. If a response header is defined with the name"Content-Type", itSHALL be ignored.
contentMap[string,Media Type Object]A map containing descriptions of potential response payloads. The key is a media type or media type range, see [RFC7231]Appendix D, and the value describes it. For responses that match multiple keys, only the most specific key is applicable. e.g."text/plain" overrides"text/*"
linksMap[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 forComponent Objects.

This objectMAY be extended withSpecification Extensions.

4.8.17.2Response Object Examples

Response of an array of a complex type:

{"description":"A complex object array response","content":{"application/json":{"schema":{"type":"array","items":{"$ref":"#/components/schemas/VeryComplexType"}}}}}
description:Acomplexobjectarrayresponsecontent:application/json:schema:type:arrayitems:$ref:'#/components/schemas/VeryComplexType'

Response with a string type:

{"description":"A simple string response","content":{"text/plain":{"schema":{"type":"string"}}}}
description:Asimplestringresponsecontent:text/plain:schema:type:string

Plain text response with headers:

{"description":"A simple string response","content":{"text/plain":{"schema":{"type":"string"},"example":"whoa!"}},"headers":{"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","schema":{"type":"integer"}},"X-Rate-Limit-Remaining":{"description":"The number of remaining requests in the current period","schema":{"type":"integer"}},"X-Rate-Limit-Reset":{"description":"The number of seconds left in the current period","schema":{"type":"integer"}}}}
description:Asimplestringresponsecontent:text/plain:schema:type:stringexample:'whoa!'headers:X-Rate-Limit-Limit:description:Thenumberofallowedrequestsinthecurrentperiodschema:type:integerX-Rate-Limit-Remaining:description:Thenumberofremainingrequestsinthecurrentperiodschema:type:integerX-Rate-Limit-Reset:description:Thenumberofsecondsleftinthecurrentperiodschema:type:integer

Response with no return value:

{"description":"object created"}
description:objectcreated

4.8.18Callback Object

A map of possible out-of band callbacks related to the parent operation.Each value in the map is aPath Item Object that describes a set of requests that may be initiated by the API provider and the expected responses.The key value used to identify the Path Item Object is an expression, evaluated at runtime, that identifies a URL to use for the callback operation.

To describe incoming requests from the API provider independent from another API call, use thewebhooks field.

4.8.18.1Patterned Fields
Field PatternTypeDescription
{expression}Path Item ObjectA Path Item Object used to define a callback request and expected responses. Acomplete example is available.

This objectMAY be extended withSpecification Extensions.

4.8.18.2Key Expression

The key that identifies thePath Item Object is aruntime 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 aruntime 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/stillrunningHTTP/1.1Host:example.orgContent-Type:application/jsonContent-Length:188{  "failedUrl": "https://clientdomain.com/failed",  "successUrls": [    "https://clientdomain.com/fast",    "https://clientdomain.com/medium",    "https://clientdomain.com/slow"  ]}

resulting in:

201 CreatedLocation:https://example.org/subscription/1

The following examples show how the various expressions evaluate, assuming the callback operation has a path parameter namedeventType and a query parameter namedqueryUrl.

ExpressionValue
$urlhttps://example.org/subscribe/myevent?queryUrl=https://clientdomain.com/stillrunning
$methodPOST
$request.path.eventTypemyevent
$request.query.queryUrlhttps://clientdomain.com/stillrunning
$request.header.content-typeapplication/json
$request.body#/failedUrlhttps://clientdomain.com/failed
$request.body#/successUrls/1https://clientdomain.com/medium
$response.header.Locationhttps://example.org/subscription/1
4.8.18.3Callback Object Examples

The following example uses the user providedqueryUrl query string parameter to define the callback URL. This is similar to awebhook, but differs in that the callback only occurs because of the initial request that sent thequeryUrl.

myCallback:'{$request.query.queryUrl}':post:requestBody:description:Callbackpayloadcontent:application/json:schema:$ref:'#/components/schemas/SomePayload'responses:'200':description:callbacksuccessfullyprocessed

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

transactionCallback:'http://notificationServer.com?transactionId={$request.body#/id}&email={$request.body#/email}':post:requestBody:description:Callbackpayloadcontent:application/json:schema:$ref:'#/components/schemas/SomePayload'responses:'200':description:callbacksuccessfullyprocessed

4.8.19Example Object

An object grouping an internal or external example value with basicsummary anddescription metadata.This object is typically used in fields namedexamples (plural), and is areferenceable alternative to olderexample (singular) fields that do not support referencing or metadata.

Examples allow demonstration of the usage of properties, parameters and objects within OpenAPI.

4.8.19.1Fixed Fields
Field NameTypeDescription
summarystringShort description for the example.
descriptionstringLong description for the example. [CommonMark] syntaxMAY be used for rich text representation.
valueAnyEmbedded literal example. Thevalue field andexternalValue 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.
externalValuestringA URI that identifies the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. Thevalue field andexternalValue field are mutually exclusive. See the rules for resolvingRelative References.

This objectMAY be extended withSpecification Extensions.

In all cases, the example valueSHOULD be compatible with the schema of its associated value.Tooling implementationsMAY choose to validate compatibility automatically, and reject the example value(s) if incompatible.

4.8.19.2Working with Examples

Example Objects can be used inParameter Objects,Header Objects, andMedia Type Objects.In all three Objects, this is done through theexamples (plural) field.However, there are several other ways to provide examples: Theexample (singular) field that is mutually exclusive withexamples in all three Objects, and two keywords (the deprecated singularexample and the current pluralexamples, which takes an array of examples) in theSchema Object that appears in theschema field of all three Objects.Each of these fields has slightly different considerations.

The Schema Object’s fields are used to show example values without regard to how they might be formatted as parameters or within media type representations.Theexamples array is part of JSON Schema and is the preferred way to include examples in the Schema Object, whileexample is retained purely for compatibility with older versions of the OpenAPI Specification.

The mutually exclusive fields in the Parameter, Header, or Media Type Objects are used to show example values whichSHOULD both match the schema and be formatted as they would appear as a serialized parameter, serialized header, or within a media type representation.The exact serialization and encoding is determined by various fields in the Parameter Object, Header Object, or in the Media Type Object’sEncoding Object.Because examples using these fields represent the final serialized form of the data, theySHALLoverride anyexample in the corresponding Schema Object.

The singularexample field in the Parameter, Header, or Media Type Object is concise and convenient for simple examples, but does not offer any other advantages over using Example Objects underexamples.

Some examples cannot be represented directly in JSON or YAML.For all three ways of providing examples, these can be shown as string values with any escaping necessary to make the string valid in the JSON or YAML format of documents that comprise the OpenAPI Description.With the Example Object, such values can alternatively be handled through theexternalValue field.

4.8.19.3Example Object Examples

In a request body:

requestBody:content:'application/json':schema:$ref:'#/components/schemas/Address'examples:foo:summary:Afooexamplevalue:foo:barbar:summary:Abarexamplevalue:bar:bazapplication/xml:examples:xmlExample:summary:ThisisanexampleinXMLexternalValue:https://example.org/examples/address-example.xmltext/plain:examples:textExample:summary:ThisisatextexampleexternalValue:https://foo.bar/examples/address-example.txt

In a parameter:

parameters:-name:zipCodein:queryschema:type:stringformat:zip-codeexamples:zip-example:$ref:'#/components/examples/zip-example'

In a response:

responses:'200':description:yourcarappointmenthasbeenbookedcontent:application/json:schema:$ref:'#/components/schemas/SuccessResponse'examples:confirmation-success:$ref:'#/components/examples/confirmation-success'

Two different uses of JSON strings:

First, a request or response body that is just a JSON string (not an object containing a string):

"application/json":{"schema":{"type":"string"},"examples":{"jsonBody":{"description":"A body of just the JSON string \"json\"","value":"json"}}}
application/json:schema:type:stringexamples:jsonBody:description:'A body of just the JSON string "json"'value:json

In the above example, we can just show the JSON string (or any JSON value) as-is, rather than stuffing a serialized JSON value into a JSON string, which would have looked like"\"json\"".

In contrast, a JSON string encoded inside of a URL-style form body:

"application/x-www-form-urlencoded":{"schema":{"type":"object","properties":{"jsonValue":{"type":"string"}}},"encoding":{"jsonValue":{"contentType":"application/json"}},"examples":{"jsonFormValue":{"description":"The JSON string \"json\" as a form value","value":"jsonValue=%22json%22"}}}
application/x-www-form-urlencoded:schema:type:objectproperties:jsonValue:type:stringencoding:jsonValue:contentType:application/jsonexamples:jsonFormValue:description:'The JSON string "json" as a form value'value:jsonValue=%22json%22

In this example, the JSON string had to be serialized before encoding it into the URL form value, so the example includes the quotation marks that are part of the JSON serialization, which are then URL percent-encoded.

4.8.20Link 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.

Unlikedynamic links (i.e. links providedin 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, aruntime expression is used for accessing values in an operation and using them as parameters while invoking the linked operation.

4.8.20.1Fixed Fields
Field NameTypeDescription
operationRefstringA URI reference to an OAS operation. This field is mutually exclusive of theoperationId field, andMUST point to anOperation Object. RelativeoperationRef valuesMAY be used to locate an existingOperation Object in the OpenAPI Description.
operationIdstringThe name of anexisting, resolvable OAS operation, as defined with a uniqueoperationId. This field is mutually exclusive of theoperationRef field.
parametersMap[string, Any |{expression}]A map representing parameters to pass to an operation as specified withoperationId or identified viaoperationRef. The key is the parameter name to be used (optionally qualified with the parameter location, e.g.path.id for anid parameter in the path), whereas the value can be a constant or an expression to be evaluated and passed to the linked operation.
requestBodyAny |{expression}A literal value or{expression} to use as a request body when calling the target operation.
descriptionstringA description of the link. [CommonMark] syntaxMAY be used for rich text representation.
serverServer ObjectA server object to be used by the target operation.

This objectMAY be extended withSpecification Extensions.

A linked operationMUST be identified using either anoperationRef oroperationId.The identified or referenced operationMUST be unique, and in the case of anoperationId, itMUST be resolved within the scope of the OpenAPI Description (OAD).Because of the potential for name clashes, theoperationRef syntax is preferred for multi-document OADs.However, because use of an operation depends on its URL path template in thePaths Object, operations from anyPath Item Object that is referenced multiple times within the OAD cannot be resolved unambiguously.In such ambiguous cases, the resulting behavior is implementation-defined andMAY result in an error.

Note that it is not possible to provide a constant value toparameters that matches the syntax of a runtime expression.It is possible to have ambiguous parameter names, e.g.name: "id", in: "path" andname: "path.id", in: "query"; this isNOT RECOMMENDED and the behavior is implementation-defined, however implementationsSHOULD prefer the qualified interpretation (path.id as a path parameter), as the names can always be qualified to disambiguate them (e.g. usingquery.path.id for the query parameter).

4.8.20.2Examples

Computing a link from a request operation where the$request.path.id is used to pass a request parameter to the linked operation.

paths:/users/{id}:parameters:-name:idin:pathrequired:truedescription:theuseridentifier,asuserIdschema:type:stringget:responses:'200':description:theuserbeingreturnedcontent:application/json:schema:type:objectproperties:uuid:# the unique user idtype:stringformat:uuidlinks:address:# the target link operationIdoperationId:getUserAddressparameters:# use the value of the request path parameter named "id"userid:$request.path.id# the path item of the linked operation/users/{userid}/address:parameters:-name:useridin:pathrequired:truedescription:theuseridentifier,asuserIdschema:type:string# linked operationget:operationId:getUserAddressresponses:'200':description:theuser'saddress

When a runtime expression fails to evaluate, no parameter value is passed to the target operation.

Values from the response body can be used to drive a linked operation.

links:address:operationId:getUserAddressByUUIDparameters:# use the value of the `uuid` field in the response bodyuserUuid:$response.body#/uuid

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

4.8.20.2.1operationRef Examples

As theoperationId is an optional field in anOperation Object, referencesMAY instead be made through a URI-reference withoperationRef.Note that both of these examples reference operations that can be identified via thePaths Object to ensure that the operation’s path template is unambiguous.

A relative URI-referenceoperationRef:

links:UserRepositories:operationRef:'#/paths/~12.0~1repositories~1%7Busername%7D/get'parameters:username:$response.body#/username

A non-relative URIoperationRef:

links:UserRepositories:operationRef:https://na2.gigantic-server.com/#/paths/~12.0~1repositories~1%7Busername%7D/getparameters:username:$response.body#/username

Note that in the use ofoperationRef theescaped forward-slash (~1) is necessary whenusing JSON Pointer in URI fragments, and it is necessary to URL-encode{ and} as%7B and%7D, respectively.The unescaped, percent-decoded path template in the above examples would be/2.0/repositories/{username}.

4.8.20.3Runtime Expressions

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

The runtime expression is defined by the following [ABNF] syntax

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

Here,json-pointer is taken from [RFC6901],char from [RFC7159]Section 7 andtoken from [RFC7230]Section 3.2.6.

Thename identifier is case-sensitive, whereastoken is not.

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

4.8.20.3.1Example Expressions
Source Locationexample expressionnotes
HTTP Method$methodThe allowable values for the$method will be those for the HTTP operation.
Requested media type$request.header.accept
Request parameter$request.path.idRequest parametersMUST be declared in theparameters section of the parent operation or they cannot be evaluated. This includes request headers.
Request body property$request.body#/user/uuidIn operations which accept payloads, references may be made to portions of therequestBody or the entire body.
Request URL$url
Response value$response.body#/statusIn operations which return payloads, references may be made to portions of the response body or the entire body.
Response header$response.header.ServerSingle header values only are available

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

4.8.21Header Object

Describes a single header forHTTP responses and forindividual parts inmultipart representations; see the relevantResponse Object andEncoding Object documentation for restrictions on which headers can be described.

The Header Object follows the structure of theParameter Object, including determining its serialization strategy based on whetherschema orcontent is present, with the following changes:

  1. nameMUST NOT be specified, it is given in the correspondingheaders map.
  2. inMUST NOT be specified, it is implicitly inheader.
  3. All traits that are affected by the locationMUST be applicable to a location ofheader (for example,style). This means thatallowEmptyValue andallowReservedMUST NOT be used, andstyle, if used,MUST be limited to"simple".
4.8.21.1Fixed Fields
4.8.21.1.1Common Fixed Fields

These fieldsMAY be used with eithercontent orschema.

Field NameTypeDescription
descriptionstringA brief description of the header. This could contain examples of use. [CommonMark] syntaxMAY be used for rich text representation.
requiredbooleanDetermines whether this header is mandatory. The default value isfalse.
deprecatedbooleanSpecifies that the header is deprecated andSHOULD be transitioned out of usage. Default value isfalse.

This objectMAY be extended withSpecification Extensions.

4.8.21.1.2Fixed Fields for use withschema

For simpler scenarios, aschema andstyle can describe the structure and syntax of the header.Whenexample orexamples are provided in conjunction with theschema field, the exampleMUST follow the prescribed serialization strategy for the header.

When serializing headers withschema, URI percent-encodingMUST NOT be applied; if using an RFC6570 implementation that automatically applies it, itMUST be removed before use.ImplementationsMUST pass header values through unchanged rather than attempting to automatically quote header values, as the quoting rules vary too widely among different headers; seeAppendix D for guidance on quoting and escaping.

Whenexample orexamples are provided in conjunction with theschema field, the exampleSHOULD match the specified schema and follow the prescribed serialization strategy for the header.Theexample andexamples fields are mutually exclusive, and if either is present itSHALLoverride anyexample in the schema.

Field NameTypeDescription
stylestringDescribes how the header value will be serialized. The default (and only legal value for headers) is"simple".
explodebooleanWhen this is true, header values of typearray orobject generate a single header whose value is a comma-separated list of the array items or key-value pairs of the map, seeStyle Examples. For other data types this field has no effect. The default value isfalse.
schemaSchema ObjectThe schema defining the type used for the header.
exampleAnyExample of the header’s potential value; seeWorking With Examples.
examplesMap[string,Example Object |Reference Object]Examples of the header’s potential value; seeWorking With Examples.

See alsoAppendix C: Using RFC6570-Based Serialization for additional guidance.

4.8.21.1.3Fixed Fields for use withcontent

For more complex scenarios, thecontent field can define the media type and schema of the header, as well as give examples of its use.

Field NameTypeDescription
contentMap[string,Media Type Object]A map containing the representations for the header. The key is the media type and the value describes it. The mapMUST only contain one entry.
4.8.21.2Header Object Example

A simple header of typeinteger:

"X-Rate-Limit-Limit":{"description":"The number of allowed requests in the current period","schema":{"type":"integer"}}
X-Rate-Limit-Limit:description:Thenumberofallowedrequestsinthecurrentperiodschema:type:integer

Requiring that a strongETag header (with a value starting with" rather thanW/) is present.

"ETag":{"required":true,"schema":{"type":"string","pattern":"^\""}}
ETag:required:trueschema:type:stringpattern:^"

4.8.22Tag Object

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

4.8.22.1Fixed Fields
Field NameTypeDescription
namestringREQUIRED. The name of the tag.
descriptionstringA description for the tag. [CommonMark] syntaxMAY be used for rich text representation.
externalDocsExternal Documentation ObjectAdditional external documentation for this tag.

This objectMAY be extended withSpecification Extensions.

4.8.22.2Tag Object Example
{"name":"pet","description":"Pets operations"}
name:petdescription:Petsoperations

4.8.23Reference Object

A simple object to allow referencing other components in the OpenAPI Description, internally and externally.

The$ref string value contains a URI [RFC3986], which identifies the value being referenced.

See the rules for resolvingRelative References.

4.8.23.1Fixed Fields
Field NameTypeDescription
$refstringREQUIRED. The reference identifier. ThisMUST be in the form of a URI.
summarystringA short summary which by defaultSHOULD override that of the referenced component. If the referenced object-type does not allow asummary field, then this field has no effect.
descriptionstringA description which by defaultSHOULD override that of the referenced component. [CommonMark] syntaxMAY be used for rich text representation. If the referenced object-type does not allow adescription field, then this field has no effect.

This object cannot be extended with additional properties, and any properties addedSHALL be ignored.

Note that this restriction on additional properties is a difference between Reference Objects andSchema Objects that contain a$ref keyword.

4.8.23.2Reference Object Example
{"$ref":"#/components/schemas/Pet"}
$ref:'#/components/schemas/Pet'
4.8.23.3Relative Schema Document Example
{"$ref":"Pet.json"}
$ref:Pet.yaml
4.8.23.4Relative Documents with Embedded Schema Example
{"$ref":"definitions.json#/Pet"}
$ref:definitions.yaml#/Pet

4.8.24Schema 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 theJSON Schema Specification Draft 2020-12. The empty schema (which allows any instance to validate)MAY be represented by the boolean valuetrue and a schema which allows no instance to validateMAY be represented by the boolean valuefalse.

For more information about the keywords, seeJSON Schema Core andJSON Schema Validation.

Unless stated otherwise, the keyword definitions follow those of JSON Schema and do not add any additional semantics; this includes keywords such as$schema,$id,$ref, and$dynamicRef being URIs rather than URLs.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.

4.8.24.1JSON Schema Keywords

The OpenAPI Schema Objectdialect is defined as requiring theOAS base vocabulary, in addition to the vocabularies as specified in the JSON Schema Specification Draft 2020-12general purpose meta-schema.

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

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

  • description - [CommonMark] syntaxMAY be used for rich text representation.
  • format - SeeData 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 keywords comprising the OAS dialect, the Schema Object supports keywords from any other vocabularies, or entirely arbitrary properties.

JSON Schema implementationsMAY choose to treat keywords defined by the OpenAPI Specification’s base vocabulary asunknown keywords, due to its inclusion in the OAS dialect with a$vocabulary value offalse.The OAS base vocabulary is comprised of the following keywords:

4.8.24.2Fixed Fields
Field NameTypeDescription
discriminatorDiscriminator ObjectAdds support for polymorphism. The discriminator is used to determine which of a set of schemas a payload is expected to satisfy. SeeComposition and Inheritance for more details.
xmlXML ObjectThisMAY be used only on property schemas. It has no effect on root schemas. Adds additional metadata to describe the XML representation of this property.
externalDocsExternal Documentation ObjectAdditional external documentation for this schema.
exampleAnyA free-form field 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: Theexample field has been deprecated in favor of the JSON Schemaexamples keyword. Use ofexample is discouraged, and later versions of this specification may remove it.

This objectMAY be extended withSpecification Extensions, though as noted, additional propertiesMAY omit thex- prefix within this object.

4.8.24.3Extended Validation with Annotations

JSON Schema Draft 2020-12 supportscollecting annotations, includingtreating unrecognized keywords as annotations.OAS implementationsMAY use such annotations, includingextensions not recognized as part of a declared JSON Schema vocabulary, as the basis for further validation.Note that JSON Schema Draft 2020-12 does not require anx- prefix for extensions.

4.8.24.3.1Non-validating constraint keywords

Theformat keyword (when using default format-annotation vocabulary) and thecontentMediaType,contentEncoding, andcontentSchema keywords define constraints on the data, but are treated as annotations instead of being validated directly.Extended validation is one way that these constraintsMAY be enforced.

4.8.24.3.2ValidatingreadOnly andwriteOnly

ThereadOnly andwriteOnly keywords are annotations, as JSON Schema is not aware of how the data it is validating is being used.Validation of these keywordsMAY be done by checking the annotation, the read or write direction, and (if relevant) the current value of the field.JSON Schema Validation Draft 2020-12 §9.4 defines the expectations of these keywords, including that a resource (described as the “owning authority”)MAY either ignore areadOnly field or treat it as an error.

Fields that are both required and read-only are an example of when it is beneficial to ignore areadOnly: true constraint in a PUT, particularly if the value has not been changed.This allows correctly requiring the field on a GET and still using the same representation and schema with PUT.Even when read-only fields are not required, stripping them is burdensome for clients, particularly when the JSON data is complex or deeply nested.

Note that the behavior ofreadOnly in particular differs from that specified by version 3.0 of this specification.

4.8.24.4Data Modeling Techniques
4.8.24.4.1Composition and Inheritance (Polymorphism)

The OpenAPI Specification allows combining and extending model definitions using theallOf keyword of JSON Schema, in effect offering model composition.allOf takes an array of object definitions that are validatedindependently but together compose a single object.

While composition offers model extensibility, it does not imply a hierarchy between the models.To support polymorphism, the OpenAPI Specification adds thediscriminator field.When used, thediscriminator indicates the name of the property that hints which schema definition is expected to validate the structure of the model.As such, thediscriminator fieldMUST be a required field.There are two ways to define the value of a discriminator for an inheriting instance.

  • Use the schema name.
  • Override the schema name by overriding the property with a new value. If a new value exists, this takes precedence over the schema name.
4.8.24.4.2Generic (Template) Data Structures

ImplementationsMAY support defining generic or template data structures using JSON Schema’s dynamic referencing feature:

  • $dynamicAnchor identifies a set of possible schemas (including a default placeholder schema) to which a$dynamicRef can resolve
  • $dynamicRef resolves to the first matching$dynamicAnchor encountered on its path from the schema entry point to the reference, as described in the JSON Schema specification

An example is included in the “Schema Object Examples” section below, and further information can be found on the Learn OpenAPI site’s“Dynamic References” page.

4.8.24.4.3Annotated Enumerations

The Schema Object’senum keyword does not allow associating descriptions or other information with individual values.

ImplementationsMAY support recognizing aoneOf oranyOf where each subschema in the keyword’s array consists of aconst keyword and annotations such astitle ordescription as an enumerated type with additional information. The exact behavior of this pattern beyond what is required by JSON Schema is implementation-defined.

4.8.24.4.4XML Modeling

Thexml field allows extra definitions when translating the JSON definition to XML.TheXML Object contains additional information about the available options.

4.8.24.5Specifying Schema Dialects

It is important for tooling to be able to determine which dialect or meta-schema any given resource wishes to be processed with: JSON Schema Core, JSON Schema Validation, OpenAPI Schema dialect, or some custom meta-schema.

The$schema keywordMAY be present in any Schema Object that is aschema resource root, and if presentMUST be used to determine which dialect should be used when processing the schema. This allows use of Schema Objects which comply with other drafts of JSON Schema than the default Draft 2020-12 support. ToolingMUST support theOAS dialect schema id, andMAY support additional values of$schema.

To allow use of a different default$schema value for all Schema Objects contained within an OAS document, ajsonSchemaDialect value may be set within theOpenAPI Object. If this default is not set, then the OAS dialect schema idMUST be used for these Schema Objects. The value of$schema within a resource root Schema Object always overrides any default.

For standalone JSON Schema documents that do not set$schema, or for Schema Objects in OpenAPI description documents that arenotcomplete documents, the dialectSHOULD be assumed to be the OAS dialect.However, for maximum interoperability, it isRECOMMENDED that OpenAPI description authors explicitly set the dialect through$schema in such documents.

4.8.24.6Schema Object Examples
4.8.24.6.1Primitive Example
{"type":"string","format":"email"}
type:stringformat:email
4.8.24.6.2Simple Model
{"type":"object","required":["name"],"properties":{"name":{"type":"string"},"address":{"$ref":"#/components/schemas/Address"},"age":{"type":"integer","format":"int32","minimum":0}}}
type:objectrequired:-nameproperties:name:type:stringaddress:$ref:'#/components/schemas/Address'age:type:integerformat:int32minimum:0
4.8.24.6.3Model with Map/Dictionary Properties

For a simple string to string mapping:

{"type":"object","additionalProperties":{"type":"string"}}
type:objectadditionalProperties:type:string

For a string to model mapping:

{"type":"object","additionalProperties":{"$ref":"#/components/schemas/ComplexModel"}}
type:objectadditionalProperties:$ref:'#/components/schemas/ComplexModel'
4.8.24.6.4Model with Annotated Enumeration
{"oneOf":[{"const":"RGB","title":"Red, Green, Blue","description":"Specify colors with the red, green, and blue additive color model"},{"const":"CMYK","title":"Cyan, Magenta, Yellow, Black","description":"Specify colors with the cyan, magenta, yellow, and black subtractive color model"}]}
oneOf:-const:RGBtitle:Red,Green,Bluedescription:Specifycolorswiththered,green,andblueadditivecolormodel-const:CMYKtitle:Cyan,Magenta,Yellow,Blackdescription:Specifycolorswiththecyan,magenta,yellow,andblacksubtractivecolormodel
4.8.24.6.5Model with Example
{"type":"object","properties":{"id":{"type":"integer","format":"int64"},"name":{"type":"string"}},"required":["name"],"examples":[{"name":"Puma","id":1}]}
type:objectproperties:id:type:integerformat:int64name:type:stringrequired:-nameexamples:-name:Pumaid:1
4.8.24.6.6Models with Composition
{"components":{"schemas":{"ErrorModel":{"type":"object","required":["message","code"],"properties":{"message":{"type":"string"},"code":{"type":"integer","minimum":100,"maximum":600}}},"ExtendedErrorModel":{"allOf":[{"$ref":"#/components/schemas/ErrorModel"},{"type":"object","required":["rootCause"],"properties":{"rootCause":{"type":"string"}}}]}}}}
components:schemas:ErrorModel:type:objectrequired:-message-codeproperties:message:type:stringcode:type:integerminimum:100maximum:600ExtendedErrorModel:allOf:-$ref:'#/components/schemas/ErrorModel'-type:objectrequired:-rootCauseproperties:rootCause:type:string
4.8.24.6.7Models with Polymorphism Support
{"components":{"schemas":{"Pet":{"type":"object","discriminator":{"propertyName":"petType"},"properties":{"name":{"type":"string"},"petType":{"type":"string"}},"required":["name","petType"]},"Cat":{"description":"A representation of a cat. Note that `Cat` will be used as the discriminating value.","allOf":[{"$ref":"#/components/schemas/Pet"},{"type":"object","properties":{"huntingSkill":{"type":"string","description":"The measured skill for hunting","default":"lazy","enum":["clueless","lazy","adventurous","aggressive"]}},"required":["huntingSkill"]}]},"Dog":{"description":"A representation of a dog. Note that `Dog` will be used as the discriminating value.","allOf":[{"$ref":"#/components/schemas/Pet"},{"type":"object","properties":{"packSize":{"type":"integer","format":"int32","description":"the size of the pack the dog is from","default":0,"minimum":0}},"required":["packSize"]}]}}}}
components:schemas:Pet:type:objectdiscriminator:propertyName:petTypeproperties:name:type:stringpetType:type:stringrequired:-name-petTypeCat:# "Cat" will be used as the discriminating valuedescription:ArepresentationofacatallOf:-$ref:'#/components/schemas/Pet'-type:objectproperties:huntingSkill:type:stringdescription:Themeasuredskillforhuntingenum:-clueless-lazy-adventurous-aggressiverequired:-huntingSkillDog:# "Dog" will be used as the discriminating valuedescription:ArepresentationofadogallOf:-$ref:'#/components/schemas/Pet'-type:objectproperties:packSize:type:integerformat:int32description:thesizeofthepackthedogisfromdefault:0minimum:0required:-packSize
4.8.24.6.8Generic Data Structure Model
{"components":{"schemas":{"genericArrayComponent":{"$id":"fully_generic_array","type":"array","items":{"$dynamicRef":"#generic-array"},"$defs":{"allowAll":{"$dynamicAnchor":"generic-array"}}},"numberArray":{"$id":"array_of_numbers","$ref":"fully_generic_array","$defs":{"numbersOnly":{"$dynamicAnchor":"generic-array","type":"number"}}},"stringArray":{"$id":"array_of_strings","$ref":"fully_generic_array","$defs":{"stringsOnly":{"$dynamicAnchor":"generic-array","type":"string"}}},"objWithTypedArray":{"$id":"obj_with_typed_array","type":"object","required":["dataType","data"],"properties":{"dataType":{"enum":["string","number"]}},"oneOf":[{"properties":{"dataType":{"const":"string"},"data":{"$ref":"array_of_strings"}}},{"properties":{"dataType":{"const":"number"},"data":{"$ref":"array_of_numbers"}}}]}}}}
components:schemas:genericArrayComponent:$id:fully_generic_arraytype:arrayitems:$dynamicRef:'#generic-array'$defs:allowAll:$dynamicAnchor:generic-arraynumberArray:$id:array_of_numbers$ref:fully_generic_array$defs:numbersOnly:$dynamicAnchor:generic-arraytype:numberstringArray:$id:array_of_strings$ref:fully_generic_array$defs:stringsOnly:$dynamicAnchor:generic-arraytype:stringobjWithTypedArray:$id:obj_with_typed_arraytype:objectrequired:-dataType-dataproperties:dataType:enum:-string-numberoneOf:-properties:dataType:const:stringdata:$ref:array_of_strings-properties:dataType:const:numberdata:$ref:array_of_numbers

4.8.25Discriminator Object

When request bodies or response payloads may be one of a number of different schemas, a Discriminator Object gives a hint about the expected schema of the document.This hint can be used to aid in serialization, deserialization, and validation.The Discriminator Object does this by implicitly or explicitly associating the possible values of a named property with alternative schemas.

Note thatdiscriminatorMUST NOT change the validation outcome of the schema.

4.8.25.1Fixed Fields
Field NameTypeDescription
propertyNamestringREQUIRED. The name of the property in the payload that will hold the discriminating value. This propertySHOULD be required in the payload schema, as the behavior when the property is absent is undefined.
mappingMap[string,string]An object to hold mappings between payload values and schema names or URI references.

This objectMAY be extended withSpecification Extensions.

4.8.25.2Conditions for Using the Discriminator Object

The Discriminator Object is legal only when using one of the composite keywordsoneOf,anyOf,allOf.

In both theoneOf andanyOf use cases, where those keywords are adjacent todiscriminator, all possible schemasMUST be listed explicitly.

To avoid redundancy, the discriminatorMAY be added to a parent schema definition, and all schemas building on the parent schema via anallOf construct may be used as an alternate schema.

TheallOf form ofdiscriminator isonly useful for non-validation use cases; validation with the parent schema with this form ofdiscriminatordoes not perform a search for child schemas or use them in validation in any way.This is becausediscriminator cannot change the validation outcome, and no standard JSON Schema keyword connects the parent schema to the child schemas.

The behavior of any configuration ofoneOf,anyOf,allOf anddiscriminator that is not described above is undefined.

4.8.25.3Options for Mapping Values to Schemas

The value of the property named inpropertyName is used as the name of the associated schema under theComponents Object,unless amapping is present for that value.Themapping entry maps a specific property value to either a different schema component name, or to a schema identified by a URI.When using implicit or explicit schema component names, inlineoneOf oranyOf subschemas are not considered.The behavior of amapping value that is both a valid schema name and a valid relative URI reference is implementation-defined, but it isRECOMMENDED that it be treated as a schema name.To ensure that an ambiguous value (e.g."foo") is treated as a relative URI reference by all implementations, authorsMUST prefix it with the"." path segment (e.g."./foo").

Mapping keysMUST be string values, but toolingMAY convert response values to strings for comparison.However, the exact nature of such conversions are implementation-defined.

4.8.25.4Examples

For these examples, assume all schemas are in theentry document of the OAD; for handling ofdiscriminator in referenced documents seeResolving Implicit Connections.

In OAS 3.x, a response payloadMAY be described to be exactly one of any number of types:

MyResponseType:oneOf:-$ref:'#/components/schemas/Cat'-$ref:'#/components/schemas/Dog'-$ref:'#/components/schemas/Lizard'

which means the payloadMUST, by validation, match exactly one of the schemas described byCat,Dog, orLizard. Deserialization of aoneOf can be a costly operation, as it requires determining which schema matches the payload and thus should be used in deserialization. This problem also exists foranyOf schemas. AdiscriminatorMAY be used as a “hint” to improve the efficiency of selection of the matching schema. Thediscriminator field cannot change the validation result of theoneOf, it can only help make the deserialization more efficient and provide better error messaging. We can specify the exact field that tells us which schema is expected to match the instance:

MyResponseType:oneOf:-$ref:'#/components/schemas/Cat'-$ref:'#/components/schemas/Dog'-$ref:'#/components/schemas/Lizard'discriminator:propertyName:petType

The expectation now is that a property with namepetTypeMUST be present in the response payload, and the value will correspond to the name of a schema defined in the OpenAPI Description. Thus the response payload:

{"id":12345,"petType":"Cat"}

will indicate that theCat schema is expected to match this payload.

In scenarios where the value of thediscriminator field does not match the schema name or implicit mapping is not possible, an optionalmapping definitionMAY be used:

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

Here the discriminating value ofdog will map to the schema#/components/schemas/Dog, rather than the default (implicit) value of#/components/schemas/dog. If the discriminating value does not match an implicit or explicit mapping, no schema can be determined and validationSHOULD fail.

When used in conjunction with theanyOf construct, the use of the discriminator can avoid ambiguity for serializers/deserializers where multiple schemas may satisfy a single payload.

This example shows theallOf usage, which avoids needing to reference all child schemas in the parent:

components:schemas:Pet:type:objectrequired:-petTypeproperties:petType:type:stringdiscriminator:propertyName:petTypemapping:dog:DogCat:allOf:-$ref:'#/components/schemas/Pet'-type:object# all other properties specific to a "Cat"properties:name:type:stringDog:allOf:-$ref:'#/components/schemas/Pet'-type:object# all other properties specific to a "Dog"properties:bark:type:stringLizard:allOf:-$ref:'#/components/schemas/Pet'-type:object# all other properties specific to a "Lizard"properties:lovesRocks:type:boolean

Validated against thePet schema, a payload like this:

{"petType":"Cat","name":"Misty"}

will indicate that the#/components/schemas/Cat schema is expected to match. Likewise this payload:

{"petType":"dog","bark":"soft"}

will map to#/components/schemas/Dog because thedog entry in themapping element maps toDog which is the schema name for#/components/schemas/Dog.

4.8.26XML Object

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

When using arrays, XML element names arenot inferred (for singular/plural forms) and thename fieldSHOULD be used to add that information.See examples for expected behavior.

4.8.26.1Fixed Fields
Field NameTypeDescription
namestringReplaces the inferred name of the element/attribute used for the described schema property. For the root schema object of aschema component, the inferred name is the name of the component; for other schemas the name is inferred from the parent property name. When defined withinitems, it will affect the name of the individual XML elements within the list. When defined alongsidetype being"array" (outside theitems), it will affect the wrapping element if and only ifwrapped istrue. Ifwrapped isfalse, it will be ignored.
namespacestringThe URI of the namespace definition. ValueMUST be in the form of a non-relative URI.
prefixstringThe prefix to be used for thename.
attributebooleanDeclares whether the property definition translates to an attribute instead of an element. Default value isfalse.
wrappedbooleanMAY 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 isfalse. The definition takes effect only when defined alongsidetype being"array" (outside theitems).

This objectMAY be extended withSpecification Extensions.

4.8.26.2Namespace Limitations

Thenamespace field is intended to match the syntax ofXML namespaces, although there are a few caveats:

  • Versions 3.1.0, 3.0.3, and earlier of this specification erroneously used the term “absolute URI” instead of “non-relative URI”, so authors using namespaces that include a fragment should check tooling support carefully.
  • XML allows but discourages relative URI-references, while this specification outright forbids them.
  • XML 1.1 allows IRIs ([RFC3987]) as namespaces, and specifies that namespaces are compared without any encoding or decoding, which means that IRIs encoded to meet this specification’s URI syntax requirement cannot be compared to IRIs as-is.
4.8.26.3Handlingnull Values

XML does not, by default, have a concept equivalent tonull, and to preserve compatibility with version 3.1.1 and earlier of this specification, the behavior of serializingnull values is implementation-defined.

However, implementationsSHOULD handlenull values as follows:

  • For elements, produce an empty element with anxsi:nil="true" attribute.
  • For attributes, omit the attribute.

Note that for attributes, this makes either anull value or a missing property serialize to an omitted attribute.As the Schema Object validates the in-memory representation, this allows handling the combination ofnull and a required property.However, because there is no distinct way to representnull as an attribute, it isRECOMMENDED to make attribute properties optional rather than usenull.

To ensure correct round-trip behavior, when parsing an element that omits an attribute, implementationsSHOULD set the corresponding property tonull if the schema allows for that value (e.g.type: ["number", "null"]), and omit the property otherwise (e.g.type: "number").

4.8.26.4XML Object Examples

Each of the following examples represent the value of theproperties keyword in aSchema Object that is omitted for brevity.The JSON and YAML representations of theproperties value are followed by an example XML representation produced for the single property shown.

4.8.26.4.1No XML Element

Basic string property:

{"animals":{"type":"string"}}
animals:type:string
<animals>...</animals>

Basic string array property (wrapped isfalse by default):

{"animals":{"type":"array","items":{"type":"string"}}}
animals:type:arrayitems:type:string
<animals>...</animals><animals>...</animals><animals>...</animals>
4.8.26.4.2XML Name Replacement
{"animals":{"type":"string","xml":{"name":"animal"}}}
animals:type:stringxml:name:animal
<animal>...</animal>
4.8.26.4.3XML Attribute, Prefix and Namespace

In this example, a fullschema component definition is shown.Note that the name of the root XML element comes from the component name.

{"components":{"schemas":{"Person":{"type":"object","properties":{"id":{"type":"integer","format":"int32","xml":{"attribute":true}},"name":{"type":"string","xml":{"namespace":"https://example.com/schema/sample","prefix":"sample"}}}}}}}
components:schemas:Person:type:objectproperties:id:type:integerformat:int32xml:attribute:truename:type:stringxml:namespace:https://example.com/schema/sampleprefix:sample
<Personid="123"><sample:namexmlns:sample="https://example.com/schema/sample">example</sample:name></Person>
4.8.26.4.4XML Arrays

Changing the element names:

{"animals":{"type":"array","items":{"type":"string","xml":{"name":"animal"}}}}
animals:type:arrayitems:type:stringxml:name:animal
<animal>value</animal><animal>value</animal>

The externalname field has no effect on the XML:

{"animals":{"type":"array","items":{"type":"string","xml":{"name":"animal"}},"xml":{"name":"aliens"}}}
animals:type:arrayitems:type:stringxml:name:animalxml:name:aliens
<animal>value</animal><animal>value</animal>

Even when the array is wrapped, if a name is not explicitly defined, the same name will be used both internally and externally:

{"animals":{"type":"array","items":{"type":"string"},"xml":{"wrapped":true}}}
animals:type:arrayitems:type:stringxml:wrapped:true
<animals><animals>value</animals><animals>value</animals></animals>

To overcome the naming problem in the example above, the following definition can be used:

{"animals":{"type":"array","items":{"type":"string","xml":{"name":"animal"}},"xml":{"wrapped":true}}}
animals:type:arrayitems:type:stringxml:name:animalxml:wrapped:true
<animals><animal>value</animal><animal>value</animal></animals>

Affecting both internal and external names:

{"animals":{"type":"array","items":{"type":"string","xml":{"name":"animal"}},"xml":{"name":"aliens","wrapped":true}}}
animals:type:arrayitems:type:stringxml:name:animalxml:name:alienswrapped:true
<aliens><animal>value</animal><animal>value</animal></aliens>

If we change the external element but not the internal ones:

{"animals":{"type":"array","items":{"type":"string"},"xml":{"name":"aliens","wrapped":true}}}
animals:type:arrayitems:type:stringxml:name:alienswrapped:true
<aliens><aliens>value</aliens><aliens>value</aliens></aliens>
4.8.26.4.5XML Withnull Values

Recall that the schema validates the in-memory data, not the XML document itself.

{"product":{"type":"object","required":["count","description","related"],"properties":{"count":{"type":["number","null"],"xml":{"attribute":true}},"rating":{"type":"string","xml":{"attribute":true}},"description":{"type":"string"},"related":{"type":["object","null"]}}}}
product:type:objectrequired:-count-description-relatedproperties:count:type:-number-"null"xml:attribute:truerating:type:stringxml:attribute:truedescription:type:stringrelated:type:-object-"null"
<product><description>Thing</description><relatedxsi:nil="true" /></product>

The above XML example corresponds to the following in-memory instance:

{"product":{"count":null,"description":"Thing","related":null}}

4.8.27Security 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), mutual TLS (use of a client certificate), OAuth2’s common flows (implicit, password, client credentials and authorization code) as defined in [RFC6749], and [OpenID-Connect-Core].Please note that as of 2020, the implicit flow is about to be deprecated byOAuth 2.0 Security Best Current Practice. Recommended for most use cases is Authorization Code Grant flow with PKCE.

4.8.27.1Fixed Fields
Field NameTypeApplies ToDescription
typestringAnyREQUIRED. The type of the security scheme. Valid values are"apiKey","http","mutualTLS","oauth2","openIdConnect".
descriptionstringAnyA description for security scheme. [CommonMark] syntaxMAY be used for rich text representation.
namestringapiKeyREQUIRED. The name of the header, query or cookie parameter to be used.
instringapiKeyREQUIRED. The location of the API key. Valid values are"query","header", or"cookie".
schemestringhttpREQUIRED. The name of the HTTP Authentication scheme to be used in the Authorization header as defined in [RFC7235]Section 5.1. The values usedSHOULD be registered in theIANA Authentication Scheme registry. The value is case-insensitive, as defined in [RFC7235]Section 2.1.
bearerFormatstringhttp ("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.
flowsOAuth Flows Objectoauth2REQUIRED. An object containing configuration information for the flow types supported.
openIdConnectUrlstringopenIdConnectREQUIRED.Well-known URL to discover the [OpenID-Connect-Discovery]provider metadata.

This objectMAY be extended withSpecification Extensions.

4.8.27.2Security Scheme Object Examples
4.8.27.2.1Basic Authentication Example
{"type":"http","scheme":"basic"}
type:httpscheme:basic
4.8.27.2.2API Key Example
{"type":"apiKey","name":"api-key","in":"header"}
type:apiKeyname:api-keyin:header
4.8.27.2.3JWT Bearer Example
{"type":"http","scheme":"bearer","bearerFormat":"JWT"}
type:httpscheme:bearerbearerFormat:JWT
4.8.27.2.4MutualTLS Example
{"type":"mutualTLS","description":"Cert must be signed by example.com CA"}
type:mutualTLSdescription:Certmustbesignedbyexample.comCA
4.8.27.2.5Implicit OAuth2 Example
{"type":"oauth2","flows":{"implicit":{"authorizationUrl":"https://example.com/api/oauth/dialog","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}}}}
type:oauth2flows:implicit:authorizationUrl:https://example.com/api/oauth/dialogscopes:write:pets:modifypetsinyouraccountread:pets:readyourpets

4.8.28OAuth Flows Object

Allows configuration of the supported OAuth Flows.

4.8.28.1Fixed Fields
Field NameTypeDescription
implicitOAuth Flow ObjectConfiguration for the OAuth Implicit flow
passwordOAuth Flow ObjectConfiguration for the OAuth Resource Owner Password flow
clientCredentialsOAuth Flow ObjectConfiguration for the OAuth Client Credentials flow. Previously calledapplication in OpenAPI 2.0.
authorizationCodeOAuth Flow ObjectConfiguration for the OAuth Authorization Code flow. Previously calledaccessCode in OpenAPI 2.0.

This objectMAY be extended withSpecification Extensions.

4.8.29OAuth Flow Object

Configuration details for a supported OAuth Flow

4.8.29.1Fixed Fields
Field NameTypeApplies ToDescription
authorizationUrlstringoauth2 ("implicit","authorizationCode")REQUIRED. The authorization URL to be used for this flow. ThisMUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
tokenUrlstringoauth2 ("password","clientCredentials","authorizationCode")REQUIRED. The token URL to be used for this flow. ThisMUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
refreshUrlstringoauth2The URL to be used for obtaining refresh tokens. ThisMUST be in the form of a URL. The OAuth2 standard requires the use of TLS.
scopesMap[string,string]oauth2REQUIRED. The available scopes for the OAuth2 security scheme. A map between the scope name and a short description for it. The mapMAY be empty.

This objectMAY be extended withSpecification Extensions.

4.8.29.2OAuth Flow Object Example
{"type":"oauth2","flows":{"implicit":{"authorizationUrl":"https://example.com/api/oauth/dialog","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}},"authorizationCode":{"authorizationUrl":"https://example.com/api/oauth/dialog","tokenUrl":"https://example.com/api/oauth/token","scopes":{"write:pets":"modify pets in your account","read:pets":"read your pets"}}}}
type:oauth2flows:implicit:authorizationUrl:https://example.com/api/oauth/dialogscopes:write:pets:modifypetsinyouraccountread:pets:readyourpetsauthorizationCode:authorizationUrl:https://example.com/api/oauth/dialogtokenUrl:https://example.com/api/oauth/tokenscopes:write:pets:modifypetsinyouraccountread:pets:readyourpets

4.8.30Security Requirement Object

Lists the required security schemes to execute this operation.The name used for each propertyMUST correspond to a security scheme declared in theSecurity Schemes under theComponents Object.

A Security Requirement ObjectMAY refer to multiple security schemes in which case all schemesMUST 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 thesecurity field is defined on theOpenAPI Object orOperation Object and contains multiple Security Requirement Objects, only one of the entries in the list needs to be satisfied to authorize the request.This enables support for scenarios where the API allows multiple, independent security schemes.

An empty Security Requirement Object ({}) indicates anonymous access is supported.

4.8.30.1Patterned Fields
Field PatternTypeDescription
{name}[string]Each nameMUST correspond to a security scheme which is declared in theSecurity Schemes under theComponents Object. If the security scheme is of type"oauth2" or"openIdConnect", then the value is a list of scope names required for the execution, and the listMAY be empty if authorization does not require a specified scope. For other security scheme types, the arrayMAY contain a list of role names which are required for the execution, but are not otherwise defined or exchanged in-band.
4.8.30.2Security Requirement Object Examples

See alsoAppendix F: Resolving Security Requirements in a Referenced Document for an example using Security Requirement Objects in multi-document OpenAPI Descriptions.

4.8.30.2.1Non-OAuth2 Security Requirement
{"api_key":[]}
api_key: []
4.8.30.2.2OAuth2 Security Requirement
{"petstore_auth":["write:pets","read:pets"]}
petstore_auth:-write:pets-read:pets
4.8.30.2.3Optional OAuth2 Security

Optional OAuth2 security as would be defined in anOpenAPI Object or anOperation Object:

{"security":[{},{"petstore_auth":["write:pets","read:pets"]}]}
security:- {}-petstore_auth:-write:pets-read:pets

4.9Specification Extensions

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

The extensions properties are implemented as patterned fields that are always prefixed byx-.

Field PatternTypeDescription
^x-AnyAllows extensions to the OpenAPI Schema. The field nameMUST begin withx-, for example,x-internal-id. Field names beginningx-oai- andx-oas- are reserved for uses defined by theOpenAPI Initiative. The value can be any valid JSON value (null, a primitive, an array, or an object.)

The OpenAPI Initiative maintains severalextension registries, including registries forindividual extension keywords andextension keyword namespaces.

Extensions are one of the best ways to prove the viability of proposed additions to the specification.It is thereforeRECOMMENDED that implementations be designed for extensibility to support community experimentation.

Support for any one extension isOPTIONAL, and support for one extension does not imply support for others.

4.10Security Filtering

Some objects in the OpenAPI SpecificationMAY be declared and remain empty, or be completely removed, even though they are inherently the core of the API documentation.

The reasoning is to allow an additional layer of access control over the documentation.While not part of the specification itself, certain librariesMAY choose to allow access to parts of the documentation based on some form of authentication/authorization.

Two examples of this:

  1. ThePaths ObjectMAY be present but empty. It may be counterintuitive, but this may tell the viewer that they got to the right place, but can’t access any documentation. They would still have access to at least theInfo Object which may contain additional information regarding authentication.
  2. ThePath Item ObjectMAY be empty. In this case, the viewer will be aware that the path exists, but will not be able to see any of its operations or parameters. This is different from hiding the path itself from thePaths Object, because the user will be aware of its existence. This allows the documentation provider to finely control what the viewer can see.

5.Security Considerations

5.1OpenAPI Description Formats

OpenAPI Descriptions use a combination of JSON, YAML, and JSON Schema, and therefore share their security considerations:

5.2Tooling and Usage Scenarios

In addition, OpenAPI Descriptions are processed by a wide variety of tooling for numerous different purposes, such as client code generation, documentation generation, server side routing, and API testing. OpenAPI Description authors must consider the risks of the scenarios where the OpenAPI Description may be used.

5.3Security Schemes

An OpenAPI Description describes the security schemes used to protect the resources it defines. The security schemes available offer varying degrees of protection. Factors such as the sensitivity of the data and the potential impact of a security breach should guide the selection of security schemes for the API resources. Some security schemes, such as basic auth and OAuth Implicit flow, are supported for compatibility with existing APIs. However, their inclusion in OpenAPI does not constitute an endorsement of their use, particularly for highly sensitive data or operations.

5.4Handling External Resources

OpenAPI Descriptions may contain references to external resources that may be dereferenced automatically by consuming tools. External resources may be hosted on different domains that may be untrusted.

5.5Handling Reference Cycles

References in an OpenAPI Description may cause a cycle. Tooling must detect and handle cycles to prevent resource exhaustion.

5.6Markdown and HTML Sanitization

Certain fields allow the use of Markdown which can contain HTML including script. It is the responsibility of tooling to appropriately sanitize the Markdown.

A.Appendix A: Revision History

VersionDateNotes
3.1.22025-09-19Patch release of the OpenAPI Specification 3.1.2
3.1.12024-10-24Patch release of the OpenAPI Specification 3.1.1
3.1.02021-02-15Release of the OpenAPI Specification 3.1.0
3.1.0-rc12020-10-08rc1 of the 3.1 specification
3.1.0-rc02020-06-18rc0 of the 3.1 specification
3.0.42024-10-24Patch release of the OpenAPI Specification 3.0.4
3.0.32020-02-20Patch release of the OpenAPI Specification 3.0.3
3.0.22018-10-08Patch release of the OpenAPI Specification 3.0.2
3.0.12017-12-06Patch release of the OpenAPI Specification 3.0.1
3.0.02017-07-26Release of the OpenAPI Specification 3.0.0
3.0.0-rc22017-06-16rc2 of the 3.0 specification
3.0.0-rc12017-04-27rc1 of the 3.0 specification
3.0.0-rc02017-02-28Implementer’s Draft of the 3.0 specification
2.02015-12-31Donation of Swagger 2.0 to the OpenAPI Initiative
2.02014-09-08Release of Swagger 2.0
1.22014-03-14Initial release of the formal document.
1.12012-08-22Release of Swagger 1.1
1.02011-08-10First release of the Swagger Specification

B.Appendix B: Data Type Conversion

Serializing typed data to plain text, which can occur intext/plain message bodies ormultipart parts, as well as in theapplication/x-www-form-urlencoded format in either URL query strings or message bodies, involves significant implementation- or application-defined behavior.

Schema Objects validate data based on theJSON Schema data model, which only recognizes four primitive data types: strings (which areonly broadly interoperable as UTF-8), numbers, booleans, andnull.Notably, integers are not a distinct type from other numbers, withtype: "integer" being a convenience defined mathematically, rather than based on the presence or absence of a decimal point in any string representation.

TheParameter Object,Header Object, andEncoding Object offer features to control how to arrange values from array or object types.They can also be used to control how strings are further encoded to avoid reserved or illegal characters.However, there is no general-purpose specification for converting schema-validated non-UTF-8 primitive data types (or entire arrays or objects) to strings.

Two cases do offer standards-based guidance:

Implementations of RFC6570 often have their own conventions for converting non-string values, but these are implementation-specific and not defined by the RFC itself.This is one reason for the OpenAPI Specification to leave these conversions as implementation-defined: It allows using RFC6570 implementations regardless of how they choose to perform the conversions.

To control the serialization of numbers, booleans, andnull (or other values RFC6570 deems to be undefined) more precisely, schemas can be defined astype: "string" and constrained usingpattern,enum,format, and other keywords to communicate how applications must pre-convert their data prior to schema validation.The resulting strings would not require any further type conversion.

Theformat keyword can assist in serialization.Some formats (such asdate-time) are unambiguous, while others (such asdecimal in theFormat Registry) are less clear.However, care must be taken withformat to ensure that the specific formats are supported by all relevant tools as unrecognized formats are ignored.

Requiring input as pre-formatted, schema-validated strings also improves round-trip interoperability as not all programming languages and environments support the same data types.

C.Appendix C: Using RFC6570-Based Serialization

Serialization is defined in terms of [RFC6570] URI Templates in three scenarios:

ObjectCondition
Parameter ObjectWhenschema is present
Header ObjectWhenschema is present
Encoding ObjectWhen encoding forapplication/x-www-form-urlencoded and any ofstyle,explode, orallowReserved are used

Implementations of this specificationMAY use an implementation of RFC6570 to perform variable expansion, however, some caveats apply.

Note that when usingstyle: "form" RFC6570 expansion to produce anapplication/x-www-form-urlencoded HTTP message body, it is necessary to remove the? prefix that is produced to satisfy the URI query string syntax.

When usingstyle and similar keywords to produce amultipart/form-data body, the query string names are placed in thename parameter of theContent-Disposition part header, and the values are placed in the corresponding part body; the?,=, and& characters are not used, and URI percent encoding is not applied, regardless of the value ofallowReserved.Note that while [RFC7578] allows using [RFC3986] percent-encoding in “file names”, it does not otherwise address the use of percent-encoding within the format.Users are expected to provide names and data with any escaping necessary for conformance with RFC7578 already applied.

Note also that not all RFC6570 implementations support all four levels of operators, all of which are needed to fully support the OpenAPI Specification’s usage.Using an implementation with a lower level of support will require additional manual construction of URI Templates to work around the limitations.

C.1Equivalences Between Fields and RFC6570 Operators

Certain field values translate to RFC6570operators (or lack thereof):

fieldvalueequivalent
style"simple"n/a
style"matrix"; prefix operator
style"label". prefix operator
style"form"? prefix operator
allowReservedfalsen/a
allowReservedtrue+ prefix operator
explodefalsen/a
explodetrue* modifier suffix

Multiplestyle: "form" parameters are equivalent to a single RFC6570variable list using the? prefix operator:

parameters:-name:fooin:queryschema:type:objectexplode:true-name:barin:queryschema:type:string

This example is equivalent to RFC6570’s{?foo*,bar}, andNOT{?foo*}{&bar}. The latter is problematic because iffoo is not defined, the result will be an invalid URI.The& prefix operator has no equivalent in the Parameter Object.

Note that RFC6570 does not specify behavior for compound values beyond the single level addressed byexplode. The result of using objects or arrays where no behavior is clearly specified for them is implementation-defined.

C.2Delimiters in Parameter Values

Delimiters used by RFC6570 expansion, such as the, used to join arrays or object values withstyle: "simple", are all automatically percent-encoded as long asallowReserved isfalse.Note that since RFC6570 does not define a way to parse variables based on a URI Template, users must take care to first split values by delimiter before percent-decoding values that might contain the delimiter character.

WhenallowReserved istrue, both percent-encoding (prior to joining values with a delimiter) and percent-decoding (after splitting on the delimiter) must be done manually at the correct time.

SeeAppendix E for additional guidance on handling delimiters forstyle values with no RFC6570 equivalent that already need to be percent-encoded when used as delimiters.

C.3Non-RFC6570 Field Values and Combinations

Configurations with no direct [RFC6570] equivalentSHOULD also be handled according to RFC6570.ImplementationsMAY create a properly delimited URI Template with variables for individual names and values using RFC6570 regular or reserved expansion (based onallowReserved).

This includes:

The Parameter Object’sname field has a much more permissive syntax than RFC6570variable name syntax.A parameter name that includes characters outside of the allowed RFC6570 variable character setMUST be percent-encoded before it can be used in a URI Template.

C.4Examples

Let’s say we want to use the following data in a form query string, whereformulas is exploded, andwords is not:

formulas:a:x+yb:x/yc:x^ywords:-math-is-fun

C.4.1RFC6570-Equivalent Expansion

This array of Parameter Objects uses regularstyle: "form" expansion, fully supported by [RFC6570]:

parameters:-name:formulasin:queryschema:type:objectadditionalProperties:type:stringexplode:true-name:wordsin:queryschema:type:arrayitems:type:string

This translates to the following URI Template:

{?formulas*,words}

when expanded with the data given earlier, we get:

?a=x%2By&b=x%2Fy&c=x%5Ey&words=math,is,fun

C.4.2Expansion with Non-RFC6570-Supported Options

But now let’s say that (for some reason), we really want that/ in theb formula to show up as-is in the query string, and we want our words to be space-separated like in a written phrase.To do that, we’ll addallowReserved: true toformulas, and change tostyle: "spaceDelimited" forwords:

parameters:-name:formulasin:queryschema:type:objectadditionalProperties:type:stringexplode:trueallowReserved:true-name:wordsin:querystyle:spaceDelimitedexplode:falseschema:type:arrayitems:type:string

We can’t combine the? and+ RFC6570prefixes, and there’s no way with RFC6570 to replace the, separator with a space character.So we need to restructure the data to fit a manually constructed URI Template that passes all of the pieces through the right sort of expansion.

Here is one such template, using a made-up convention ofwords.0 for the first entry in the words value,words.1 for the second, andwords.2 for the third:

?a={+a}&b={+b}&c={+c}&words={words.0} {words.1} {words.2}

RFC6570mentions the use of. “to indicate name hierarchy in substructures,” but does not define any specific naming convention or behavior for it.Since the. usage is not automatic, we’ll need to construct an appropriate input structure for this new template.

We’ll also need to pre-process the values forformulas because while/ and most other reserved characters are allowed in the query string by RFC3986,[,], and#are not, and&,=, and+ all havespecial behavior in theapplication/x-www-form-urlencoded format, which is what we are using in the query string.

SettingallowReserved: true doesnot make reserved characters that are not allowed in URIs allowed, it just allows them to bepassed through expansion unchanged, for example because some other specification has defined a particular meaning for them.

Therefore, users still need to percent-encode any reserved characters that arenot being passed through due to a special meaning because reserved expansion does not know which reserved characters are being used, and which should still be percent-encoded.However, reserved expansion, unlike regular expansion,will leave the pre-percent-encoded triples unchanged.See alsoAppendix E for further guidance on percent-encoding and form media types, including guidance on handling the delimiter characters forspaceDelimited,pipeDelimited, anddeepObject in parameter names and values.

So here is our data structure that arranges the names and values to suit the template above, where values forformulas have[]#&=+ pre-percent encoded (although only+ appears in this example):

a:x%2Byb:x/yc:x^ywords.0:mathwords.1:iswords.2:fun

Expanding our manually assembled template with our restructured data yields the following query string:

?a=x%2By&b=x/y&c=x%5Ey&words=math%20is%20fun

The/ and the pre-percent-encoded%2B have been left alone, but the disallowed^ character (inside a value) and space characters (in the template but outside of the expanded variables) were percent-encoded.

C.4.3Undefined Values and Manual URI Template Construction

Care must be taken when manually constructing templates to handle the values that RFC6570considers to beundefined correctly:

formulas: {}words:-hello-world

Using this data with our original RFC6570-friendly URI Template,{?formulas*,words}, produces the following:

?words=hello,world

This means that the manually constructed URI Template and restructured data need to leave out theformulas object entirely so that thewords parameter is the first and only parameter in the query string.

Restructured data:

words.0:hellowords.1:world

Manually constructed URI Template:

?words={words.0} {words.1}

Result:

?words=hello%20world

C.4.4Illegal Variable Names as Parameter Names

In this example, the heart emoji is not legal in URI Template names (or URIs):

parameters:-name:❤️in:queryschema:type:string

We can’t just pass❤️: "love!" to an RFC6570 implementation.Instead, we have to pre-percent-encode the name (which is a six-octet UTF-8 sequence) in both the data and the URI Template:

"%E2%9D%A4%EF%B8%8F":love!
{?%E2%9D%A4%EF%B8%8F}

This will expand to the result:

?%E2%9D%A4%EF%B8%8F=love%21

D.Appendix D: Serializing Headers and Cookies

HTTP headers have inconsistent rules regarding what characters are allowed, and how some or all disallowed characters can be escaped and included.While thequoted-string ABNF rule given in [RFC7230]Section 3.2.6 is the most common escaping solution, it is not sufficiently universal to apply automatically.For example, a strongETag looks like"foo" (with quotes, regardless of the contents), and a weakETag looks likeW/"foo" (note that only part of the value is quoted); the contents of the quotes for this header are also not escaped in the wayquoted-string contents are.

For this reason, any data being passed to a header by way of aParameter orHeader Object needs to be quoted and escaped prior to passing it to the OAS implementation, and the parsed header values are expected to contain the quotes and escapes.

D.1Percent-Encoding and Cookies

Note: OAS v3.0.4 and v3.1.1 applied the advice in this section to avoid RFC6570-style serialization to both headers and cookies.However, further research has indicated that percent-encoding was never intended to apply to headers, so this section has been corrected to apply only to cookies.

[RFC6570]'s percent-encoding behavior is not always appropriate forin: "cookie" parameters.In many cases, it is more appropriate to usecontent with a media type such astext/plain and require the application to assemble the correct string.

[RFC6265] recommends (but does not strictly required) base64 encoding (contentEncoding: "base64") if “arbitrary data” will be stored in a cookie.Note that the standard base64-encoding alphabet includes non-URL-safe characters that are percent-encoded by RFC6570 expansion; serializing values through both encodings isNOT RECOMMENDED.WhilecontentEncoding also supports thebase64url encoding, which is URL-safe, the header and cookie RFCs do not mention this encoding.

Usingstyle: "form" within: "cookie" via an RFC6570 implementation requires stripping the? prefix, as when producingapplication/x-www-form-urlencoded message bodies.

For multiple values,style: "form" is always incorrect, even if no characters are subject to percent-encoding, as name=value pairs in cookies are delimited by a semicolon followed by a space character rather than&.

E.Appendix E: Percent-Encoding and Form Media Types

NOTE: In this section, theapplication/x-www-form-urlencoded andmultipart/form-data media types are abbreviated asform-urlencoded andform-data, respectively, for readability.

Percent-encoding is used in URIs and media types that derive their syntax from URIs.The fundamental rules of percent-encoding are:

The rest of this appendix provides more detailed guidance based on the above rules.

E.1Percent-Encoding Character Classes

This process is concerned with three classes of characters, the names of which vary among specifications but are defined as follows for the purposes of this section:

Unless otherwise specified, this section uses RFC3986’s definition ofreserved andunreserved, and defines the unsafe set as all characters not included in either of those sets.

E.2Percent-Encoding andform-urlencoded

Each URI component (such as the query string) considers some of the reserved characters to be unsafe, either because they serve as delimiters between the components (e.g.#), or (in the case of[ and]) were historically considered globally unsafe but were later given reserved status for limited purposes.

Reserved characters with no special meaning defined within a component can be left un-percent encoded.However, other specifications can define special meanings, requiring percent-encoding for those characters outside of the additional special meanings.

Theform-urlencoded media type defines special meanings for= and& as delimiters, and+ as the replacement for the space character (instead of its percent-encoded form of%20).This means that while these three characters are reserved-but-allowed in query strings by RFC3986, they must be percent-encoded inform-urlencoded query strings except when used for theirform-urlencoded purposes; seeAppendix C for an example of handling+ in form values.

E.3Percent-Encoding andform-data

[RFC7578]Section 2 suggests RFC3986-based percent-encoding as a mechanism to keep text-based per-part header data such as file names within the ASCII character set.This suggestion was not part of older (pre-2015) specifications forform-data, so care must be taken to ensure interoperability.Users wishing to use percent-encoding in this wayMUST provide the data in percent-encoded form, as percent-encoding is not automatically applied for this media type regardless of which Encoding Object fields are used.

Theform-data media type allows arbitrary text or binary data in its parts, so percent-encoding or similar escaping is not needed in general.

E.4Generating and Validating URIs andform-urlencoded Strings

URI percent encoding and theform-urlencoded media type have complex specification histories spanning multiple revisions and, in some cases, conflicting claims of ownership by different standards bodies.Unfortunately, these specifications each define slightly different percent-encoding rules, which need to be taken into account if the URIs orform-urlencoded message bodies will be subject to strict validation.(Note that many URI parsers do not perform validation by default, if at all.)

This specification normatively cites the following relevant standards:

SpecificationDateOAS UsagePercent-EncodingNotes
[RFC3986]01/2005URI/URL syntax[RFC3986]obsoletes [RFC1738], [RFC2396]
[RFC6570]03/2012style-based serialization[RFC3986]does not use+ forform‑urlencoded
[RFC1866]Section 8.2.111/1995content-based serialization[RFC1738]obsoleted by [HTML401]Section 17.13.4.1, [URL]Section 5

Style-based serialization with percent-encoding is used in theParameter Object whenschema is present, and in theEncoding Object when at least one ofstyle,explode, orallowReserved is present.SeeAppendix C for more details of RFC6570’s two different approaches to percent-encoding, including an example involving+.

Content-based serialization is defined by theMedia Type Object, and used with theParameter Object andHeader Object when thecontent field is present, and with theEncoding Object based on thecontentType field when the fieldsstyle,explode, andallowReserved are absent.Each part is encoded based on the media type (e.g.text/plain orapplication/json), and must then be percent-encoded for use in aform-urlencoded string unless the media type already incorporates URI percent-encoding.

E.4.1Interoperability with Historical Specifications

In most cases, generating query strings in strict compliance with [RFC3986] is sufficient to pass validation (including JSON Schema’sformat: "uri" andformat: "uri-reference" whenformat validation is enabled), but someform-urlencoded implementations still expect the slightly more restrictive [RFC1738] rules to be used.

Since all RFC1738-compliant URIs are compliant with RFC3986, applications needing to ensure historical interoperabilitySHOULD use RFC1738’s rules.

E.4.2Interoperability with Web Browser Environments

WHATWG is aweb browser-oriented standards group that has defined a “URL Living Standard” for parsing and serializing URLs in a browser context, including parsing and serializingform-urlencoded data.WHATWG’s percent-encoding rules for query strings are different depending on whether the query string isbeing treated asform-urlencoded (where it requires more percent-encoding than [RFC1738]) oras part of the generic syntax, where it allows characters that [RFC3986] forbids.

Implementations needing maximum compatibility with web browsersSHOULD use WHATWG’sform-urlencoded percent-encoding rules.However, theySHOULD NOT rely on WHATWG’s less stringent generic query string rules, as the resulting URLs would fail RFC3986 validation, including JSON Schema’sformat: uri andformat: uri-reference (whenformat validation is endabled).

E.5Decoding URIs andform-urlencoded Strings

The percent-decoding algorithm does not care which characters were or were not percent-decoded, which means that URIs percent-encoded according to any specification will be decoded correctly.

Similarly, allform-urlencoded decoding algorithms simply add+-for-space handling to the percent-decoding algorithm, and will work regardless of the encoding specification used.

However, care must be taken to useform-urlencoded decoding if+ represents a space, and to use regular percent-decoding if+ represents itself as a literal value.

E.6Percent-Encoding and Illegal or Reserved Delimiters

The[,],|, and space characters, which are used as delimiters for thedeepObject,pipeDelimited, andspaceDelimited styles, respectively, allMUST be percent-encoded to comply with [RFC3986].This requires users to pre-encode the character(s) in some other way in parameter names and values to distinguish them from the delimiter usage when using one of these styles.

The space character is always illegal and encoded in some way by all implementations of all versions of the relevant standards.While one could use theform-urlencoded convention of+ to distinguish spaces in parameter names and values fromspaceDelimited delimiters encoded as%20, the specifications define the decoding as a single pass, making it impossible to distinguish the different usages in the decoded result unless a non-standard parsing algorithm is used that separates based on one delimiter before decoding the other.Any such non-standard parsing approach will not be interoperable across all tools.

Some environments use[,], and possibly| unencoded in query strings without apparent difficulties.WHATWG’s generic query string rules do not require percent-encoding them in non-form-urlencoded query strings, although it also excludes them from the set of valid URL Unicode code points.Code that relies on leaving these delimiters unencoded, while using regular percent-encoding for them within names and values, is not guaranteed to be interoperable across all implementations.

For maximum interoperability, it isRECOMMENDED to either define and document an additional escape convention while percent-encoding the delimiters for these styles, or to avoid these styles entirely.The exact method of additional encoding/escaping is left to the API designer, and is expected to be performed before serialization and encoding described in this specification, and reversed after this specification’s encoding and serialization steps are reversed.This keeps it outside of the processes governed by this specification.

F.Appendix F: Resolving Security Requirements in a Referenced Document

This appendix shows how to retrieve an HTTP-accessible multi-document OpenAPI Description (OAD) and resolve aSecurity Requirement Object in the referenced (non-entry) document. SeeResolving Implicit Connections for more information.

First, theentry document is where parsing begins. It defines theMySecurity security scheme to be JWT-based, and it defines a Path Item as a reference to a component in another document:

GET/api/description/openapiHTTP/1.1Host:www.example.comAccept:application/openapi+json
"components":{"securitySchemes":{"MySecurity":{"type":"http","scheme":"bearer","bearerFormat":"JWT"}}},"paths":{"/foo":{"$ref":"other#/components/pathItems/Foo"}}
GET/api/description/openapiHTTP/1.1Host:www.example.comAccept:application/openapi+yaml
components:securitySchemes:MySecurity:type:httpscheme:bearerbearerFormat:JWTpaths:/foo:$ref:'other#/components/pathItems/Foo'

This entry document references another document,other, without using a file extension. This gives the client the flexibility to choose an acceptable format on a resource-by-resource basis, assuming both representations are available:

GET/api/description/otherHTTP/1.1Host:www.example.comAccept:application/openapi+json
"components":{"securitySchemes":{"MySecurity":{"type":"http","scheme":"basic"}},"pathItems":{"Foo":{"get":{"security":["MySecurity":[]]}}}}
GET/api/description/otherHTTP/1.1Host:www.example.comAccept:application/openapi+yaml
components:securitySchemes:MySecurity:type:httpscheme:basicpathItems:Foo:get:security:-MySecurity: []

In theother document, the referenced path item has a Security Requirement for a Security Scheme,MySecurity. The same Security Scheme exists in the original entry document. As outlined inResolving Implicit Connections,MySecurity is resolved with animplementation-defined behavior. However, documented in that section, it isRECOMMENDED that tools resolve component names from theentry document. As with all implementation-defined behavior, it is important to check tool documentation to determine which behavior is supported.

G.References

G.1Normative references

[ABNF]
Augmented BNF for Syntax Specifications: ABNF. D. Crocker, Ed.; P. Overell. IETF. January 2008. Internet Standard. URL:https://www.rfc-editor.org/rfc/rfc5234
[CommonMark]
CommonMark Spec. URL:https://spec.commonmark.org/
[CommonMark-0.27]
CommonMark Spec, Version 0.27. John MacFarlane. 18 November 2016. URL:https://spec.commonmark.org/0.27/
[HTML401]
HTML 4.01 Specification. Dave Raggett; Arnaud Le Hors; Ian Jacobs. W3C. 27 March 2018. W3C Recommendation. URL:https://www.w3.org/TR/html401/
[IANA-HTTP-AUTHSCHEMES]
Hypertext Transfer Protocol (HTTP) Authentication Scheme Registry. IANA. URL:https://www.iana.org/assignments/http-authschemes/
[IANA-HTTP-STATUS-CODES]
Hypertext Transfer Protocol (HTTP) Status Code Registry. IANA. URL:https://www.iana.org/assignments/http-status-codes/
[JSON-Schema-2020-12]
JSON Schema: A Media Type for Describing JSON Documents. Draft 2020-12. Austin Wright; Henry Andrews; Ben Hutton; Greg Dennis. Internet Engineering Task Force (IETF). 10 June 2022. Internet-Draft. URL:https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-01
[JSON-Schema-Validation-2020-12]
JSON Schema Validation: A Vocabulary for Structural Validation of JSON. Draft 2020-12. Austin Wright; Henry Andrews; Ben Hutton. Internet Engineering Task Force (IETF). 10 June 2022. Internet-Draft. URL:https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-01
[OpenAPI-Registry]
OpenAPI Initiative Registry. OpenAPI Initiative. URL:https://spec.openapis.org/registry/index.html
[OpenID-Connect-Core]
OpenID Connect Core 1.0 incorporating errata set 2. N. Sakimura; J. Bradley; M. Jones; B. de Medeiros; C. Mortimore. OpenID Foundation. 15 December 2023. Final. URL:https://openid.net/specs/openid-connect-core-1_0.html
[OpenID-Connect-Discovery]
OpenID Connect Discovery 1.0 incorporating errata set 2. N. Sakimura; J. Bradley; M. Jones; E. Jay. OpenID Foundation. 15 December 2023. Final. URL:https://openid.net/specs/openid-connect-discovery-1_0.html
[RFC1738]
Uniform Resource Locators (URL). T. Berners-Lee; L. Masinter; M. McCahill. IETF. December 1994. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc1738
[RFC1866]
Hypertext Markup Language - 2.0. T. Berners-Lee; D. Connolly. IETF. November 1995. Historic. URL:https://www.rfc-editor.org/rfc/rfc1866
[RFC2046]
Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types. N. Freed; N. Borenstein. IETF. November 1996. Draft Standard. URL:https://www.rfc-editor.org/rfc/rfc2046
[RFC2119]
Key words for use in RFCs to Indicate Requirement Levels. S. Bradner. IETF. March 1997. Best Current Practice. URL:https://www.rfc-editor.org/rfc/rfc2119
[RFC2396]
Uniform Resource Identifiers (URI): Generic Syntax. T. Berners-Lee; R. Fielding; L. Masinter. IETF. August 1998. Draft Standard. URL:https://www.rfc-editor.org/rfc/rfc2396
[RFC3986]
Uniform Resource Identifier (URI): Generic Syntax. T. Berners-Lee; R. Fielding; L. Masinter. IETF. January 2005. Internet Standard. URL:https://www.rfc-editor.org/rfc/rfc3986
[RFC3987]
Internationalized Resource Identifiers (IRIs). M. Duerst; M. Suignard. IETF. January 2005. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc3987
[RFC4648]
The Base16, Base32, and Base64 Data Encodings. S. Josefsson. IETF. October 2006. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc4648
[RFC6265]
HTTP State Management Mechanism. A. Barth. IETF. April 2011. Proposed Standard. URL:https://httpwg.org/specs/rfc6265.html
[RFC6570]
URI Template. J. Gregorio; R. Fielding; M. Hadley; M. Nottingham; D. Orchard. IETF. March 2012. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc6570
[RFC6749]
The OAuth 2.0 Authorization Framework. D. Hardt, Ed. IETF. October 2012. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc6749
[RFC6838]
Media Type Specifications and Registration Procedures. N. Freed; J. Klensin; T. Hansen. IETF. January 2013. Best Current Practice. URL:https://www.rfc-editor.org/rfc/rfc6838
[RFC6901]
JavaScript Object Notation (JSON) Pointer. P. Bryan, Ed.; K. Zyp; M. Nottingham, Ed. IETF. April 2013. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc6901
[RFC7159]
The JavaScript Object Notation (JSON) Data Interchange Format. T. Bray, Ed. IETF. March 2014. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc7159
[RFC7230]
Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing. R. Fielding, Ed.; J. Reschke, Ed. IETF. June 2014. Proposed Standard. URL:https://httpwg.org/specs/rfc7230.html
[RFC7231]
Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content. R. Fielding, Ed.; J. Reschke, Ed. IETF. June 2014. Proposed Standard. URL:https://httpwg.org/specs/rfc7231.html
[RFC7235]
Hypertext Transfer Protocol (HTTP/1.1): Authentication. R. Fielding, Ed.; J. Reschke, Ed. IETF. June 2014. Proposed Standard. URL:https://httpwg.org/specs/rfc7235.html
[RFC7578]
Returning Values from Forms: multipart/form-data. L. Masinter. IETF. July 2015. Proposed Standard. URL:https://www.rfc-editor.org/rfc/rfc7578
[RFC8174]
Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words. B. Leiba. IETF. May 2017. Best Current Practice. URL:https://www.rfc-editor.org/rfc/rfc8174
[SPDX-Licenses]
SPDX License List. Linux Foundation. URL:https://spdx.org/licenses/
[URL]
URL Standard. Anne van Kesteren. WHATWG. Living Standard. URL:https://url.spec.whatwg.org/
[xml-names11]
Namespaces in XML 1.1 (Second Edition). Tim Bray; Dave Hollander; Andrew Layman; Richard Tobin et al. W3C. 16 August 2006. W3C Recommendation. URL:https://www.w3.org/TR/xml-names11/
[YAML]
YAML Ain’t Markup Language (YAML™) Version 1.2. Oren Ben-Kiki; Clark Evans; Ingy döt Net. 1 October 2009. URL:http://yaml.org/spec/1.2/spec.html

G.2Informative references

[OpenAPI-Learn]
OpenAPI - Getting started, and the specification explained. OpenAPI Initiative. URL:https://learn.openapis.org/


[8]ページ先頭

©2009-2026 Movatter.jp