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: versions/3.0.4.md
+75-6
Original file line number
Diff line number
Diff line change
@@ -2336,18 +2336,56 @@ Expressions can be embedded into string values by surrounding the expression wit
2336
2336
2337
2337
#### <aname="headerObject"></a>Header Object
2338
2338
2339
-
The Header Object follows the structure of the [Parameter Object](#parameterObject) with the following changes:
2339
+
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.
2340
+
2341
+
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:
2340
2342
2341
2343
1.`name` MUST NOT be specified, it is given in the corresponding `headers` map.
2342
2344
1.`in` MUST NOT be specified, it is implicitly in `header`.
2343
-
1. All traits that are affected by the location MUST be applicable to a location of `header` (for example, [`style`](#parameterStyle)).
2345
+
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`.
2346
+
2347
+
###### Common Fixed Fields
2348
+
2349
+
These fields MAY be used with either `content` or `schema`.
2350
+
2351
+
Field Name | Type | Description
2352
+
---|:---:|---
2353
+
<aname="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.
2354
+
<aname="headerRequired"></a>required | `boolean` | Determines whether this header is mandatory. The default value is `false`.
2355
+
<aname="headerDeprecated"></a> deprecated | `boolean` | Specifies that the header is deprecated and SHOULD be transitioned out of usage. Default value is `false`.
2356
+
2357
+
###### Fixed Fields for use with `schema`
2358
+
2359
+
For simpler scenarios, a [`schema`](#headerSchema) and [`style`](#headerStyle) can describe the structure and syntax of the header.
2360
+
When `example` or `examples` are provided in conjunction with the `schema` object, the example MUST follow the prescribed serialization strategy for the header.
2361
+
2362
+
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.
2363
+
2364
+
Field Name | Type | Description
2365
+
---|:---:|---
2366
+
<aname="headerStyle"></a>style | `string` | Describes how the header value will be serialized. The default (and only legal value for headers) is `simple`.
2367
+
<aname="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`.
2368
+
<aname="headerSchema"></a>schema | [Schema Object](#schemaObject)\|[Reference Object](#referenceObject) | The schema defining the type used for the header.
2369
+
<aname="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.
2370
+
<aname="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.
2371
+
2372
+
See also [Appendix C: Using RFC6570 Implementations](#usingRFC6570Implementations) for additional guidance.
2373
+
2374
+
###### Fixed Fields for use with `content`
2375
+
2376
+
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.
2377
+
Using `content` with a `text/plain` media type is RECOMMENDED for headers where the `schema` strategy is not appropriate.
2378
+
2379
+
Field Name | Type | Description
2380
+
---|:---:|---
2381
+
<aname="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.
2344
2382
2345
2383
##### Header Object Example
2346
2384
2347
2385
A simple header of type `integer`:
2348
2386
2349
2387
```json
2350
-
{
2388
+
"X-Rate-Limit-Limit": {
2351
2389
"description": "The number of allowed requests in the current period",
2352
2390
"schema": {
2353
2391
"type": "integer"
@@ -2356,9 +2394,36 @@ A simple header of type `integer`:
2356
2394
```
2357
2395
2358
2396
```yaml
2359
-
description: The number of allowed requests in the current period
2360
-
schema:
2361
-
type: integer
2397
+
X-Rate-Limit-Limit:
2398
+
description: The number of allowed requests in the current period
2399
+
schema:
2400
+
type: integer
2401
+
```
2402
+
2403
+
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`:
2404
+
2405
+
```json
2406
+
"ETag": {
2407
+
"required": true,
2408
+
"content": {
2409
+
"text/plain": {
2410
+
"schema": {
2411
+
"type": "string",
2412
+
"pattern": "^\""
2413
+
}
2414
+
}
2415
+
}
2416
+
}
2417
+
```
2418
+
2419
+
```yaml
2420
+
ETag:
2421
+
required: true
2422
+
content:
2423
+
text/plain:
2424
+
schema:
2425
+
type: string
2426
+
pattern: ^"
2362
2427
```
2363
2428
2364
2429
#### <a name="tagObject"></a>Tag Object
@@ -3631,3 +3696,7 @@ Version | Date | Notes
3631
3696
1.2 | 2014-03-14 | Initial release of the formal document.
3632
3697
1.1 | 2012-08-22 | Release of Swagger 1.1
3633
3698
1.0 | 2011-08-10 | First release of the Swagger Specification
3699
+
3700
+
## <a name="usingRFC6570Implementations"></a>Appendix C: Using RFC6570 Implementations
3701
+
3702
+
## <a name="serializingHeadersAndCookies"></a>Appendix D: Serializing Headers and Cookies
0 commit comments