Skip to content

Commit ed0b855

Browse files
authored
Merge pull request #594 from json-schema-org/differing-uris
Add tests for some more differing URI scenarios.
2 parents ae06513 + de3f769 commit ed0b855

File tree

9 files changed

+238
-0
lines changed

9 files changed

+238
-0
lines changed

remotes/different-id-ref-string.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$id": "http://localhost:1234/real-id-ref-string.json",
3+
"$defs": {"bar": {"type": "string"}},
4+
"$ref": "#/$defs/bar"
5+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"$defs": {
3+
"bar": {
4+
"$id": "http://localhost:1234/the-nested-id.json",
5+
"type": "string"
6+
}
7+
},
8+
"$ref": "http://localhost:1234/the-nested-id.json"
9+
}

remotes/urn-ref-string.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"$id": "urn:uuid:feebdaed-ffff-0000-ffff-0000deadbeef",
3+
"$defs": {"bar": {"type": "string"}},
4+
"$ref": "#/$defs/bar"
5+
}

tests/draft-next/ref.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,5 +858,30 @@
858858
"valid": false
859859
}
860860
]
861+
},
862+
{
863+
"description": "URN ref with nested pointer ref",
864+
"schema": {
865+
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
866+
"$defs": {
867+
"foo": {
868+
"$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
869+
"$defs": {"bar": {"type": "string"}},
870+
"$ref": "#/$defs/bar"
871+
}
872+
}
873+
},
874+
"tests": [
875+
{
876+
"description": "a string is valid",
877+
"data": "bar",
878+
"valid": true
879+
},
880+
{
881+
"description": "a non-string is invalid",
882+
"data": 12,
883+
"valid": false
884+
}
885+
]
861886
}
862887
]

tests/draft-next/refRemote.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,53 @@
243243
"valid": true
244244
}
245245
]
246+
},
247+
{
248+
"description": "remote HTTP ref with different $id",
249+
"schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
250+
"tests": [
251+
{
252+
"description": "number is invalid",
253+
"data": 1,
254+
"valid": false
255+
},
256+
{
257+
"description": "string is valid",
258+
"data": "foo",
259+
"valid": true
260+
}
261+
]
262+
},
263+
{
264+
"description": "remote HTTP ref with different URN $id",
265+
"schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
266+
"tests": [
267+
{
268+
"description": "number is invalid",
269+
"data": 1,
270+
"valid": false
271+
},
272+
{
273+
"description": "string is valid",
274+
"data": "foo",
275+
"valid": true
276+
}
277+
]
278+
},
279+
{
280+
"description": "remote HTTP ref with nested absolute ref",
281+
"schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
282+
"tests": [
283+
{
284+
"description": "number is invalid",
285+
"data": 1,
286+
"valid": false
287+
},
288+
{
289+
"description": "string is valid",
290+
"data": "foo",
291+
"valid": true
292+
}
293+
]
246294
}
247295
]

tests/draft2019-09/ref.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,5 +858,30 @@
858858
"valid": false
859859
}
860860
]
861+
},
862+
{
863+
"description": "URN ref with nested pointer ref",
864+
"schema": {
865+
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
866+
"$defs": {
867+
"foo": {
868+
"$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
869+
"$defs": {"bar": {"type": "string"}},
870+
"$ref": "#/$defs/bar"
871+
}
872+
}
873+
},
874+
"tests": [
875+
{
876+
"description": "a string is valid",
877+
"data": "bar",
878+
"valid": true
879+
},
880+
{
881+
"description": "a non-string is invalid",
882+
"data": 12,
883+
"valid": false
884+
}
885+
]
861886
}
862887
]

tests/draft2019-09/refRemote.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,53 @@
243243
"valid": true
244244
}
245245
]
246+
},
247+
{
248+
"description": "remote HTTP ref with different $id",
249+
"schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
250+
"tests": [
251+
{
252+
"description": "number is invalid",
253+
"data": 1,
254+
"valid": false
255+
},
256+
{
257+
"description": "string is valid",
258+
"data": "foo",
259+
"valid": true
260+
}
261+
]
262+
},
263+
{
264+
"description": "remote HTTP ref with different URN $id",
265+
"schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
266+
"tests": [
267+
{
268+
"description": "number is invalid",
269+
"data": 1,
270+
"valid": false
271+
},
272+
{
273+
"description": "string is valid",
274+
"data": "foo",
275+
"valid": true
276+
}
277+
]
278+
},
279+
{
280+
"description": "remote HTTP ref with nested absolute ref",
281+
"schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
282+
"tests": [
283+
{
284+
"description": "number is invalid",
285+
"data": 1,
286+
"valid": false
287+
},
288+
{
289+
"description": "string is valid",
290+
"data": "foo",
291+
"valid": true
292+
}
293+
]
246294
}
247295
]

tests/draft2020-12/ref.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,5 +858,30 @@
858858
"valid": false
859859
}
860860
]
861+
},
862+
{
863+
"description": "URN ref with nested pointer ref",
864+
"schema": {
865+
"$ref": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
866+
"$defs": {
867+
"foo": {
868+
"$id": "urn:uuid:deadbeef-4321-ffff-ffff-1234feebdaed",
869+
"$defs": {"bar": {"type": "string"}},
870+
"$ref": "#/$defs/bar"
871+
}
872+
}
873+
},
874+
"tests": [
875+
{
876+
"description": "a string is valid",
877+
"data": "bar",
878+
"valid": true
879+
},
880+
{
881+
"description": "a non-string is invalid",
882+
"data": 12,
883+
"valid": false
884+
}
885+
]
861886
}
862887
]

tests/draft2020-12/refRemote.json

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,5 +243,53 @@
243243
"valid": true
244244
}
245245
]
246+
},
247+
{
248+
"description": "remote HTTP ref with different $id",
249+
"schema": {"$ref": "http://localhost:1234/different-id-ref-string.json"},
250+
"tests": [
251+
{
252+
"description": "number is invalid",
253+
"data": 1,
254+
"valid": false
255+
},
256+
{
257+
"description": "string is valid",
258+
"data": "foo",
259+
"valid": true
260+
}
261+
]
262+
},
263+
{
264+
"description": "remote HTTP ref with different URN $id",
265+
"schema": {"$ref": "http://localhost:1234/urn-ref-string.json"},
266+
"tests": [
267+
{
268+
"description": "number is invalid",
269+
"data": 1,
270+
"valid": false
271+
},
272+
{
273+
"description": "string is valid",
274+
"data": "foo",
275+
"valid": true
276+
}
277+
]
278+
},
279+
{
280+
"description": "remote HTTP ref with nested absolute ref",
281+
"schema": {"$ref": "http://localhost:1234/nested-absolute-ref-to-string.json"},
282+
"tests": [
283+
{
284+
"description": "number is invalid",
285+
"data": 1,
286+
"valid": false
287+
},
288+
{
289+
"description": "string is valid",
290+
"data": "foo",
291+
"valid": true
292+
}
293+
]
246294
}
247295
]

0 commit comments

Comments
 (0)