Skip to content

Commit 2334248

Browse files
committed
Add a more complex header example
1 parent 63423e7 commit 2334248

File tree

1 file changed

+33
-1
lines changed

1 file changed

+33
-1
lines changed

src/oas.md

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2489,7 +2489,7 @@ Using `content` with a `text/plain` media type is RECOMMENDED for headers where
24892489
| ---- | :----: | ---- |
24902490
| <a name="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. |
24912491

2492-
##### Header Object Example
2492+
##### Header Object Examples
24932493

24942494
A simple header of type `integer`:
24952495

@@ -2516,6 +2516,38 @@ ETag:
25162516
pattern: ^"
25172517
```
25182518

2519+
A `Link` header that, if present, must include links with the standard relation types `self`, `first`, `prev`, `next`, and `last`, as might be used on a paginated collection:
2520+
2521+
```yaml
2522+
Link:
2523+
schema:
2524+
type: array
2525+
uniqueItems: true
2526+
minItems: 5
2527+
maxItems: 5
2528+
items:
2529+
type: string
2530+
anyOf:
2531+
- pattern: rel="?first"?
2532+
- pattern: rel="?prev"?
2533+
- pattern: rel="?self"?
2534+
- pattern: rel="?next"?
2535+
- pattern: rel="?last"?
2536+
style: simple
2537+
examples:
2538+
CollectionLinks:
2539+
dataValue:
2540+
- https://example.com/foos?page=1; rel=first
2541+
- https://example.com/foos?page=4; rel=prev
2542+
- https://example.com/foos?page=5; rel=self
2543+
- https://example.com/foos?page=6; rel=next
2544+
- https://example.com/foos?page=10; rel=last
2545+
serializedValue: https://example.com/foos?page=1; rel=first, https://example.com/foos?page=4; rel=prev, https://example.com/foos?page=5; rel=self, https://example.com/foos?page=6; rel=next, https://example.com/foos?page=10; rel=last
2546+
```
2547+
2548+
Note that the `items`, `uniqueItems: true`, and `anyOf` combination allows the links to appear in any order.
2549+
If a fixed order is desired, then `prefixItems` could be used and `uniqueItems` would not be necessary.
2550+
25192551
#### Tag Object
25202552

25212553
Adds metadata to a single tag that is used by the [Operation Object](#operation-object).

0 commit comments

Comments
 (0)