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
Fix handling of parameter names, clarify table entry
* Paramter names don't need to be modeled as template variables.
* Include an example of a parameter name that needs encoding.
* Add more details to the fixed field entries for allowReserved
Copy file name to clipboardExpand all lines: versions/3.0.4.md
+53-24
Original file line number
Diff line number
Diff line change
@@ -1068,7 +1068,7 @@ Field Name | Type | Description
1068
1068
---|:---:|---
1069
1069
<a name="parameterStyle"></a>style | `string` | Describes how the parameter value will be serialized depending on the type of the parameter value. Default values (based on value of `in`): for `query` - `form`; for `path` - `simple`; for `header` - `simple`; for `cookie` - `form`.
1070
1070
<a name="parameterExplode"></a>explode | `boolean` | When this is true, parameter 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 parameters this property has no effect. When [`style`](#parameterStyle) is `form`, the default value is `true`. For all other styles, the default value is `false`.
1071
-
<a name="parameterAllowReserved"></a>allowReserved | `boolean` | When this is true, parameter values are serialized using reserved expansion, as defined by [RFC6570](https://datatracker.ietf.org/doc/html/rfc6570#autoid-20), which allows [RFC3986's reserved character set](https://datatracker.ietf.org/doc/html/rfc3986#autoid-13), 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 are not allowed in the query string, or have a meaning other than their literal value (e.g. `+` as an escape for the space character in `application/x-www-form-urlencoded` query strings). This property only applies to parameters with an `in` value of `query`. The default value is `false`.
1071
+
<a name="parameterAllowReserved"></a>allowReserved | `boolean` | When this is true, parameter values are serialized using reserved expansion, as defined by [RFC6570](https://datatracker.ietf.org/doc/html/rfc6570#autoid-20), which allows [RFC3986's reserved character set](https://datatracker.ietf.org/doc/html/rfc3986#autoid-13), 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 are [not allowed in the query string](https://datatracker.ietf.org/doc/html/rfc3986#autoid-24) (`[`, `]`, `#`), or have a special meaning in `application/x-www-form-urlencoded` (`-`, `&`, `+`); see Appendices [C](#usingRFC6570Implementations) and [E](#percentEncodingAndFormMediaTypes) for details. This property only applies to parameters with an `in` value of `query`. The default value is `false`.
1072
1072
<a name="parameterSchema"></a>schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the parameter.
1073
1073
<a name="parameterExample"></a>example | Any | Example of the parameter's potential value. The example SHOULD match the specified schema and encoding properties if present. The `example` field is mutually exclusive of the `examples` field. Furthermore, if referencing a `schema` that contains an example, the `example` value SHALL _override_ the example provided by the schema. To represent examples of media types that cannot naturally be represented in JSON or YAML, a string value can contain the example with escaping where necessary.
1074
1074
<a name="parameterExamples"></a>examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the parameter's potential value. Each example SHOULD contain a value in the correct format as specified in the parameter encoding. The `examples` field is mutually exclusive of the `example` field. Furthermore, if referencing a `schema` that contains an example, the `examples` value SHALL _override_ the example provided by the schema.
@@ -1620,7 +1620,7 @@ Field Name | Type | Description
1620
1620
<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`.
1621
1621
<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`.
1622
1622
<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`.
1623
-
<a name="encodingAllowReserved"></a>allowReserved | `boolean` | When this is true, parameter values are serialized using reserved expansion, as defined by [RFC6570](https://datatracker.ietf.org/doc/html/rfc6570#autoid-20), which allows [RFC3986's reserved character set](https://datatracker.ietf.org/doc/html/rfc3986#autoid-13), 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 are not allowed in the query string, or have a meaning other than their literal value (e.g. `+` as an escape for the space character in `application/x-www-form-urlencoded` query strings). The default value is `false`. This property SHALL be ignored if the request body media type is not `application/x-www-form-urlencoded`.
1623
+
<a name="encodingAllowReserved"></a>allowReserved | `boolean` | When this is true, parameter values are serialized using reserved expansion, as defined by [RFC6570](https://datatracker.ietf.org/doc/html/rfc6570#autoid-20), which allows [RFC3986's reserved character set](https://datatracker.ietf.org/doc/html/rfc3986#autoid-13), 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 are [not allowed in the query string](https://datatracker.ietf.org/doc/html/rfc3986#autoid-24) (`[`, `]`, `#`), or have a special meaning in `application/x-www-form-urlencoded` (`-`, `&`, `+`); see Appendices [C](#usingRFC6570Implementations) and [E](#percentEncodingAndFormMediaTypes) for details. This property only applies to parameters with an `in` value of `query`. The default value is `false`.
1624
1624
1625
1625
This object MAY be extended with [Specification Extensions](#specificationExtensions).
1626
1626
@@ -3541,6 +3541,9 @@ Implementations of this specification MAY use an implementation of RFC6570 to pe
3541
3541
3542
3542
Note that when using `style: form` RFC6570 expansion to produce an `application/x-www-form-urlencoded` HTTP message body, it is necessary to remove the `?` prefix that is produced to satisfy the URI query string syntax.
3543
3543
3544
+
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.
3545
+
Using an implementation with a lower level of support will require additional manual construction of URI Templates to work around the limitations.
3546
+
3544
3547
### Equivalences Between Fields and RFC6570 Operators
3545
3548
3546
3549
Certain field values translate to RFC6570 operators (or lack thereof):
@@ -3587,7 +3590,7 @@ This includes:
3587
3590
* any parameter name that is not a legal RFC6570 variable name (alphanumerics, `_`, and percent-encoded characters)
3588
3591
3589
3592
The Parameter Object's `name` field has a much more permissive syntax than [RFC6570 variable name syntax](https://www.rfc-editor.org/rfc/rfc6570#section-2.3).
3590
-
A parameter name that includes characters outside of the allowed RFC6570 variable character set MUST be percent-encoded before it can be used in a URI Template, and MUST set `allowReserved: true` to avoid double percent-encoding.
3593
+
A parameter name that includes characters outside of the allowed RFC6570 variable character set MUST be percent-encoded before it can be used in a URI Template.
3591
3594
3592
3595
### Examples
3593
3596
@@ -3664,39 +3667,36 @@ parameters:
3664
3667
We can't combine the `?` and `+` RFC6570 prefixes, and there's no way with RFC6570 to replace the `,` separator with a space character.
3665
3668
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.
3666
3669
3667
-
Here is one such template.
3668
-
The exact variable names are unimportant, but in this example "f" and "w" are meant to suggest "formulas" and "words", while "n" and "v" suggest "name" and "value":
3670
+
Here is one such template, using a made-up convention of `words.0` for the first entry in the words value, `words.1` for the second.
We'll also need to pre-process the names and values for `formulas` because while `/` and most other reserved characters are allowed in the query string by RFC3986, `[`, `]`, and `#` [are not](https://datatracker.ietf.org/doc/html/rfc3986#appendix-A), and `&`, `=`, and `+` all have [special behavior](https://www.rfc-editor.org/rfc/rfc1866#section-8.2.1) in the `application/x-www-form-urlencoded` format, which is what we are using in the query string.
3676
+
RFC6570 [mentions](https://www.rfc-editor.org/rfc/rfc6570.html#section-2.4.2) the use of `.` "to indicate name hierarchy in substructures," but does not define any specific naming convention or behavior for it.
3677
+
Since the `.` usage is not automatic, we'll need to construct an appropriate input structure for this new template.
3678
+
3679
+
We'll also need to pre-process the values for `formulas` because while `/` and most other reserved characters are allowed in the query string by RFC3986, `[`, `]`, and `#` [are not](https://datatracker.ietf.org/doc/html/rfc3986#appendix-A), and `&`, `=`, and `+` all have [special behavior](https://www.rfc-editor.org/rfc/rfc1866#section-8.2.1) in the `application/x-www-form-urlencoded` format, which is what we are using in the query string.
3675
3680
3676
3681
Setting `allowReserved: true` does _not_ make reserved characters that are not allowed in URIs allowed, it just allows them to be _passed through expansion unchanged._
3677
3682
Therefore, any tooling still needs to percent-encode those characters because reserved expansion will not do it, but it _will_ leave the percent-encoded triples unchanged.
3678
-
See also Appendix D for further guidance on percent-encoding and form media types, including guidance on handling the delimiter characters for `spaceDelimited`, `pipeDelimited`, and `deepObject` in parameter names and values.
3683
+
See also [Appendix E](#to indicate name hierarchy in substructures) for further guidance on percent-encoding and form media types, including guidance on handling the delimiter characters for `spaceDelimited`, `pipeDelimited`, and `deepObject` in parameter names and values.
3679
3684
3680
-
So here is our data structure that arranges the names and values to suit the template above, where names and values for `formulas` have `[]#&=+` pre-percent encoded (although only `+` appears in this example):
3685
+
So here is our data structure that arranges the names and values to suit the template above, where values for `formulas` have `[]#&=+` pre-percent encoded (although only `+` appears in this example):
3681
3686
3682
3687
```YAML
3683
-
fn0: a
3684
-
fv0: x%2By
3685
-
fn1: b
3686
-
fv1: x/y
3687
-
fn2: c
3688
-
fv2: x^y
3689
-
wn: words
3690
-
wv0: math
3691
-
wv1: is
3692
-
wv2: fun
3688
+
a: x%2By
3689
+
b: x/y
3690
+
c: x^y
3691
+
words.0: math
3692
+
words.1: is
3693
+
words.2: fun
3693
3694
```
3694
3695
3695
3696
Expanding our manually assembled template with our restructured data yields the following query string:
3696
3697
3697
3698
```urlencoded
3698
3699
?a=x%2By&b=x/y&c=x%5Ey&words=math%20is%20fun
3699
-
3700
3700
```
3701
3701
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.
3702
3702
@@ -3723,19 +3723,48 @@ This means that the manually constructed URI Template and restructured data need
3723
3723
Restructured data:
3724
3724
3725
3725
```YAML
3726
-
wn: words
3727
-
wv0: hello
3728
-
wv1: world
3726
+
words.0: hello
3727
+
words.1: world
3729
3728
```
3730
3729
3731
3730
Manually constructed URI Template:
3732
3731
3733
3732
```urlencoded
3734
-
?{wn}={wv0} {wv1}
3733
+
?words={words.0} {words.1}
3735
3734
```
3736
3735
3737
3736
Result:
3738
3737
3739
3738
```urlencoded
3740
3739
?words=hello%20world
3741
3740
```
3741
+
3742
+
#### Illegal Variable Names as Parameter Names
3743
+
In this example, the heart emoji is not legal in URI Template names (or URIs):
3744
+
3745
+
```YAML
3746
+
parameters:
3747
+
- name: ❤️
3748
+
in: query
3749
+
schema:
3750
+
type: string
3751
+
```
3752
+
3753
+
We can't just pass `❤️: love!` to an RFC6570 implementation.
3754
+
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:
3755
+
3756
+
```YAML
3757
+
%E2%9D%A4%EF%B8%8F: love!
3758
+
```
3759
+
3760
+
```urlencoded
3761
+
{?%E2%9D%A4%EF%B8%8F}
3762
+
```
3763
+
3764
+
This will expand to the result:
3765
+
3766
+
```urlencoded
3767
+
?%E2%9D%A4%EF%B8%8F=love%21
3768
+
```
3769
+
3770
+
## <a name="percentEncodingAndFormMediaTypes"></a>Appendix E: Percent-Encoding and Form Media Types
0 commit comments