Skip to content

Commit 68bfa30

Browse files
committed
Better implementation of Link
Actually ensure each pattern is matched - in the previous way the example was written, the uniqueItems was not sufficient as a link with the same rel but different URI would have satisfied the conditions. Also, the text says "includes" these rels, so there could be more entries.
1 parent ac96d1e commit 68bfa30

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/oas.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2531,17 +2531,19 @@ A `Link` header that, if present, must include links with the standard relation
25312531
Link:
25322532
schema:
25332533
type: array
2534-
uniqueItems: true
2535-
minItems: 5
2536-
maxItems: 5
25372534
items:
25382535
type: string
2539-
anyOf:
2540-
- pattern: rel="?first"?
2541-
- pattern: rel="?prev"?
2542-
- pattern: rel="?self"?
2543-
- pattern: rel="?next"?
2544-
- pattern: rel="?last"?
2536+
allOf:
2537+
- contains:
2538+
pattern: rel="?first"?
2539+
- contains:
2540+
pattern: rel="?prev"?
2541+
- contains:
2542+
pattern: rel="?self"?
2543+
- contains:
2544+
pattern: rel="?next"?
2545+
- contains:
2546+
pattern: rel="?last"?
25452547
style: simple
25462548
# The ";" character and the URI delimiters are reserved
25472549
# but needs to be allowed as headers do not expect these
@@ -2558,8 +2560,8 @@ Link:
25582560
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
25592561
```
25602562

2561-
Note that the `items`, `uniqueItems: true`, and `anyOf` combination allows the links to appear in any order.
2562-
If a fixed order is desired, then `prefixItems` could be used and `uniqueItems` would not be necessary.
2563+
Note that the `allOf` with `contains` combination allows the links to appear in any order.
2564+
If a fixed order is desired, then `prefixItems` could be used and the `allof` would not be necessary.
25632565

25642566
#### Tag Object
25652567

0 commit comments

Comments
 (0)