Skip to content

Commit 9eab0d6

Browse files
committed
[299] Add tests for invalid use of fragments in "$id"
1 parent 240fbf6 commit 9eab0d6

File tree

2 files changed

+100
-2
lines changed

2 files changed

+100
-2
lines changed

tests/draft2019-09/id.json

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[
2+
{
3+
"description": "Invalid use of fragments in location-independent $id",
4+
"schema": {"$ref": "https://json-schema.org/draft/2019-09/schema"},
5+
"tests": [
6+
{
7+
"description": "Identifier name",
8+
"data": {
9+
"$ref": "#foo",
10+
"$defs": {
11+
"A": {
12+
"$id": "#foo",
13+
"type": "integer"
14+
}
15+
}
16+
},
17+
"valid": false
18+
},
19+
{
20+
"description": "Identifier path",
21+
"data": {
22+
"$ref": "#/a/b",
23+
"$defs": {
24+
"A": {
25+
"$id": "#/a/b",
26+
"type": "integer"
27+
}
28+
}
29+
},
30+
"valid": false
31+
},
32+
{
33+
"description": "Identifier name with absolute URI",
34+
"data": {
35+
"$ref": "http://localhost:1234/bar#foo",
36+
"$defs": {
37+
"A": {
38+
"$id": "http://localhost:1234/bar#foo",
39+
"type": "integer"
40+
}
41+
}
42+
},
43+
"valid": false
44+
},
45+
{
46+
"description": "Identifier path with absolute URI",
47+
"data": {
48+
"$ref": "http://localhost:1234/bar#/a/b",
49+
"$defs": {
50+
"A": {
51+
"$id": "http://localhost:1234/bar#/a/b",
52+
"type": "integer"
53+
}
54+
}
55+
},
56+
"valid": false
57+
},
58+
{
59+
"description": "Identifier name with base URI change in subschema",
60+
"data": {
61+
"$id": "http://localhost:1234/root",
62+
"$ref": "http://localhost:1234/nested.json#foo",
63+
"$defs": {
64+
"A": {
65+
"$id": "nested.json",
66+
"$defs": {
67+
"B": {
68+
"$id": "#foo",
69+
"type": "integer"
70+
}
71+
}
72+
}
73+
}
74+
},
75+
"valid": false
76+
},
77+
{
78+
"description": "Identifier path with base URI change in subschema",
79+
"data": {
80+
"$id": "http://localhost:1234/root",
81+
"$ref": "http://localhost:1234/nested.json#/a/b",
82+
"$defs": {
83+
"A": {
84+
"$id": "nested.json",
85+
"$defs": {
86+
"B": {
87+
"$id": "#/a/b",
88+
"type": "integer"
89+
}
90+
}
91+
}
92+
}
93+
},
94+
"valid": false
95+
}
96+
]
97+
}
98+
]

tests/draft2019-09/ref.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@
273273
"tests": [
274274
{
275275
"description": "valid tree",
276-
"data": {
276+
"data": {
277277
"meta": "root",
278278
"nodes": [
279279
{
@@ -302,7 +302,7 @@
302302
},
303303
{
304304
"description": "invalid tree",
305-
"data": {
305+
"data": {
306306
"meta": "root",
307307
"nodes": [
308308
{

0 commit comments

Comments
 (0)