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
+58-34Lines changed: 58 additions & 34 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -994,7 +994,7 @@ Serializing with `schema` is NOT RECOMMENDED for `in: "cookie"` parameters, `in:
994
994
| <a name="parameter-explode"></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 field has no effect. When [`style`](#parameter-style) is `"form"`, the default value is `true`. For all other styles, the default value is `false`. Note that despite `false` being the default for `deepObject`, the combination of `false` with `deepObject` is undefined. |
995
995
| <a name="parameter-allow-reserved"></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#section-3.2.3), which allows [RFC3986's reserved character set](https://datatracker.ietf.org/doc/html/rfc3986#section-2.2), 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 by the rules of the `in` destination or media type, or are [not allowed in the path by this specification](#path-templating); see Appendices [C](#appendix-c-using-rfc6570-based-serialization) and [E](#appendix-e-percent-encoding-and-form-media-types) for details. The default value is `false`. |
996
996
| <a name="parameter-schema"></a>schema | [Schema Object](#schema-object) | The schema defining the type used for the parameter. |
997
-
| <a name="parameter-example"></a>example | Any | **Deprecated**. Example of the parameter's potential value; see [Working With Examples](#working-with-examples). |
997
+
| <a name="parameter-example"></a>example | Any | Example of the parameter's potential value; see [Working With Examples](#working-with-examples). |
998
998
| <a name="parameter-examples"></a>examples | Map[ `string`, [Example Object](#example-object) \| [Reference Object](#reference-object)] | Examples of the parameter's potential value; see [Working With Examples](#working-with-examples). |
999
999
1000
1000
See also [Appendix C: Using RFC6570-Based Serialization](#appendix-c-using-rfc6570-based-serialization) for additional guidance.
@@ -1276,7 +1276,7 @@ See [Working With Examples](#working-with-examples) for further guidance regardi
1276
1276
| ---- | :----: | ---- |
1277
1277
| <a name="media-type-schema"></a>schema | [Schema Object](#schema-object) | A schema describing the complete content of the request, response, parameter, or header. |
1278
1278
| <a name="media-type-item-schema"></a>itemSchema | [Schema Object](#schema-object) | A schema describing each item within a [sequential media type](#sequential-media-types). |
1279
-
| <a name="media-type-example"></a>example | Any | **Deprecated**. Example of the media type; see [Working With Examples](#working-with-examples). |
1279
+
| <a name="media-type-example"></a>example | Any | Example of the media type; see [Working With Examples](#working-with-examples). |
1280
1280
| <a name="media-type-examples"></a>examples | Map[ `string`, [Example Object](#example-object) \| [Reference Object](#reference-object)] | Examples of the media type; see [Working With Examples](#working-with-examples). |
1281
1281
| <a name="media-type-encoding"></a>encoding | Map[`string`, [Encoding Object](#encoding-object)] | A map between a property name and its encoding information, as defined under [Encoding Usage and Restrictions](#encoding-usage-and-restrictions). The `encoding` field SHALL only apply when the media type is `multipart` or `application/x-www-form-urlencoded`. If no Encoding Object is provided for a property, the behavior is determined by the default values documented for the Encoding Object. |
1282
1282
@@ -1920,7 +1920,10 @@ requestBody:
1920
1920
examples:
1921
1921
multipart:
1922
1922
description: |
1923
-
The input example data for the
1923
+
The input example data for the serialized value
1924
+
is taken from the Schema Object `examples` fields
1925
+
for the "id" and "addresses" field, and is a solid
1926
+
red 2x2 pixel PNG for the "profileImage" field.
1924
1927
externalSerializedValue: ./examples/multipart
1925
1928
```
1926
1929
@@ -2216,37 +2219,34 @@ As further explained under [Working With Examples](#working-with-examples), this
2216
2219
| <a name="example-external-data-value"></a>externalDataValue | `string` | A URI that identifies the data example in a separate document, allowing for values not easily expressed in JSON or YAML. This is usually only needed when working with binary data. The value MUST be valid according to the relevant Schema Object. If this field is present, then `dataValue`, `value`, and `externalValue` MUST be absent. See also the rules for resolving [Relative URI References](#relative-references-in-api-description-uris). |
2217
2220
| <a name="example-serialized-value"></a>serializedValue | `string` | An example of the serialized form of the value, including encoding and escaping as described under [Validity of Data and Serialized Examples](#validity-of-data-and-serialized-examples). If `dataValue` or `externalDataValue` are present, then this field SHOULD contain the serialization of the given data. Otherwise, it SHOULD be the valid serialization of a data value that itself MUST be valid as described for `dataValue`. This field SHOULD NOT be used if the serialization format is JSON, as the data form is easier to work with. If this field is present, `externalSerializedValue`, `value`, and `externalValue` MUST be absent. |
2218
2221
| <a name="example-eternal-serialized-value"></a>externalSerializedValue | `string` | A URI that identifies the serialized example in a separate document, allowing for values not easily or readably expressed in JSON or YAML strings. If `dataValue` or `externalDataValue` are present, then this field SHOULD identify a serialization of the given data. Otherwise, the value SHOULD be a valid serialization as described for `serializedValue`. If this field is present, `serializedValue`, `value`, and `externalValue` MUST be absent. See also the rules for resolving [Relative References](#relative-references-in-api-description-uris). |
2219
-
| <a name="example-value"></a>value | Any | **Deprecated**: It is implementation-defined whether this field is used for data or serialized forms. Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. |
2220
-
| <a name="example-external-value"></a>externalValue | `string` | **Deprecated**: It is implementation-defined whether this field is used for data or serialized forms. A URI that identifies the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. See also the rules for resolving [Relative URI References](#relative-references-in-api-description-uris). |
2222
+
| <a name="example-value"></a>value | Any | Embedded literal example. The `value` field and `externalValue` field are mutually exclusive. To represent examples of media types that cannot naturally represented in JSON or YAML, use a string value to contain the example, escaping where necessary. |
2223
+
| <a name="example-external-value"></a>externalValue | `string` | A URI that identifies the literal example. This provides the capability to reference examples that cannot easily be included in JSON or YAML documents. The `value` field and `externalValue` field are mutually exclusive. See the rules for resolving [Relative References](#relative-references-in-api-description-uris). |
2221
2224
2222
2225
This object MAY be extended with [Specification Extensions](#specification-extensions).
2223
2226
2224
2227
##### Working with Examples
2225
2228
2226
2229
Due to the history of example fields in both this specification and JSON Schema, there are a number of different ways to specify examples.
2227
2230
2228
-
Outside of [Schema Objects](#schema-object), it is RECOMMENDED to use Example Objects with the `examples` (plural) fields available in the [Parameter](#parameter-object), [Header](#header-object), [Media Type](#media-type-object), and [Encoding](#encoding-object) Objects.
2231
+
In the case of the non-Schema Object `example` (singular) fields, and of the `value` and`externalValue` fields of the Example Object, the example value SHOULD be compatible with the schema of its associated value.
2232
+
Because of variations in tooling support for `value` and `externalValue` and ambiguity regarding what can be "easily" represented in JSON or YAML, the `dataValue` `externalDataValue`, `serializedValue`, and `externalSerializedValue` fields have been introduced.
2233
+
For compatibility requirements of these new fields, see [Validity of Data and Serialized Examples](#validity-of-data-and-serialized-examples).
2234
+
2235
+
Tooling implementations MAY choose to validate compatibility automatically, and reject the example value(s) if incompatible.
2229
2236
2230
2237
###### Example Objects vs Other Fields Allowing Examples
2231
2238
2232
-
However, there are several other ways to provide examples: The deprecated `example` (singular) field that is mutually exclusive with `examples` in all Objects that support both fields, and two keywords (the deprecated singular `example` and the current plural `examples`, which takes an array of examples) in the [Schema Object](#schema-object).
2239
+
However, there are several other ways to provide examples: The `example` (singular) field that is mutually exclusive with `examples` in all Objects that support both fields, and two keywords (the deprecated singular `example` and the current plural `examples`, which takes an array of examples) in the [Schema Object](#schema-object).
2233
2240
When a schema is present alongside of the non-Schema Object `example` and `examples`, this results in four possible ways to specify an example.
2234
2241
Each of these fields has slightly different considerations.
2235
2242
2236
2243
The Schema Object's fields are used to show example values without regard to how they might be formatted as parameters or within media type representations.
2237
2244
The `examples` array is part of JSON Schema and is the preferred way to include examples in the Schema Object, while `example` is retained purely for compatibility with older versions of the OpenAPI Specification.
2238
2245
2239
2246
The fields outside of the Schema Object can be used to show how data in either or both of serialized (`serializedValue`, `externalSerializedValue`) or unserialized (`dataValue`, `externalDataValue`) forms.
2240
-
However, the `example` (singular) field is deprecated as it shares the same difficulties as the likewise deprecated `value` and `externalValue` fields of the Example Object.
2241
2247
2242
2248
Because examples using these non-Schema Object fields can show both the data and its serialization more clearly, they SHALL _override_ any `example` in the corresponding Schema Object.
2243
2249
2244
-
###### Deprecated Example Object Fields
2245
-
2246
-
Historically, the Example Object's `value` and `externalValue` field and the non-Schema Object singular `example` fields were intended to show examples of the serialized form, while allowing JSON or YAML examples to be included inline rather than as serialized strings.
2247
-
Due to some ambiguity in this guidance, these fields have been implemented in several different ways.
2248
-
To preserve existing tooling behavior, these fields have been deemed to have implementation-defined behavior, and are deprecated in favor of the new unambiguous fields that allow OAD authors to choose which form(s) to show.
2249
-
2250
2250
###### Validity of Data and Serialized Examples
2251
2251
2252
2252
The `dataValue` and `externalDataValue` fields are intended to show example data structures suitable for validation by the relevant Schema Object, against which they MUST be valid.
@@ -2559,7 +2559,7 @@ The `example` and `examples` fields are mutually exclusive, and if either is pre
2559
2559
| <aname="header-style"></a>style |`string`| Describes how the header value will be serialized. The default (and only legal value for headers) is `"simple"`. |
2560
2560
| <aname="header-explode"></a>explode |`boolean`| When this is true, header values of type `array` or `object` generate a single header whose value is a comma-separated list of the array items or key-value pairs of the map, see [Style Examples](#style-examples). For other data types this field has no effect. The default value is `false`. |
2561
2561
| <aname="header-schema"></a>schema |[Schema Object](#schema-object)\|[Reference Object](#reference-object)| The schema defining the type used for the header. |
2562
-
| <aname="header-example"></a>example | Any |**Deprecated**. Example of the header's potential value; see [Working With Examples](#working-with-examples). |
2562
+
| <aname="header-example"></a>example | Any | Example of the header's potential value; see [Working With Examples](#working-with-examples). |
2563
2563
| <aname="header-examples"></a>examples | Map[`string`, [Example Object](#example-object)\|[Reference Object](#reference-object)]| Examples of the header's potential value; see [Working With Examples](#working-with-examples). |
2564
2564
2565
2565
See also [Appendix C: Using RFC6570-Based Serialization](#appendix-c-using-rfc6570-based-serialization) for additional guidance.
@@ -3351,7 +3351,8 @@ application/xml:
3351
3351
type: string
3352
3352
examples:
3353
3353
pets:
3354
-
dataValue: "dog, cat, hamster"
3354
+
dataValue:
3355
+
animals: "dog, cat, hamster"
3355
3356
serializedValue: |
3356
3357
<document>
3357
3358
<animals>dog, cat, hamster</animals>
@@ -3373,7 +3374,8 @@ application/xml:
3373
3374
type: string
3374
3375
examples:
3375
3376
pets:
3376
-
dataValue: [dog, cat, hamster]
3377
+
dataValue:
3378
+
animals: [dog, cat, hamster]
3377
3379
externalSerializedValue: ./examples/pets.xml
3378
3380
```
3379
3381
@@ -3402,7 +3404,8 @@ application/xml:
3402
3404
name: animal
3403
3405
examples:
3404
3406
pets:
3405
-
dataValue: [dog, cat, hamster]
3407
+
dataValue:
3408
+
animals: [dog, cat, hamster]
3406
3409
externalSerializedValue: ./examples/pets.xml
3407
3410
```
3408
3411
@@ -3475,7 +3478,8 @@ application/xml:
3475
3478
name: animal
3476
3479
examples:
3477
3480
pets:
3478
-
dataValue: [dog, cat, hamster]
3481
+
dataValue:
3482
+
animals: [dog, cat, hamster]
3479
3483
externalSerializedValue: ./examples/pets.xml
3480
3484
```
3481
3485
@@ -3508,7 +3512,8 @@ application/xml:
3508
3512
name: animal
3509
3513
examples:
3510
3514
pets:
3511
-
dataValue: [dog, cat, hamster]
3515
+
dataValue:
3516
+
animals: [dog, cat, hamster]
3512
3517
externalSerializedValue: ./examples/pets.xml
3513
3518
```
3514
3519
@@ -3539,7 +3544,8 @@ application/xml:
3539
3544
type: string
3540
3545
examples:
3541
3546
pets:
3542
-
dataValue: [dog, cat, hamster]
3547
+
dataValue:
3548
+
animals: [dog, cat, hamster]
3543
3549
externalSerializedValue: ./examples/pets.xml
3544
3550
```
3545
3551
@@ -3574,7 +3580,8 @@ application/xml:
3574
3580
name: animal
3575
3581
examples:
3576
3582
pets:
3577
-
dataValue: [dog, cat, hamster]
3583
+
dataValue:
3584
+
animals: [dog, cat, hamster]
3578
3585
externalSerializedValue: ./examples/pets.xml
3579
3586
```
3580
3587
@@ -3610,7 +3617,8 @@ application/xml:
3610
3617
name: animal
3611
3618
examples:
3612
3619
pets:
3613
-
dataValue: [dog, cat, hamster]
3620
+
dataValue:
3621
+
animals: [dog, cat, hamster]
3614
3622
externalSerializedValue: ./examples/pets.xml
3615
3623
```
3616
3624
@@ -3629,20 +3637,36 @@ Where `./examples/pets.xml` would be:
3629
3637
If we change the external element but not the internal ones:
0 commit comments