Skip to content

Commit 4abf253

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 fda8288 commit 4abf253

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
@@ -2534,17 +2534,19 @@ A `Link` header that, if present, must include links with the standard relation
25342534
Link:
25352535
schema:
25362536
type: array
2537-
uniqueItems: true
2538-
minItems: 5
2539-
maxItems: 5
25402537
items:
25412538
type: string
2542-
anyOf:
2543-
- pattern: rel="?first"?
2544-
- pattern: rel="?prev"?
2545-
- pattern: rel="?self"?
2546-
- pattern: rel="?next"?
2547-
- pattern: rel="?last"?
2539+
allOf:
2540+
- contains:
2541+
pattern: rel="?first"?
2542+
- contains:
2543+
pattern: rel="?prev"?
2544+
- contains:
2545+
pattern: rel="?self"?
2546+
- contains:
2547+
pattern: rel="?next"?
2548+
- contains:
2549+
pattern: rel="?last"?
25482550
style: simple
25492551
# The ";" character and the URI delimiters are reserved
25502552
# but needs to be allowed as headers do not expect these
@@ -2561,8 +2563,8 @@ Link:
25612563
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
25622564
```
25632565

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

25672569
#### Tag Object
25682570

0 commit comments

Comments
 (0)