From 3030962b1dc436f447a3c493a4318d8b0151b291 Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Thu, 30 May 2024 13:18:13 -0700 Subject: [PATCH 1/6] Verbose Header Object documentation (3.0.4) This copies the relevant Parameter Object fields to the Header Object instead of relying on implicit guidance. The text for the fields has been edited to reflect that only headers are being described. This also include an example of describing a header using the `content` field, and explaining why it is necessary to do so. --- versions/3.0.4.md | 77 +++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 71 insertions(+), 6 deletions(-) diff --git a/versions/3.0.4.md b/versions/3.0.4.md index 12b2375a79..75d1eecad2 100644 --- a/versions/3.0.4.md +++ b/versions/3.0.4.md @@ -2232,18 +2232,56 @@ Expressions can be embedded into string values by surrounding the expression wit #### Header Object -The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes: +The Header Object is used to describe headers for [HTTP responses](#responseHeaders) and for [individual parts in `multipart` representations](#encodingHeaders); see the relevant [Header Object](#headerObject) and [Encoding Object](#encodingObject) documentation for restrictions on which headers can be described. + +The Header Object follows the structure of the [Parameter Object](#parameterObject), including determining its serialization strategy based on whether `schema` or `content` is present, with the following changes: 1. `name` MUST NOT be specified, it is given in the corresponding `headers` map. 1. `in` MUST NOT be specified, it is implicitly in `header`. -1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, [`style`](#parameterStyle)). +1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, [`style`](#parameterStyle)). This means that `allowEmptyValue` and `allowReserved` MUST NOT be used, and `style`, if used, MUST be limited to `simple`. + +###### Common Fixed Fields + +These fields MAY be used with either `content` or `schema`. + +Field Name | Type | Description +---|:---:|--- +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. +required | `boolean` | Determines whether this header is mandatory. The default value is `false`. + deprecated | `boolean` | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`. + +###### Fixed Fields for use with `schema` + +For simpler scenarios, a [`schema`](#headerSchema) and [`style`](#headerStyle) can describe the structure and syntax of the header. +When `example` or `examples` are provided in conjunction with the `schema` object, the example MUST follow the prescribed serialization strategy for the header. + +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](#serializingHeadersAndCookies) for details. + +Field Name | Type | Description +---|:---:|--- +style | `string` | Describes how the header value will be serialized. The default (and only legal value for headers) is `simple`. +explode | `boolean` | When this is true, header values of type `array` or `object` generate separate header values for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. The default value is `false`. +schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the header. +example | Any | Example of the header'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. +examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the header's potential value. Each example SHOULD contain a value in the correct format as specified in the header 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. + +See also [Appendix C: Using RFC6570 Implementations](#usingRFC6570Implementations) for additional guidance. + +###### Fixed Fields for use with `content` + +For more complex scenarios, the [`content`](#headerContent) property can define the media type and schema of the header, as well as give examples of its use. +Using `content` with a `text/plain` media type is RECOMMENDED for headers where the `schema` strategy is not appropriate. + +Field Name | Type | Description +---|:---:|--- +content | Map[`string`, [Media Type Object](#mediaTypeObject)] | A map containing the representations for the header. The key is the media type and the value describes it. The map MUST only contain one entry. ##### Header Object Example A simple header of type `integer`: ```json -{ +"X-Rate-Limit-Limit": { "description": "The number of allowed requests in the current period", "schema": { "type": "integer" @@ -2252,9 +2290,36 @@ A simple header of type `integer`: ``` ```yaml -description: The number of allowed requests in the current period -schema: - type: integer +X-Rate-Limit-Limit: + description: The number of allowed requests in the current period + schema: + type: integer +``` + +Requiring that a strong `ETag` header (with a value starting with `"` rather than `W/`) is present. Note the use of `content`, because using `schema` and `style` would require the `"` to be percent-encoded as `%22`: + +```json +"ETag": { + "required": true, + "content": { + "text/plain": { + "schema": { + "type": "string", + "pattern": "^\"" + } + } + } +} +``` + +```yaml +ETag: + required: true + content: + text/plain: + schema: + type: string + pattern: ^" ``` #### Tag Object From ee409871ed9126dfe3c4cb87bf77771fcb8aaeed Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Thu, 30 May 2024 13:32:27 -0700 Subject: [PATCH 2/6] Stub out linked appendixes... ...to placate the PR checks in GitHub. --- versions/3.0.4.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/versions/3.0.4.md b/versions/3.0.4.md index 75d1eecad2..ca95cc9e1a 100644 --- a/versions/3.0.4.md +++ b/versions/3.0.4.md @@ -3588,3 +3588,7 @@ Version | Date | Notes 1.2 | 2014-03-14 | Initial release of the formal document. 1.1 | 2012-08-22 | Release of Swagger 1.1 1.0 | 2011-08-10 | First release of the Swagger Specification + +## Appendix C: Using RFC6570 Implementations + +## Appendix D: Serializing Headers and Cookies From 7aef3b55a42d385691a4030aa603673c5801dd6b Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Tue, 4 Jun 2024 08:58:18 -0700 Subject: [PATCH 3/6] Better wording (review feedback) Co-authored-by: Ralf Handl --- versions/3.0.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/3.0.4.md b/versions/3.0.4.md index ca95cc9e1a..3e9c4ed601 100644 --- a/versions/3.0.4.md +++ b/versions/3.0.4.md @@ -2248,7 +2248,7 @@ Field Name | Type | Description ---|:---:|--- 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. required | `boolean` | Determines whether this header is mandatory. The default value is `false`. - deprecated | `boolean` | Specifies that a parameter is deprecated and SHOULD be transitioned out of usage. Default value is `false`. + deprecated | `boolean` | Specifies that the header is deprecated and SHOULD be transitioned out of usage. Default value is `false`. ###### Fixed Fields for use with `schema` From 29e765811a93a22a6a93036c0e21555b8fb5c97f Mon Sep 17 00:00:00 2001 From: "Henry H. Andrews" Date: Tue, 4 Jun 2024 13:23:08 -0700 Subject: [PATCH 4/6] Review feedback. --- versions/3.0.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/3.0.4.md b/versions/3.0.4.md index 3e9c4ed601..6cd99e8c5a 100644 --- a/versions/3.0.4.md +++ b/versions/3.0.4.md @@ -2260,7 +2260,7 @@ Serializing with `schema` is NOT RECOMMENDED for headers with parameters (name=v Field Name | Type | Description ---|:---:|--- style | `string` | Describes how the header value will be serialized. The default (and only legal value for headers) is `simple`. -explode | `boolean` | When this is true, header values of type `array` or `object` generate separate header values for each value of the array or key-value pair of the map. For other types of parameters this property has no effect. The default value is `false`. +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](https://github.com/OAI/OpenAPI-Specification/blob/v3.0.4-dev/versions/3.0.4.md#style-examples). For other data types this property has no effect. The default value is `false`. schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the header. example | Any | Example of the header'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. examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the header's potential value. Each example SHOULD contain a value in the correct format as specified in the header 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. From 2f129ecf94be28601a65dfe337f8b2499e149517 Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Thu, 6 Jun 2024 11:06:06 -0700 Subject: [PATCH 5/6] Wording consistency (review feedback) Co-authored-by: Ralf Handl --- versions/3.0.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/3.0.4.md b/versions/3.0.4.md index 6cd99e8c5a..d9011bdb5e 100644 --- a/versions/3.0.4.md +++ b/versions/3.0.4.md @@ -2232,7 +2232,7 @@ Expressions can be embedded into string values by surrounding the expression wit #### Header Object -The Header Object is used to describe headers for [HTTP responses](#responseHeaders) and for [individual parts in `multipart` representations](#encodingHeaders); see the relevant [Header Object](#headerObject) and [Encoding Object](#encodingObject) documentation for restrictions on which headers can be described. +Describes a single header for [HTTP responses](#responseHeaders) and for [individual parts in `multipart` representations](#encodingHeaders); see the relevant [Response Object](#responseObject) and [Encoding Object](#encodingObject) documentation for restrictions on which headers can be described. The Header Object follows the structure of the [Parameter Object](#parameterObject), including determining its serialization strategy based on whether `schema` or `content` is present, with the following changes: From bace4b43843bd18de040aab3d4126a474ed11d0a Mon Sep 17 00:00:00 2001 From: Henry Andrews Date: Fri, 7 Jun 2024 11:23:30 -0700 Subject: [PATCH 6/6] Review feedback Co-authored-by: Ralf Handl --- versions/3.0.4.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/3.0.4.md b/versions/3.0.4.md index d9011bdb5e..bdfe850be8 100644 --- a/versions/3.0.4.md +++ b/versions/3.0.4.md @@ -2260,7 +2260,7 @@ Serializing with `schema` is NOT RECOMMENDED for headers with parameters (name=v Field Name | Type | Description ---|:---:|--- style | `string` | Describes how the header value will be serialized. The default (and only legal value for headers) is `simple`. -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](https://github.com/OAI/OpenAPI-Specification/blob/v3.0.4-dev/versions/3.0.4.md#style-examples). For other data types this property has no effect. The default value is `false`. +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 property has no effect. The default value is `false`. schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the header. example | Any | Example of the header'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. examples | Map[ `string`, [Example Object](#exampleObject) \| [Reference Object](#referenceObject)] | Examples of the header's potential value. Each example SHOULD contain a value in the correct format as specified in the header 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.