Debian Codegraph @

spec/JSON-Schema-Test-Suite/tests/draft2020-12/id.json

raw ◀ ▶
1 Debian patch touch this file
•1 [
2 {
3 "description": "Invalid use of fragments in location-independent $id",
4 "schema": {
5 "$ref": "https://json-schema.org/draft/2020-12/schema"
6 },
7 "tests": [
8 {
9 "description": "Identifier name",
10 "data": {
11 "$ref": "#foo",
12 "$defs": {
13 "A": {
14 "$id": "#foo",
15 "type": "integer"
16 }
17 }
18 },
19 "valid": false
20 },
21 {
22 "description": "Identifier name and no ref",
23 "data": {
24 "$defs": {
25 "A": { "$id": "#foo" }
26 }
27 },
28 "valid": false
29 },
30 {
31 "description": "Identifier path",
32 "data": {
33 "$ref": "#/a/b",
34 "$defs": {
35 "A": {
36 "$id": "#/a/b",
37 "type": "integer"
38 }
39 }
40 },
41 "valid": false
42 },
43 {
44 "description": "Identifier name with absolute URI",
45 "data": {
46 "$ref": "http://localhost:1234/bar#foo",
47 "$defs": {
48 "A": {
49 "$id": "http://localhost:1234/bar#foo",
50 "type": "integer"
51 }
52 }
53 },
54 "valid": false
55 },
56 {
57 "description": "Identifier path with absolute URI",
58 "data": {
59 "$ref": "http://localhost:1234/bar#/a/b",
60 "$defs": {
61 "A": {
62 "$id": "http://localhost:1234/bar#/a/b",
63 "type": "integer"
64 }
65 }
66 },
67 "valid": false
68 },
69 {
70 "description": "Identifier name with base URI change in subschema",
71 "data": {
72 "$id": "http://localhost:1234/root",
73 "$ref": "http://localhost:1234/nested.json#foo",
74 "$defs": {
75 "A": {
76 "$id": "nested.json",
77 "$defs": {
78 "B": {
79 "$id": "#foo",
80 "type": "integer"
81 }
82 }
83 }
84 }
85 },
86 "valid": false
87 },
88 {
89 "description": "Identifier path with base URI change in subschema",
90 "data": {
91 "$id": "http://localhost:1234/root",
92 "$ref": "http://localhost:1234/nested.json#/a/b",
93 "$defs": {
94 "A": {
95 "$id": "nested.json",
96 "$defs": {
97 "B": {
98 "$id": "#/a/b",
99 "type": "integer"
100 }
101 }
102 }
103 }
104 },
105 "valid": false
106 }
107 ]
108 },
109 {
110 "description": "Valid use of empty fragments in location-independent $id",
111 "comment": "These are allowed but discouraged",
112 "schema": {
113 "$ref": "https://json-schema.org/draft/2020-12/schema"
114 },
115 "tests": [
116 {
117 "description": "Identifier name with absolute URI",
118 "data": {
119 "$ref": "http://localhost:1234/bar",
120 "$defs": {
121 "A": {
122 "$id": "http://localhost:1234/bar#",
123 "type": "integer"
124 }
125 }
126 },
127 "valid": true
128 },
129 {
130 "description": "Identifier name with base URI change in subschema",
131 "data": {
132 "$id": "http://localhost:1234/root",
133 "$ref": "http://localhost:1234/nested.json#/$defs/B",
134 "$defs": {
135 "A": {
136 "$id": "nested.json",
137 "$defs": {
138 "B": {
139 "$id": "#",
140 "type": "integer"
141 }
142 }
143 }
144 }
145 },
146 "valid": true
147 }
148 ]
149 },
150 {
151 "description": "Unnormalized $ids are allowed but discouraged",
152 "schema": {
153 "$ref": "https://json-schema.org/draft/2020-12/schema"
154 },
155 "tests": [
156 {
157 "description": "Unnormalized identifier",
158 "data": {
159 "$ref": "http://localhost:1234/foo/baz",
160 "$defs": {
161 "A": {
162 "$id": "http://localhost:1234/foo/bar/../baz",
163 "type": "integer"
164 }
165 }
166 },
167 "valid": true
168 },
169 {
170 "description": "Unnormalized identifier and no ref",
171 "data": {
172 "$defs": {
173 "A": {
174 "$id": "http://localhost:1234/foo/bar/../baz",
175 "type": "integer"
176 }
177 }
178 },
179 "valid": true
180 },
181 {
182 "description": "Unnormalized identifier with empty fragment",
183 "data": {
184 "$ref": "http://localhost:1234/foo/baz",
185 "$defs": {
186 "A": {
187 "$id": "http://localhost:1234/foo/bar/../baz#",
188 "type": "integer"
189 }
190 }
191 },
192 "valid": true
193 },
194 {
195 "description": "Unnormalized identifier with empty fragment and no ref",
196 "data": {
197 "$defs": {
198 "A": {
199 "$id": "http://localhost:1234/foo/bar/../baz#",
200 "type": "integer"
201 }
202 }
203 },
204 "valid": true
205 }
206 ]
207 },
208 {
209 "description": "$id inside an enum is not a real identifier",
210 "comment": "the implementation must not be confused by an $id buried in the enum",
211 "schema": {
212 "$defs": {
213 "id_in_enum": {
214 "enum": [
215 {
216 "$id": "https://localhost:1234/id/my_identifier.json",
217 "type": "null"
218 }
219 ]
220 },
221 "real_id_in_schema": {
222 "$id": "https://localhost:1234/id/my_identifier.json",
223 "type": "string"
224 },
225 "zzz_id_in_const": {
226 "const": {
227 "$id": "https://localhost:1234/id/my_identifier.json",
228 "type": "null"
229 }
230 }
231 },
232 "anyOf": [
233 { "$ref": "#/$defs/id_in_enum" },
234 { "$ref": "https://localhost:1234/id/my_identifier.json" }
235 ]
236 },
237 "tests": [
238 {
239 "description": "exact match to enum, and type matches",
240 "data": {
241 "$id": "https://localhost:1234/id/my_identifier.json",
242 "type": "null"
243 },
244 "valid": true
245 },
246 {
247 "description": "match $ref to $id",
248 "data": "a string to match #/$defs/id_in_enum",
249 "valid": true
250 },
251 {
252 "description": "no match on enum or $ref to $id",
253 "data": 1,
254 "valid": false
255 }
256 ]
257 }
258 ]