Skip to content

Commit 3030ae3

Browse files
committed
Latest changes to v3.1.1
1 parent 77fad2b commit 3030ae3

File tree

1 file changed

+43
-24
lines changed

1 file changed

+43
-24
lines changed

versions/3.2.0.md

Lines changed: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ A "schema" is a formal description of syntax and structure.
2828
This document serves as the [schema](#schema) for the OpenAPI Specification format; a non-authoritative JSON Schema based on this document is also provided on [spec.openapis.org](https://spec.openapis.org) for informational purposes.
2929
This specification also _uses_ schemas in the form of the [Schema Object](#schema-object).
3030

31+
### Object
32+
33+
When capitalized, the word "Object" refers to any of the Objects that are named by section headings in this document.
34+
3135
### Path Templating
3236

3337
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.
@@ -135,8 +139,8 @@ Implementations MAY support complete-document parsing in any of the following wa
135139
* Detecting OpenAPI or JSON Schema documents using media types
136140
* Detecting OpenAPI documents through the root `openapi` field
137141
* Detecting JSON Schema documents through detecting keywords or otherwise successfully parsing the document in accordance with the JSON Schema specification
138-
* Detecting a document containing a referenceable object at its root based on the expected type of the reference
139-
* Allowing users to configure the type of documents that might be loaded due to a reference to a non-root object
142+
* Detecting a document containing a referenceable Object at its root based on the expected type of the reference
143+
* Allowing users to configure the type of documents that might be loaded due to a reference to a non-root Object
140144

141145
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.
142146
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.
@@ -199,27 +203,36 @@ Note that no aspect of implicit connection resolution changes how [URIs are reso
199203

200204
### Data Types
201205

202-
Data types in the OAS are based on the types supported by the [JSON Schema Specification Draft 2020-12](https://tools.ietf.org/html/draft-bhutton-json-schema-00#section-4.2.1).
203-
Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part.
204-
Models are defined using the [Schema Object](#schema-object), which is a superset of JSON Schema Specification Draft 2020-12.
206+
Data types in the OAS are based on the types defined by the [JSON Schema Validation Specification Draft 2020-12](https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-6.1.1):
207+
"null", "boolean", "object", "array", "number", "string", or "integer".
208+
Models are defined using the [Schema Object](#schema-object), which is a superset of the JSON Schema Specification Draft 2020-12.
209+
210+
JSON Schema keywords and `format` 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, the `pattern` keyword and the `date-time` format only apply to strings, and treat any instance of the other five types as _automatically valid._ This means JSON Schema keywords and formats do **NOT** implicitly require the expected type. Use the `type` keyword to explicitly constrain the type.
211+
212+
Note that the `type` 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 because [[RFC7159|JSON]] itself does not make that distinction. Since there is no distinct JSON integer type, JSON Schema defines integers mathematically. This means that both `1` and `1.0` are [equivalent](https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-00#section-4.2.2), and are both considered to be integers.
213+
214+
#### Data Type Format
205215

206-
<a name="data-type-format"></a>As defined by the [JSON Schema Validation specification](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00#section-7.3), 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 validate `format` varies across implementations.
216+
As defined by the [JSON Schema Validation specification](https://tools.ietf.org/html/draft-bhutton-json-schema-validation-00#section-7.3), 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 validate `format` varies across implementations.
207217

208218
The OpenAPI Initiative also hosts a [Format Registry](https://spec.openapis.org/registry/format/) for formats defined by OAS users and other specifications. Support for any registered format is strictly OPTIONAL, and support for one registered format does not imply support for any others.
209219

210220
Types that are not accompanied by a `format` keyword follow the type definition in the JSON Schema. Tools that do not recognize a specific `format` MAY default back to the `type` alone, as if the `format` is not specified.
221+
For the purpose of [JSON Schema validation](https://datatracker.ietf.org/doc/html/draft-bhutton-json-schema-validation-00#section-7.1), 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.
211222

212223
The formats defined by the OAS are:
213224

214-
| [`type`](#data-types) | [`format`](#data-type-format) | Comments |
225+
| `format` | JSON Data Type | Comments |
215226
| ---- | ---- | ---- |
216-
| `integer` | `int32` | signed 32 bits |
217-
| `integer` | `int64` | signed 64 bits (a.k.a long) |
218-
| `number` | `float` | |
219-
| `number` | `double` | |
220-
| `string` | `password` | A hint to obscure the value. |
227+
| `int32` | number | signed 32 bits |
228+
| `int64` | number | signed 64 bits (a.k.a long) |
229+
| `float` | number | |
230+
| `double` | number | |
231+
| `password` | string | A hint to obscure the value. |
221232

222-
#### Working With Binary Data
233+
As noted under [Data Type](#data-types), both `type: number` and `type: integer` are considered to be numbers in the data model.
234+
235+
#### Working with Binary Data
223236

224237
The OAS can describe either _raw_ or _encoded_ binary data.
225238

@@ -253,8 +266,8 @@ The following table shows how to migrate from OAS 3.0 binary data descriptions,
253266

254267
| OAS < 3.1 | OAS 3.1+ | Comments |
255268
| ---- | ---- | ---- |
256-
| `type: string`<br />`format: binary` | `contentMediaType: image/png` | if redundant, can be omitted, often resulting in an empty [Schema Object](#schema-object) |
257-
| `type: string`<br />`format: byte` | `type: string`<br />`contentMediaType: image/png`<br />`contentEncoding: base64` | note that `base64url` can be used to avoid re-encoding the base64 string to be URL-safe |
269+
| <code style="white-space:nowrap">type: string</code><br /><code style="white-space:nowrap">format: binary</code> | <code style="white-space:nowrap">contentMediaType: image/png</code> | if redundant, can be omitted, often resulting in an empty [Schema Object](#schema-object) |
270+
| <code style="white-space:nowrap">type: string</code><br /><code style="white-space:nowrap">format: byte</code> | <code style="white-space:nowrap">type: string</code><br /><code style="white-space:nowrap">contentMediaType: image/png</code><br /><code style="white-space:nowrap">contentEncoding: base64</code> | note that `base64url` can be used to avoid re-encoding the base64 string to be URL-safe |
258271

259272
### Rich Text Formatting
260273

@@ -312,9 +325,9 @@ This is the root object of the [OpenAPI document](#openapi-description).
312325
| <a name="oas-json-schema-dialect"></a> jsonSchemaDialect | `string` | The default value for the `$schema` keyword within [Schema Objects](#schema-object) contained within this OAS document. This MUST be in the form of a URI. |
313326
| <a name="oas-servers"></a>servers | [[Server Object](#server-object)] | An array of Server Objects, which provide connectivity information to a target server. If the `servers` field is not provided, or is an empty array, the default value would be a [Server Object](#server-object) with a [url](#server-url) value of `/`. |
314327
| <a name="oas-paths"></a>paths | [Paths Object](#paths-object) | The available paths and operations for the API. |
315-
| <a name="oas-webhooks"></a>webhooks | Map[`string`, [Path Item Object](#path-item-object) \| [Reference Object](#reference-object)] ] | The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. Closely related to the `callbacks` feature, this section describes requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses. An [example](../examples/v3.1/webhook-example.yaml) is available. |
328+
| <a name="oas-webhooks"></a>webhooks | Map[`string`, [Path Item Object](#path-item-object) \| [Reference Object](#reference-object)] ] | The incoming webhooks that MAY be received as part of this API and that the API consumer MAY choose to implement. Closely related to the `callbacks` feature, this section describes requests initiated other than by an API call, for example by an out of band registration. The key name is a unique string to refer to each webhook, while the (optionally referenced) Path Item Object describes a request that may be initiated by the API provider and the expected responses. An [example](https://learn.openapis.org/examples/v3.1/webhook-example.html) is available. |
316329
| <a name="oas-components"></a>components | [Components Object](#components-object) | An element to hold various schemas for the document. |
317-
| <a name="oas-security"></a>security | [[Security Requirement Object](#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. To make security optional, an empty security requirement (`{}`) can be included in the array. |
330+
| <a name="oas-security"></a>security | [[Security Requirement Object](#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. |
318331
| <a name="oas-tags"></a>tags | [[Tag Object](#tag-object)] | A list of tags used by the document with additional metadata. The order of the tags can be used to reflect on their order by the parsing tools. Not all tags that are used by the [Operation Object](#operation-object) must be declared. The tags that are not declared MAY be organized randomly or based on the tools' logic. Each tag name in the list MUST be unique. |
319332
| <a name="oas-external-docs"></a>externalDocs | [External Documentation Object](#external-documentation-object) | Additional external documentation. |
320333

@@ -1556,9 +1569,9 @@ application/json:
15561569

15571570
##### Considerations for File Uploads
15581571

1559-
In contrast to OpenAPI 2.0, `file` input/output content in OpenAPI 3 is described with the same semantics as any other schema type.
1572+
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.
15601573

1561-
In contrast to OpenAPI 2.0, the `format` keyword has no effect on the content-encoding of the schema. Instead, JSON Schema's `contentEncoding` and `contentMediaType` keywords are used. See [Working With Binary Data](#working-with-binary-data) for how to model various scenarios with these keywords, and how to migrate from the previous `format` usage.
1574+
In contrast to OAS 3.0, the `format` keyword has no effect on the content-encoding of the schema in OAS 3.1. Instead, JSON Schema's `contentEncoding` and `contentMediaType` keywords are used. See [Working With Binary Data](#working-with-binary-data) for how to model various scenarios with these keywords, and how to migrate from the previous `format` usage.
15621575

15631576
Examples:
15641577

@@ -1576,6 +1589,12 @@ content:
15761589
application/octet-stream: {}
15771590
```
15781591

1592+
```yaml
1593+
# arbitrary JSON without constraints beyond being syntactically valid:
1594+
content:
1595+
application/json: {}
1596+
```
1597+
15791598
These examples apply to either input payloads of file uploads or response payloads.
15801599

15811600
A `requestBody` for submitting a file in a `POST` operation may look like the following example:
@@ -2082,7 +2101,7 @@ To describe incoming requests from the API provider independent from another API
20822101

20832102
| Field Pattern | Type | Description |
20842103
| ---- | :----: | ---- |
2085-
| <a name="callback-expression"></a>{expression} | [Path Item Object](#path-item-object) \| [Reference Object](#reference-object) | A Path Item Object, or a reference to one, used to define a callback request and expected responses. A [complete example](../examples/v3.0/callback-example.yaml) is available. |
2104+
| <a name="callback-expression"></a>{expression} | [Path Item Object](#path-item-object) \| [Reference Object](#reference-object) | A Path Item Object, or a reference to one, used to define a callback request and expected responses. A [complete example](https://learn.openapis.org/examples/v3.0/callback-example.html) is available. |
20862105

20872106
This object MAY be extended with [Specification Extensions](#specification-extensions).
20882107

@@ -2188,7 +2207,7 @@ This object MAY be extended with [Specification Extensions](#specification-exten
21882207
In all cases, the example value SHOULD be compatible with the schema of its associated value.
21892208
Tooling implementations MAY choose to validate compatibility automatically, and reject the example value(s) if incompatible.
21902209

2191-
#### Working With Examples
2210+
##### Working with Examples
21922211

21932212
Example Objects can be used in both [Parameter Objects](#parameter-object) and [Media Type Objects](#media-type-object).
21942213
In both Objects, this is done through the `examples` (plural) field.
@@ -2686,7 +2705,7 @@ $ref: '#/components/schemas/Pet'
26862705
$ref: Pet.yaml
26872706
```
26882707

2689-
##### Relative Documents With Embedded Schema Example
2708+
##### Relative Documents with Embedded Schema Example
26902709

26912710
```json
26922711
{
@@ -3730,7 +3749,7 @@ Please note that as of 2020, the implicit flow is about to be deprecated by [OAu
37303749
| <a name="security-scheme-type"></a>type | `string` | Any | **REQUIRED**. The type of the security scheme. Valid values are `"apiKey"`, `"http"`, `"mutualTLS"`, `"oauth2"`, `"openIdConnect"`. |
37313750
| <a name="security-scheme-description"></a>description | `string` | Any | A description for security scheme. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. |
37323751
| <a name="security-scheme-name"></a>name | `string` | `apiKey` | **REQUIRED**. The name of the header, query or cookie parameter to be used. |
3733-
| <a name="security-scheme-in"></a>in | `string` | `apiKey` | **REQUIRED**. The ___location of the API key. Valid values are `"query"`, `"header"` or `"cookie"`. |
3752+
| <a name="security-scheme-in"></a>in | `string` | `apiKey` | **REQUIRED**. The ___location of the API key. Valid values are `"query"`, `"header"`, or `"cookie"`. |
37343753
| <a name="security-scheme-scheme"></a>scheme | `string` | `http` | **REQUIRED**. The name of the HTTP Authentication scheme to be used in the [Authorization header as defined in RFC7235](https://tools.ietf.org/html/rfc7235#section-5.1). The values used SHOULD be registered in the [IANA Authentication Scheme registry](https://www.iana.org/assignments/http-authschemes/http-authschemes.xhtml). The value is case-insensitive, as defined in [RFC7235](https://datatracker.ietf.org/doc/html/rfc7235#section-2.1). |
37353754
| <a name="security-scheme-bearer-format"></a>bearerFormat | `string` | `http` (`"bearer"`) | A hint to the client to identify how the bearer token is formatted. Bearer tokens are usually generated by an authorization server, so this information is primarily for documentation purposes. |
37363755
| <a name="security-scheme-flows"></a>flows | [OAuth Flows Object](#oauth-flows-object) | `oauth2` | **REQUIRED**. An object containing configuration information for the flow types supported. |
@@ -4302,7 +4321,7 @@ when expanded with the data given earlier, we get:
43024321
?a=x%2By&b=x%2Fy&c=x%5Ey&words=math,is,fun
43034322
```
43044323

4305-
#### Expansion With Non-RFC6570-Supported Options
4324+
#### Expansion with Non-RFC6570-Supported Options
43064325

43074326
But now let's say that (for some reason), we really want that `/` in the `b` formula to show up as-is in the query string, and we want our words to be space-separated like in a written phrase.
43084327
To do that, we'll add `allowReserved: true` to `formulas`, and change to `style: "spaceDelimited"` for `words`:

0 commit comments

Comments
 (0)