Skip to content

Commit 31d23da

Browse files
committed
Migrate 3.0 format guidance to content* (3.1.1 port add-on)
Various updates ported over from 3.0.4 mention using the `format` values `byte` or `binary`, which have been replaced by the `contentMediaType` and `contentEncoding` keywords. This change updates those ported chagnes accordingly.
1 parent 49d542d commit 31d23da

1 file changed

Lines changed: 19 additions & 14 deletions

File tree

versions/3.1.1.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1751,17 +1751,20 @@ requestBody:
17511751
type: object
17521752
properties: {}
17531753
profileImage:
1754-
# Content-Type for properties with type string and contentEncoding is `application/octet-stream`
1754+
# default Content-Type for properties with type string and a contentEncoding
1755+
# is `application/octet-stream`, so `image/png` must be set using contentMediaType
17551756
type: string
17561757
contentMediaType: image/png
17571758
contentEncoding: base64
17581759
children:
1759-
# default Content-Type for arrays is based on the _inner_ type (`text/plain` here)
1760+
# default Content-Type for arrays is based on the items subschema type, which
1761+
# is a string, producing a default of `text/plain`
17601762
type: array
17611763
items:
17621764
type: string
17631765
addresses:
1764-
# default Content-Type for arrays is based on the _inner_ type (object shown, so `application/json` in this example)
1766+
# default Content-Type for arrays is based on the items subschema type, which
1767+
# is an object, producing a default of `application/json`
17651768
type: array
17661769
items:
17671770
type: object
@@ -1791,17 +1794,18 @@ Field Name | Type | Description
17911794

17921795
This object MAY be extended with [Specification Extensions](#specificationExtensions).
17931796

1794-
The default values for `contentType` are as follows, where an _n/a_ in the `format` column means that the presence or value of `format` is irrelevant:
1797+
The default values for `contentType` are as follows, where an _n/a_ in the `contentEncoding` column means that the presence or value of `contentEncoding` is irrelevant:
17951798

1796-
Property `type` | Property `format` | Default `contentType`
1797-
------------- | --------------- | ---------------------
1798-
`string` | `binary` | `application/octet-stream`
1799-
`string` | _none, or any except `binary`_ | `text/plain`
1799+
Property `type` | Property `contentEncoding` | Default `contentType`
1800+
--------------- | -------------------------- | ---------------------
1801+
_absent_ | _n/a_ | `application/octet-stream`
1802+
`string` | _present_ | `application/octet-stream`
1803+
`string` | _absent_ | `text/plain`
18001804
`number`, `integer`, or `boolean` | _n/a_ | `text/plain`
18011805
`object` | _n/a_ | `application/json`
1802-
`array` | _n/a_ | according to the `type` and `format` of the `items` schema
1806+
`array` | _n/a_ | according to the `type` of the `items` schema
18031807

1804-
Determining how to handle `null` values if `nullable: true` is present depends on how `null` values are being serialized.
1808+
Determining how to handle a `type` value of `null` depends on how `null` values are being serialized.
18051809
If `null` values are entirely omitted, then the `contentType` is irrelevant.
18061810
See [Appendix B](#dataTypeConversion) for a discussion of data type conversion options.
18071811

@@ -1830,8 +1834,8 @@ It is not currently possible to correlate schema properties with unnamed, ordere
18301834
Note that there are significant restrictions on what headers can be used with `multipart` media types in general ([RFC2046 §5.1](https://www.rfc-editor.org/rfc/rfc2046.html#section-5.1)) and `multi-part/form-data` in particular ([RFC7578 §4.8](https://www.rfc-editor.org/rfc/rfc7578.html#section-4.8)).
18311835

18321836
Note also that `Content-Transfer-Encoding` is deprecated for `multipart/form-data` ([RFC7578 §4.7](https://www.rfc-editor.org/rfc/rfc7578.html#section-4.7)) where binary data is supported, as it is in HTTP.
1833-
Using `format: byte` for a multipart field is equivalent to setting `Content-Transfer-Encoding: base64`.
1834-
If `format: byte` is used along with setting a different `Content-Transfer-Encoding` value with the `headers` field, the result is undefined.
1837+
Using `contentEncoding` is equivalent to setting `Content-Transfer-Encoding` to the same value.
1838+
If `contentEncoding` is used along with setting a different `Content-Transfer-Encoding` value with the `headers` field, the result is undefined.
18351839

18361840
##### Encoding Object Example
18371841

@@ -4200,7 +4204,7 @@ To control the serialization of numbers, booleans, and `null` (or other values R
42004204
The resulting strings would not require any further type conversion.
42014205

42024206
The `format` keyword can assist in serialization.
4203-
Some formats (such as `date-time` or `byte`) are unambiguous, while others (such as [`decimal`](https://spec.openapis.org/registry/format/decimal.html) in the [Format Registry](https://spec.openapis.org/registry/format/)) are less clear.
4207+
Some formats (such as `date-time`) are unambiguous, while others (such as [`decimal`](https://spec.openapis.org/registry/format/decimal.html) in the [Format Registry](https://spec.openapis.org/registry/format/)) are less clear.
42044208
However, care must be taken with `format` to ensure that the specific formats are supported by all relevant tools as unrecognized formats are ignored.
42054209

42064210
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.
@@ -4453,8 +4457,9 @@ This will expand to the result:
44534457
RFC6570's percent-encoding behavior is not always appropriate for `in: header` and `in: cookie` parameters.
44544458
In many cases, it is more appropriate to use `content` with a media type such as `text/plain` and require the application to assemble the correct string.
44554459

4456-
For both cookies ([RFC6265](https://www.rfc-editor.org/rfc/rfc6265)) and HTTP headers using the structured fields ([RFC8941](https://www.rfc-editor.org/rfc/rfc8941)) syntax, non-ASCII content is handled using base64 encoding (`format: byte`).
4460+
For both cookies ([RFC6265](https://www.rfc-editor.org/rfc/rfc6265)) and HTTP headers using the structured fields ([RFC8941](https://www.rfc-editor.org/rfc/rfc8941)) syntax, non-ASCII content is handled using base64 encoding (`contentEncoding: base64`).
44574461
Note that the standard base64 encoding alphabet includes non-URL-safe characters that are percent-encoded by RFC6570 expansion; serializing values through both encodings is NOT RECOMMENDED.
4462+
While `contentEncoding` also supports the `base64url` encoding, which is URL-safe, the header and cookie RFCs do not mention this encoding.
44584463

44594464
Most HTTP headers predate the structured field syntax, and a comprehensive assessment of their syntax and encoding rules is well beyond the scope of this specification.
44604465
While [RFC8187](https://www.rfc-editor.org/rfc/rfc8187) recommends percent-encoding HTTP field (header or trailer) parameters, these parameters appear after a `;` character.

0 commit comments

Comments
 (0)