Skip to content

Commit 980e105

Browse files
authored
Merge pull request #790 from dylankerr-bis/add-test-sibling-nested-ref-id
Add test for sibling $ref and $id in nested schema to 2019-09 and 2020-12 suites
2 parents 4cf5599 + b5037ed commit 980e105

File tree

3 files changed

+99
-0
lines changed

3 files changed

+99
-0
lines changed

tests/draft2019-09/ref.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,39 @@
663663
}
664664
]
665665
},
666+
{
667+
"description": "order of evaluation: $id and $ref on nested schema",
668+
"schema": {
669+
"$comment": "$id must be evaluated before $ref to get the proper $ref destination",
670+
"$schema": "https://json-schema.org/draft/2019-09/schema",
671+
"$id": "https://example.com/draft2019-09/ref-and-id3/base.json",
672+
"$ref": "nested/foo.json",
673+
"$defs": {
674+
"foo": {
675+
"$comment": "canonical uri: https://example.com/draft2019-09/ref-and-id3/nested/foo.json",
676+
"$id": "nested/foo.json",
677+
"$ref": "./bar.json"
678+
},
679+
"bar": {
680+
"$comment": "canonical uri: https://example.com/draft2019-09/ref-and-id3/nested/bar.json",
681+
"$id": "nested/bar.json",
682+
"type": "number"
683+
}
684+
}
685+
},
686+
"tests": [
687+
{
688+
"description": "data is valid against nested sibling",
689+
"data": 5,
690+
"valid": true
691+
},
692+
{
693+
"description": "data is invalid against nested sibling",
694+
"data": "a",
695+
"valid": false
696+
}
697+
]
698+
},
666699
{
667700
"description": "simple URN base URI with $ref via the URN",
668701
"schema": {

tests/draft2020-12/ref.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,39 @@
663663
}
664664
]
665665
},
666+
{
667+
"description": "order of evaluation: $id and $ref on nested schema",
668+
"schema": {
669+
"$comment": "$id must be evaluated before $ref to get the proper $ref destination",
670+
"$schema": "https://json-schema.org/draft/2020-12/schema",
671+
"$id": "https://example.com/draft2020-12/ref-and-id3/base.json",
672+
"$ref": "nested/foo.json",
673+
"$defs": {
674+
"foo": {
675+
"$comment": "canonical uri: https://example.com/draft2020-12/ref-and-id3/nested/foo.json",
676+
"$id": "nested/foo.json",
677+
"$ref": "./bar.json"
678+
},
679+
"bar": {
680+
"$comment": "canonical uri: https://example.com/draft2020-12/ref-and-id3/nested/bar.json",
681+
"$id": "nested/bar.json",
682+
"type": "number"
683+
}
684+
}
685+
},
686+
"tests": [
687+
{
688+
"description": "data is valid against nested sibling",
689+
"data": 5,
690+
"valid": true
691+
},
692+
{
693+
"description": "data is invalid against nested sibling",
694+
"data": "a",
695+
"valid": false
696+
}
697+
]
698+
},
666699
{
667700
"description": "simple URN base URI with $ref via the URN",
668701
"schema": {

tests/v1/ref.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,39 @@
663663
}
664664
]
665665
},
666+
{
667+
"description": "order of evaluation: $id and $ref on nested schema",
668+
"schema": {
669+
"$comment": "$id must be evaluated before $ref to get the proper $ref destination",
670+
"$schema": "https://json-schema.org/v1",
671+
"$id": "https://example.com/v1/ref-and-id3/base.json",
672+
"$ref": "nested/foo.json",
673+
"$defs": {
674+
"foo": {
675+
"$comment": "canonical uri: https://example.com/v1/ref-and-id3/nested/foo.json",
676+
"$id": "nested/foo.json",
677+
"$ref": "./bar.json"
678+
},
679+
"bar": {
680+
"$comment": "canonical uri: https://example.com/v1/ref-and-id3/nested/bar.json",
681+
"$id": "nested/bar.json",
682+
"type": "number"
683+
}
684+
}
685+
},
686+
"tests": [
687+
{
688+
"description": "data is valid against nested sibling",
689+
"data": 5,
690+
"valid": true
691+
},
692+
{
693+
"description": "data is invalid against nested sibling",
694+
"data": "a",
695+
"valid": false
696+
}
697+
]
698+
},
666699
{
667700
"description": "simple URN base URI with $ref via the URN",
668701
"schema": {

0 commit comments

Comments
 (0)