Skip to content

Commit 545cff1

Browse files
authored
Merge pull request #4802 from handrews/content-examples-3
v3.2: Allow Parameter/Header examples w/content
2 parents 79ec626 + dfbda97 commit 545cff1

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

src/oas.md

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,8 @@ See [Appendix B](#appendix-b-data-type-conversion) for a discussion of convertin
11241124

11251125
These fields MAY be used with either `content` or `schema`.
11261126

1127+
The `example` and `examples` fields are mutually exclusive; see [Working with Examples](#working-with-examples) for guidance on validation requirements.
1128+
11271129
| Field Name | Type | Description |
11281130
| ---- | :----: | ---- |
11291131
| <a name="parameter-name"></a>name | `string` | **REQUIRED**. The name of the parameter. Parameter names are _case sensitive_. <ul><li>If [`in`](#parameter-in) is `"path"`, the `name` field MUST correspond to a single template expression occurring within the [path](#paths-path) field in the [Paths Object](#paths-object). See [Path Templating](#path-templating) for further information.<li>If [`in`](#parameter-in) is `"header"` and the `name` field is `"Accept"`, `"Content-Type"` or `"Authorization"`, the parameter definition SHALL be ignored.<li>If `in` is `"querystring"`, or for [certain combinations](#style-examples) of [`style`](#parameter-style) and [`explode`](#parameter-explode), the value of `name` is not used in the parameter serialization.<li>For all other cases, the `name` corresponds to the parameter name used by the [`in`](#parameter-in) field.</ul> |
@@ -1132,6 +1134,8 @@ These fields MAY be used with either `content` or `schema`.
11321134
| <a name="parameter-required"></a>required | `boolean` | Determines whether this parameter is mandatory. If the [parameter location](#parameter-in) is `"path"`, this field is **REQUIRED** and its value MUST be `true`. Otherwise, the field MAY be included and its default value is `false`. |
11331135
| <a name="parameter-deprecated"></a> deprecated | `boolean` | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`. |
11341136
| <a name="parameter-allow-empty-value"></a> allowEmptyValue | `boolean` | If `true`, clients MAY pass a zero-length string value in place of parameters that would otherwise be omitted entirely, which the server SHOULD interpret as the parameter being unused. Default value is `false`. If [`style`](#parameter-style) is used, and if [behavior is _n/a_ (cannot be serialized)](#style-examples), the value of `allowEmptyValue` SHALL be ignored. Interactions between this field and the parameter's [Schema Object](#schema-object) are implementation-defined. This field is valid only for `query` parameters. <br><br>**Deprecated:** Use of this field is NOT RECOMMENDED, and it is likely to be removed in a later revision. |
1137+
| <a name="parameter-example"></a>example | Any | Example of the parameter's potential value; see [Working With Examples](#working-with-examples). |
1138+
| <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). |
11351139

11361140
This object MAY be extended with [Specification Extensions](#specification-extensions).
11371141

@@ -1140,8 +1144,6 @@ Note that while `"Cookie"` as a `name` is not forbidden if `in` is `"header"`, t
11401144
###### Fixed Fields for use with `schema`
11411145

11421146
For simpler scenarios, a [`schema`](#parameter-schema) and [`style`](#parameter-style) can describe the structure and syntax of the parameter.
1143-
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.
1144-
The `example` and `examples` fields are mutually exclusive.
11451147

11461148
These fields MUST NOT be used with `in: "querystring"`.
11471149
@@ -1153,8 +1155,6 @@ Serializing with `schema` is NOT RECOMMENDED for `in: "cookie"` parameters, `in:
11531155
| <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. |
11541156
| <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`. |
11551157
| <a name="parameter-schema"></a>schema | [Schema Object](#schema-object) | The schema defining the type used for the parameter. |
1156-
| <a name="parameter-example"></a>example | Any | Example of the parameter's potential value; see [Working With Examples](#working-with-examples). |
1157-
| <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). |
11581158

11591159
See also [Appendix C: Using RFC6570-Based Serialization](#appendix-c-using-rfc6570-based-serialization) for additional guidance.
11601160

@@ -2677,34 +2677,32 @@ The Header Object follows the structure of the [Parameter Object](#parameter-obj
26772677

26782678
These fields MAY be used with either `content` or `schema`.
26792679

2680+
The `example` and `examples` fields are mutually exclusive; see [Working with Examples](#working-with-examples) for guidance on validation requirements.
2681+
26802682
| Field Name | Type | Description |
26812683
| ---- | :----: | ---- |
26822684
| <a name="header-description"></a>description | `string` | A brief description of the header. This could contain examples of use. [CommonMark syntax](https://spec.commonmark.org/) MAY be used for rich text representation. |
26832685
| <a name="header-required"></a>required | `boolean` | Determines whether this header is mandatory. The default value is `false`. |
26842686
| <a name="header-deprecated"></a> deprecated | `boolean` | Specifies that the header is deprecated and SHOULD be transitioned out of usage. Default value is `false`. |
2687+
| <a name="header-example"></a>example | Any | Example of the header's potential value; see [Working With Examples](#working-with-examples). |
2688+
| <a name="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). |
26852689

26862690
This object MAY be extended with [Specification Extensions](#specification-extensions).
26872691

26882692
###### Fixed Fields for use with `schema`
26892693

26902694
For simpler scenarios, a [`schema`](#header-schema) and [`style`](#header-style) can describe the structure and syntax of the header.
2691-
When `example` or `examples` are provided in conjunction with the `schema` field, the example MUST follow the prescribed serialization strategy for the header.
26922695

26932696
Serializing headers with `schema` can be problematic due to the URI percent-encoding that is automatically applied, which would percent-encode characters such as `;` that are used to separate primary header values from their parameters.
26942697
The `allowReserved` field can disable most but not all of this behavior.
26952698
See [Appendix D](#appendix-d-serializing-headers-and-cookies) for details and further guidance.
26962699

2697-
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.
2698-
The `example` and `examples` fields are mutually exclusive.
2699-
27002700
| Field Name | Type | Description |
27012701
| ---- | :----: | ---- |
27022702
| <a name="header-style"></a>style | `string` | Describes how the header value will be serialized. The default (and only legal value for headers) is `"simple"`. |
27032703
| <a name="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`. |
27042704
| <a name="header-allow-reserved"></a>allowReserved | `boolean` | When this is true, header 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). See [Appendix D: Serializing Headers and Cookies](#appendix-d-serializing-headers-and-cookies) for guidance on header encoding and escaping. The default value is `false`. |
27052705
| <a name="header-schema"></a>schema | [Schema Object](#schema-object) | The schema defining the type used for the header. |
2706-
| <a name="header-example"></a>example | Any | Example of the header's potential value; see [Working With Examples](#working-with-examples). |
2707-
| <a name="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). |
27082706

27092707
See also [Appendix C: Using RFC6570-Based Serialization](#appendix-c-using-rfc6570-based-serialization) for additional guidance.
27102708

src/schemas/validation/schema.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -370,6 +370,8 @@ $defs:
370370
- required:
371371
- content
372372
allOf:
373+
- $ref: '#/$defs/examples'
374+
- $ref: '#/$defs/specification-extensions'
373375
- if:
374376
properties:
375377
in:
@@ -407,7 +409,6 @@ $defs:
407409
default: false
408410
type: boolean
409411
allOf:
410-
- $ref: '#/$defs/examples'
411412
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-path'
412413
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-header'
413414
- $ref: '#/$defs/parameter/dependentSchemas/schema/$defs/styles-for-query'
@@ -478,7 +479,6 @@ $defs:
478479
default: form
479480
const: form
480481

481-
$ref: '#/$defs/specification-extensions'
482482
unevaluatedProperties: false
483483

484484
parameter-or-reference:
@@ -790,7 +790,9 @@ $defs:
790790
default: false
791791
type: boolean
792792
$ref: '#/$defs/examples'
793-
$ref: '#/$defs/specification-extensions'
793+
allOf:
794+
- $ref: '#/$defs/examples'
795+
- $ref: '#/$defs/specification-extensions'
794796
unevaluatedProperties: false
795797

796798
header-or-reference:

0 commit comments

Comments
 (0)