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
@@ -45,11 +51,65 @@ Web-style form data consists of name-value pairs, with duplicate names allowed,
45
51
46
52
{% capture remarks %}
47
53
Both form media types use the [Encoding Object](https://spec.openapis.org/oas/latest.html#encoding-object) to map object properties from schema-ready data structures to name-value pairs, with special rules for arrays causing each array value to be treated as a separate pair with the same name.
48
-
While the ordering of pairs is significant in these formats, the OAS does not (as of v3.2) provide a way to control such ordering.
49
54
50
55
As of OAS v3.2, endpoint URL query strings can be modeled as a media type using `in: querystring` in the [Parameter Object](https://spec.openapis.org/oas/latest.html#parameter-object). The query string can also be modeled using multiple `in: query` Parameter Objects through mechanisms similar to the Encoding Object.
51
56
52
57
Note that URL-encoded forms have been defined by different standards organizations at different times, leading to inconsistencies regarding percent-encoding in later standards and implementations; this is addressed in detail in [Appendix E](https://spec.openapis.org/oas/latest.html#appendix-e-percent-encoding-and-form-media-types).
58
+
59
+
Since v3.3, the OAS provides for a way to preserve ordering, by treating the deserialized content as an array, rather than an object.
60
+
{% endcapture %}
61
+
62
+
{% capture examples %}
63
+
64
+
Treating the data as an object, this data:
65
+
66
+
```json
67
+
{
68
+
"alpha": 1,
69
+
"beta": 2,
70
+
"gamma": [ 3, 4 ]
71
+
}
72
+
```
73
+
74
+
... serializes as `application/x-www-form-urlencoded` to: `alpha=1&beta=2&gamma=3&gamma=4`
75
+
76
+
and serializes as `multipart/form-data; boundary="4aKOX"` to:
77
+
78
+
```
79
+
--4aKOX
80
+
Content-Disposition: form-data; name="alpha"
81
+
82
+
1
83
+
--4aKOX
84
+
Content-Disposition: form-data; name="beta"
85
+
86
+
2
87
+
--4aKOX
88
+
Content-Disposition: form-data; name="gamma"
89
+
90
+
3
91
+
--4aKOX
92
+
Content-Disposition: form-data; name="gamma"
93
+
94
+
4
95
+
--4aKOX--
96
+
```
97
+
98
+
If preservation of value/part order is important, treat the data as an array, where each array item
99
+
is an object consisting of the key/value pair:
100
+
101
+
```json
102
+
[
103
+
{ "alpha": 1 },
104
+
{ "beta": 2 },
105
+
{ "gamma": 3 }
106
+
{ "gamma": 4 }
107
+
}
108
+
```
109
+
110
+
This distinction can be made clear to a deserializer by using `type: array` in the
111
+
schema, using the process as described in [Non-JSON Data](https://spec.openapis.org/oas/latest#non-json-data).
112
+
53
113
{% endcapture %}
54
114
55
-
{% include media-type-entry.md summary=summary remarks=remarks %}
115
+
{% include media-type-entry.md summary=summary remarks=remarks examples=examples %}
0 commit comments