You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Update "format" and "content*" for new JSON Schema
This removes OAS formats and examples that are now superfluous
as they are part of the 2019-09 JSON Schema draft.
Similarly it deprecates the "byte" and "binary" formats in favor
of JSON Schema's "contentEncoding" and "contentMediaType" keywords,
and updates various related exapmles and other guidance.
It also removes confusingly blank rows in the OAS format table.
Copy file name to clipboardExpand all lines: versions/3.1.0.md
+28-21Lines changed: 28 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -147,10 +147,10 @@ Primitive data types in the OAS are based on the types supported by the [JSON Sc
147
147
Note that `integer` as a type is also supported and is defined as a JSON number without a fraction or exponent part.
148
148
Models are defined using the [Schema Object](#schemaObject), which is a superset of JSON Schema Specification Draft 2019-09.
149
149
150
-
<aname="dataTypeFormat"></a>Primitives have an optional modifier property: `format`.
151
-
OAS uses several known formats to define in fine detail the data type being used.
150
+
<aname="dataTypeFormat"></a>Primitives have an optional modifier property: `format`, which is defined by JSON Schema.
151
+
OAS uses several known additional formats to define in fine detail the data type being used.
152
152
However, to support documentation needs, the `format` property is an open `string`-valued property, and can have any value.
153
-
Formats such as `"email"`, `"uuid"`, and so on, MAY be used even though undefined by this specification.
153
+
Additional formats MAY be used even though undefined by either JSON Schema or this specification.
154
154
Types that are not accompanied by a `format` property 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.
155
155
156
156
The formats defined by the OAS are:
@@ -161,14 +161,14 @@ The formats defined by the OAS are:
161
161
`integer` | `int64` | signed 64 bits (a.k.a long)
162
162
`number` | `float` | |
163
163
`number` | `double` | |
164
-
`string` | | |
165
-
`string` | `byte` | base64 encoded characters
166
-
`string` | `binary` | any sequence of octets
167
-
`boolean` | | |
168
-
`string` | `date` | As defined by `full-date` - [RFC3339](https://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14)
169
-
`string` | `date-time` | As defined by `date-time` - [RFC3339](https://xml2rfc.ietf.org/public/rfc/html/rfc3339.html#anchor14)
170
164
`string` | `password` | A hint to UIs to obscure input.
`string` | `binary` | any sequence of octets **Deprecated**
171
167
168
+
Use of `byte` or `binary` is discouraged, and later versions of this specification may remove them from this list. They SHOULD be replaced with the JSON Schema keywords `contentEncoding` or `contentMediaType` as follows:
169
+
170
+
* replace `"format": "byte"` with `"contentEncoding": "base64"` or `"contentEncoding": "base64url"`
171
+
* replace `"format": "binary"` with `"contentMediaType": "application/octet-stream"` or an appropriate specific media type
172
172
173
173
### <aname="richText"></a>Rich Text Formatting
174
174
Throughout the specification `description` fields are noted as supporting CommonMark markdown formatting.
@@ -1453,14 +1453,14 @@ In contrast with the 2.0 specification, `file` input/output content in OpenAPI i
1453
1453
# content transferred with base64 encoding
1454
1454
schema:
1455
1455
type: string
1456
-
format: base64
1456
+
contentEncoding: base64
1457
1457
```
1458
1458
1459
1459
```yaml
1460
1460
# content transferred in binary (octet-stream):
1461
1461
schema:
1462
1462
type: string
1463
-
format: binary
1463
+
contentMediaType: application/octet-stream
1464
1464
```
1465
1465
1466
1466
These examples apply to either input payloads of file uploads or response payloads.
@@ -1474,7 +1474,7 @@ requestBody:
1474
1474
schema:
1475
1475
# a binary file of any type
1476
1476
type: string
1477
-
format: binary
1477
+
contentMediaType: application/octet-stream
1478
1478
```
1479
1479
1480
1480
In addition, specific media types MAY be specified:
@@ -1487,11 +1487,11 @@ requestBody:
1487
1487
'image/jpeg':
1488
1488
schema:
1489
1489
type: string
1490
-
format: binary
1490
+
contentMediaType: image/jpeg
1491
1491
'image/png':
1492
1492
schema:
1493
1493
type: string
1494
-
format: binary
1494
+
contentMediaType: image/png
1495
1495
```
1496
1496
1497
1497
To upload multiple files, a `multipart` media type MUST be used:
@@ -1507,7 +1507,7 @@ requestBody:
1507
1507
type: array
1508
1508
items:
1509
1509
type: string
1510
-
format: binary
1510
+
contentMediaType: application/octet-stream
1511
1511
1512
1512
```
1513
1513
@@ -1546,7 +1546,9 @@ When passing in `multipart` types, boundaries MAY be used to separate sections o
1546
1546
1547
1547
* If the property is a primitive, or an array of primitive values, the default Content-Type is `text/plain`
1548
1548
* If the property is complex, or an array of complex values, the default Content-Type is `application/json`
1549
-
* If the property is a `type: string` with `format: binary` or `format: base64` (aka a file object), the default Content-Type is `application/octet-stream`
1549
+
* If the property is a `type: string` with a `contentMediaType`, the Content-Type is the value from `contentMediaType`
1550
+
* If the property is a `type: string` with a `contentEncoding` of `base64` or `base64url`, but does _not_ have a `contentMediaType`, the default Content-Type is `application/octet-stream`
1551
+
* **Deprecated:** If the property is a `type: string` with `format: binary` or `format: base64` (aka a file object), the default Content-Type is `application/octet-stream`
1550
1552
1551
1553
1552
1554
Examples:
@@ -1566,9 +1568,9 @@ requestBody:
1566
1568
type: object
1567
1569
properties: {}
1568
1570
profileImage:
1569
-
#default Content-Type for string/binary is `application/octet-stream`
1571
+
# Content-Type for string/contentMediaType is the contentMediaType (image/png here)
1570
1572
type: string
1571
-
format: binary
1573
+
contentMediaType: image/png
1572
1574
children:
1573
1575
# default Content-Type for arrays is based on the `inner` type (text/plain here)
1574
1576
type: array
@@ -1590,7 +1592,13 @@ A single encoding definition applied to a single schema property.
1590
1592
##### Fixed Fields
1591
1593
Field Name | Type | Description
1592
1594
---|:---:|---
1593
-
<a name="encodingContentType"></a>contentType | `string` | The Content-Type for encoding a specific property. Default value depends on the property type: for `string` with `format` being `binary` – `application/octet-stream`; for other primitive types – `text/plain`; for `object` - `application/json`; for `array` – the default is defined based on the inner type. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types.
1595
+
<a name="encodingContentType"></a>contentType | `string` | The Content-Type for encoding a specific property. Default value depends on the property type:
1596
+
1597
+
* for `type` with a `contentMediaType`, the default value is the value from `contentMediaType`
1598
+
* for other primitive types – `text/plain`; for `object` - `application/json`
1599
+
* for `array` – the default is defined based on the inner type. The value can be a specific media type (e.g. `application/json`), a wildcard media type (e.g. `image/*`), or a comma-separated list of the two types
1600
+
* **Deprecated:** for `string` with `format` being `binary` – `application/octet-stream`
1601
+
1594
1602
<a name="encodingHeaders"></a>headers | Map[`string`, [Header Object](#headerObject) \| [Reference Object](#referenceObject)] | A map allowing additional information to be provided as headers, for example `Content-Disposition`. `Content-Type` is described separately and SHALL be ignored in this section. This property SHALL be ignored if the request body media type is not a `multipart`.
1595
1603
<a name="encodingStyle"></a>style | `string` | Describes how a specific property value will be serialized depending on its type. See [Parameter Object](#parameterObject) for details on the [`style`](#parameterStyle) property. The behavior follows the same values as `query` parameters, including default values. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of [`contentType`](#encodingContentType) (implicit or explicit) SHALL be ignored.
1596
1604
<a name="encodingExplode"></a>explode | `boolean` | When this is true, property values of type `array` or `object` generate separate parameters for each value of the array, or key-value-pair of the map. For other types of properties this property has no effect. When [`style`](#encodingStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded` or `multipart/form-data`. If a value is explicitly defined, then the value of [`contentType`](#encodingContentType) (implicit or explicit) SHALL be ignored.
@@ -1621,9 +1629,8 @@ requestBody:
1621
1629
type: object
1622
1630
properties: {}
1623
1631
profileImage:
1624
-
# default is application/octet-stream, need to declare an image type only!
0 commit comments