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
Copy file name to clipboardExpand all lines: src/oas.md
+28-29Lines changed: 28 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1165,7 +1165,10 @@ For simpler scenarios, a [`schema`](#parameter-schema) and [`style`](#parameter-
1165
1165
When `example` or `examples` are provided in conjunction with the `schema` field, the example SHOULD match the specified schema and follow the prescribed serialization strategy for the parameter.
1166
1166
The `example` and `examples` fields are mutually exclusive, and if either is present it SHALL _override_ any `example` in the schema.
1167
1167
1168
-
Serializing with `schema` is NOT RECOMMENDED for `in: "cookie"` parameters, `in: "header"` parameters that use HTTP header parameters (name=value pairs following a `;`) in their values, or `in: "header"` parameters where values might have non-URL-safe characters; see [Appendix D](#appendix-d-serializing-headers-and-cookies) for details.
1168
+
When serializing `in: "header"` parameters with `schema`, URI percent-encoding MUST NOT be applied; if using an RFC6570 implementation that automatically applies it, it MUST be removed before use.
1169
+
Implementations MUST pass header values through unchanged rather than attempting to automatically quote header values, as the quoting rules vary too widely among different headers; see [Appendix D](#appendix-d-serializing-headers-and-cookies) for guidance on quoting and escaping.
1170
+
1171
+
Serializing with `schema` is NOT RECOMMENDED for `in: "cookie"` parameters; see [Appendix D](#appendix-d-serializing-headers-and-cookies) for details.
1169
1172
1170
1173
| Field Name | Type | Description |
1171
1174
| ---- | :----: | ---- |
@@ -1181,7 +1184,7 @@ See also [Appendix C: Using RFC6570-Based Serialization](#appendix-c-using-rfc65
1181
1184
###### Fixed Fields for use with `content`
1182
1185
1183
1186
For more complex scenarios, the [`content`](#parameter-content) field can define the media type and schema of the parameter, as well as give examples of its use.
1184
-
Using `content` with a `text/plain` media type is RECOMMENDED for `in: "header"` and `in: "cookie"` parameters where the `schema` strategy is not appropriate.
1187
+
Using `content` with a `text/plain` media type is RECOMMENDED for `in: "cookie"` parameters where the `schema` strategy's percent-encoding and/or delimiter rules are not appropriate.
1185
1188
1186
1189
| Field Name | Type | Description |
1187
1190
| ---- | :----: | ---- |
@@ -2589,7 +2592,8 @@ This object MAY be extended with [Specification Extensions](#specification-exten
2589
2592
For simpler scenarios, a [`schema`](#header-schema) and [`style`](#header-style) can describe the structure and syntax of the header.
2590
2593
When `example` or `examples` are provided in conjunction with the `schema` field, the example MUST follow the prescribed serialization strategy for the header.
2591
2594
2592
-
Serializing with `schema` is NOT RECOMMENDED for headers with parameters (name=value pairs following a `;`) in their values, or where values might have non-URL-safe characters; see [Appendix D](#appendix-d-serializing-headers-and-cookies) for details.
2595
+
When serializing headers with `schema`, URI percent-encoding MUST NOT be applied; if using an RFC6570 implementation that automatically applies it, it MUST be removed before use.
2596
+
Implementations MUST pass header values through unchanged rather than attempting to automatically quote header values, as the quoting rules vary too widely among different headers; see [Appendix D](#appendix-d-serializing-headers-and-cookies) for guidance on quoting and escaping.
2593
2597
2594
2598
When `example` or `examples` are provided in conjunction with the `schema` field, the example SHOULD match the specified schema and follow the prescribed serialization strategy for the header.
2595
2599
The `example` and `examples` fields are mutually exclusive, and if either is present it SHALL _override_ any `example` in the schema.
@@ -2607,7 +2611,6 @@ See also [Appendix C: Using RFC6570-Based Serialization](#appendix-c-using-rfc65
2607
2611
###### Fixed Fields for use with `content`
2608
2612
2609
2613
For more complex scenarios, the [`content`](#header-content) field can define the media type and schema of the header, as well as give examples of its use.
2610
-
Using `content` with a `text/plain` media type is RECOMMENDED for headers where the `schema` strategy is not appropriate.
2611
2614
2612
2615
| Field Name | Type | Description |
2613
2616
| ---- | :----: | ---- |
@@ -2638,25 +2641,19 @@ Requiring that a strong `ETag` header (with a value starting with `"` rather tha
2638
2641
```json
2639
2642
"ETag": {
2640
2643
"required": true,
2641
-
"content": {
2642
-
"text/plain": {
2643
-
"schema": {
2644
-
"type": "string",
2645
-
"pattern": "^\""
2646
-
}
2647
-
}
2644
+
"schema": {
2645
+
"type": "string",
2646
+
"pattern": "^\""
2648
2647
}
2649
2648
}
2650
2649
```
2651
2650
2652
2651
```yaml
2653
2652
ETag:
2654
2653
required: true
2655
-
content:
2656
-
text/plain:
2657
-
schema:
2658
-
type: string
2659
-
pattern: ^"
2654
+
schema:
2655
+
type: string
2656
+
pattern: ^"
2660
2657
```
2661
2658
2662
2659
#### Tag Object
@@ -4548,25 +4545,27 @@ This will expand to the result:
4548
4545
4549
4546
## Appendix D: Serializing Headers and Cookies
4550
4547
4551
-
[RFC6570](https://www.rfc-editor.org/rfc/rfc6570)'s percent-encoding behavior is not always appropriate for `in: "header"` and `in: "cookie"` parameters.
4548
+
HTTP headers have inconsistent rules regarding what characters are allowed, and how some or all disallowed characters can be escaped and included.
4549
+
While the `quoted-string` ABNF rule given in [[RFC7230]][Section 3.2.6](https://httpwg.org/specs/rfc7230.html#field.components) is the most common escaping solution, it is not sufficiently universal to apply automatically.
4550
+
For example, a strong `ETag` looks like `"foo"` (with quotes, regardless of the contents), and a weak `ETag` looks like `W/"foo"` (note that only part of the value is quoted); the contents of the quotes for this header are also not escaped in the way `quoted-string` contents are.
4551
+
4552
+
For this reason, any data being passed to a header by way of a [Parameter](#parameter-object) or [Header](#header-object) 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.
4553
+
4554
+
### Percent-Encoding and Cookies
4555
+
4556
+
_**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.
4557
+
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._
4558
+
4559
+
[RFC6570](https://www.rfc-editor.org/rfc/rfc6570)'s percent-encoding behavior is not always appropriate for `in: "cookie"` parameters.
4552
4560
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.
4553
4561
4554
-
For both [RFC6265](https://www.rfc-editor.org/rfc/rfc6265)cookies and HTTP headers using the [RFC8941](https://www.rfc-editor.org/rfc/rfc8941) structured fields syntax, non-ASCII content is handled using base64 encoding (`contentEncoding: "base64"`).
4562
+
[RFC6265](https://www.rfc-editor.org/rfc/rfc6265)recommends (but does not strictly required) base64 encoding (`contentEncoding: "base64"`) if "arbitrary data" will be stored in a cookie.
4555
4563
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.
4556
4564
While `contentEncoding` also supports the `base64url` encoding, which is URL-safe, the header and cookie RFCs do not mention this encoding.
4557
4565
4558
-
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.
4559
-
While [RFC8187](https://www.rfc-editor.org/rfc/rfc8187) recommends percent-encoding HTTP (header or trailer) field parameters, these parameters appear after a `;` character.
4560
-
With `style: "simple"`, that delimiter would itself be percent-encoded, violating the general HTTP field syntax.
4561
-
4562
-
Using `style: "form"` with `in: "cookie"` is ambiguous for a single value, and incorrect for multiple values.
4563
-
This is true whether the multiple values are the result of using `explode: true` or not.
4564
-
4565
-
This style is specified to be equivalent to RFC6570 form expansion which includes the `?` character (see [Appendix C](#appendix-c-using-rfc6570-based-serialization) for more details), which is not part of the cookie syntax.
4566
-
However, examples of this style in past versions of this specification have not included the `?` prefix, suggesting that the comparison is not exact.
4567
-
Because implementations that rely on an RFC6570 implementation and those that perform custom serialization based on the style example will produce different results, it is implementation-defined as to which of the two results is correct.
4566
+
Using `style: "form"` with `in: "cookie"` via an RFC6570 implementation requires stripping the `?` prefix, as when producing `application/x-www-form-urlencoded` message bodies.
4568
4567
4569
-
For multiple values, `style: "form"` is always incorrectas name=value pairs in cookies are delimited by `;` (a semicolon followed by a space character) rather than `&`.
4568
+
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 `&`.
4570
4569
4571
4570
## Appendix E: Percent-Encoding and Form Media Types
0 commit comments