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
+62Lines changed: 62 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2450,6 +2450,67 @@ Using `content` with a `text/plain` media type is RECOMMENDED for headers where
2450
2450
| ---- | :----: | ---- |
2451
2451
| <aname="header-content"></a>content | Map[`string`, [Media Type Object](#media-type-object)]| 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. |
2452
2452
2453
+
##### Modeling Link Headers
2454
+
2455
+
[[!RFC9264]] defines the `application/linkset` and `application/linkset+json` media types.
2456
+
The former is exactly the format of HTTP link header values except allowing additional whitespace for readability, while the latter is an equivalent JSON representation of such headers.
2457
+
2458
+
To use either of these media types, the `schema` in the [Media Type Object](#media-type-object) MUST describe the links as they would be structured in the `application/linkset+json` format.
2459
+
If the Media Type Object's parent key is `application/linkset+json`, then the serialization is trivial, however this format cannot be used in the HTTP `Link` header.
2460
+
If the Media Type Object's parent key is `application/linkset`, then the serialization MUST be the equivalent representation of the `schema`-modeled links in the `application/linkset` format.
2461
+
If the `application/linkset` Media Type Object is used in the `content` field of a Header Object (or a Parameter Object with `in: "header"`), the serialization MUST be made compatible with the HTTP field syntax as described by [[!RFC9264]][Section 4.1](https://www.rfc-editor.org/rfc/rfc9264.html#name-http-link-document-format-a).
2462
+
2463
+
The following example shows how the same data model can be used for a collection pagination linkset either in JSON format as message content, or in the HTTP `Link` header:
2464
+
2465
+
```yaml
2466
+
components:
2467
+
schemas:
2468
+
SimpleLinkContext:
2469
+
type: array
2470
+
items:
2471
+
type: object
2472
+
required:
2473
+
- href
2474
+
properties:
2475
+
href:
2476
+
type: string
2477
+
format: uri-reference
2478
+
CollectionLinks:
2479
+
type: object
2480
+
required:
2481
+
- linkset
2482
+
properties:
2483
+
linkset:
2484
+
type: array
2485
+
items:
2486
+
type: object
2487
+
required: [first, prev, next, last]
2488
+
properties:
2489
+
anchor:
2490
+
type: string
2491
+
format: uri
2492
+
additionalProperties:
2493
+
$ref: '#/components/schemas/SimpleLinkContext'
2494
+
responses:
2495
+
CollectionWithLinks:
2496
+
content:
2497
+
application/json:
2498
+
schema:
2499
+
type: array
2500
+
headers:
2501
+
Link:
2502
+
required: true
2503
+
content:
2504
+
application/linkset:
2505
+
schema:
2506
+
$ref: '#/components/schemas/CollectionLinks'
2507
+
StandaloneJsonLinkset:
2508
+
content:
2509
+
application/linkset+json:
2510
+
schema:
2511
+
$ref: '#/components/mediaTypes/CollectionLinks'
2512
+
```
2513
+
2453
2514
##### Header Object Example
2454
2515
2455
2516
A simple header of type `integer`:
@@ -4292,6 +4353,7 @@ This will expand to the result:
4292
4353
4293
4354
[RFC6570](https://www.rfc-editor.org/rfc/rfc6570)'s percent-encoding behavior is not always appropriate for `in: "header"` and `in: "cookie"` parameters.
4294
4355
In many cases, it is more appropriate to use `content` with a media type such as `text/plain` and require the application to assemble the correct string.
4356
+
Other media types, such as `application/linkset` (see [Modeling Link Headers](#modeling-link-headers)), are directly suitable for use as `content` for specific headers.
4295
4357
4296
4358
In some cases, setting `allowReserved: true` will be sufficient to avoid incorrect encoding, however many characters are still percent-encoded with this field enabled, so care must be taken to ensure no unexpected percent-encoding will take place.
0 commit comments