Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 9.2k
Verbose Header Object documentation (3.0.4)#3867
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
3030962
Verbose Header Object documentation (3.0.4)
handrews ee40987
Stub out linked appendixes...
handrews 7aef3b5
Better wording (review feedback)
handrews 29e7658
Review feedback.
handrews 2f129ec
Wording consistency (review feedback)
handrews bace4b4
Review feedback
handrews File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2232,18 +2232,56 @@ Expressions can be embedded into string values by surrounding the expression wit | ||
| #### <a name="headerObject"></a>Header Object | ||
| The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes: | ||
| 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: | ||
| 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 | ||
| ---|:---:|--- | ||
| <a name="headerDescription"></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. | ||
| <a name="headerRequired"></a>required | `boolean` | Determines whether this header is mandatory. The default value is `false`. | ||
| <a name="headerDeprecated"></a> 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` | ||
| 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 | ||
| ---|:---:|--- | ||
| <a name="headerStyle"></a>style | `string` | Describes how the header value will be serialized. The default (and only legal value for headers) is `simple`. | ||
| <a name="headerExplode"></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 property has no effect. The default value is `false`. | ||
| <a name="headerSchema"></a>schema | [Schema Object](#schemaObject) \| [Reference Object](#referenceObject) | The schema defining the type used for the header. | ||
| <a name="headerExample"></a>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. | ||
| <a name="headerExamples"></a>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 | ||
| ---|:---:|--- | ||
| <a name="headerContent"></a>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: ^" | ||
| ``` | ||
| #### <a name="tagObject"></a>Tag Object | ||
| @@ -3523,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 | ||
| ## <a name="usingRFC6570Implementations"></a>Appendix C: Using RFC6570 Implementations | ||
handrews marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| ## <a name="serializingHeadersAndCookies"></a>Appendix D: Serializing Headers and Cookies | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.