Debian Codegraph @

spec/extras/$data/absolute_ref.json

raw symbols SCIP
1 [
2 {
3 "description": "property is equal to another property [absolute JSON pointer]",
4 "schema": {
5 "properties": {
6 "sameAs": {
7 "const": {
8 "$data": "/thisOne"
9 }
10 },
11 "thisOne": {}
12 }
13 },
14 "tests": [
15 {
16 "description": "same value is valid",
17 "data": {
18 "sameAs": 5,
19 "thisOne": 5
20 },
21 "valid": true
22 },
23 {
24 "description": "same object is valid",
25 "data": {
26 "sameAs": {
27 "foo": 1,
28 "bar": 2
29 },
30 "thisOne": {
31 "bar": 2,
32 "foo": 1
33 }
34 },
35 "valid": true
36 },
37 {
38 "description": "another value is invalid",
39 "data": {
40 "sameAs": {
41 "foo": 1
42 },
43 "thisOne": {
44 "foo": 2
45 }
46 },
47 "valid": false
48 },
49 {
50 "description": "another type is invalid",
51 "data": {
52 "sameAs": 5,
53 "thisOne": "5"
54 },
55 "valid": false
56 }
57 ]
58 },
59 {
60 "description": "items in one array are equal to items in another (limited length) [absolute JSON pointer]",
61 "schema": {
62 "properties": {
63 "arr": {
64 "items": [{}, {}, {}],
65 "additionalItems": false
66 },
67 "sameArr": {
68 "items": [
69 {
70 "const": {
71 "$data": "/arr/0"
72 }
73 },
74 {
75 "const": {
76 "$data": "/arr/1"
77 }
78 },
79 {
80 "const": {
81 "$data": "/arr/2"
82 }
83 }
84 ],
85 "additionalItems": false
86 }
87 }
88 },
89 "tests": [
90 {
91 "description": "equal arrays are valid",
92 "data": {
93 "arr": [
94 1,
95 "abc",
96 {
97 "foo": "bar"
98 }
99 ],
100 "sameArr": [
101 1,
102 "abc",
103 {
104 "foo": "bar"
105 }
106 ]
107 },
108 "valid": true
109 },
110 {
111 "description": "different arrays are invalid",
112 "data": {
113 "arr": [
114 1,
115 "abc",
116 {
117 "foo": "bar"
118 }
119 ],
120 "sameArr": [
121 1,
122 "abc",
123 {
124 "foo": "foo"
125 }
126 ]
127 },
128 "valid": false
129 }
130 ]
131 },
132 {
133 "description": "property value is contained in array [absolute JSON pointer]",
134 "schema": {
135 "properties": {
136 "name": {
137 "type": "string"
138 },
139 "list": {
140 "type": "array",
141 "contains": {
142 "const": {
143 "$data": "/name"
144 }
145 }
146 }
147 }
148 },
149 "tests": [
150 {
151 "description": "1 item array containing property is valid",
152 "data": {
153 "name": "foo",
154 "list": ["foo"]
155 },
156 "valid": true
157 },
158 {
159 "description": "2 item array containing property is valid",
160 "data": {
161 "name": "foo",
162 "list": ["foo", "bar"]
163 },
164 "valid": true
165 },
166 {
167 "description": "array not containing property is invalid",
168 "data": {
169 "name": "foo",
170 "list": ["bar"]
171 },
172 "valid": false
173 },
174 {
175 "description": "empty array is invalid",
176 "data": {
177 "name": "foo",
178 "list": []
179 },
180 "valid": false
181 }
182 ]
183 },
184 {
185 "description": "property is one of values in another property [absolute JSON pointer]",
186 "schema": {
187 "properties": {
188 "allowedValues": {},
189 "value": {
190 "enum": {
191 "$data": "/allowedValues"
192 }
193 }
194 }
195 },
196 "tests": [
197 {
198 "description": "one of the enum is valid",
199 "data": {
200 "allowedValues": [1, 2, 3],
201 "value": 1
202 },
203 "valid": true
204 },
205 {
206 "description": "something else is invalid",
207 "data": {
208 "allowedValues": [1, 2, 3],
209 "value": 4
210 },
211 "valid": false
212 },
213 {
214 "description": "heterogeneous enum validation",
215 "data": {
216 "allowedValues": [
217 6,
218 "foo",
219 [],
220 true,
221 {
222 "foo": 12
223 }
224 ],
225 "value": {
226 "foo": 12
227 }
228 },
229 "valid": true
230 },
231 {
232 "description": "fail if value of enum is not an array",
233 "data": {
234 "allowedValues": "[1, 2, 3]",
235 "value": 1
236 },
237 "valid": false
238 },
239 {
240 "description": "valid if value of enum is undefined",
241 "data": {
242 "value": 1
243 },
244 "valid": true
245 }
246 ]
247 },
248 {
249 "description": "enum in properties [absolute JSON pointer]",
250 "schema": {
251 "properties": {
252 "allowedValues": {}
253 },
254 "additionalProperties": {
255 "enum": {
256 "$data": "/allowedValues"
257 }
258 }
259 },
260 "tests": [
261 {
262 "description": "properties are valid",
263 "data": {
264 "allowedValues": ["foo", "bar"],
265 "a": "foo",
266 "b": "bar"
267 },
268 "valid": true
269 },
270 {
271 "description": "properties are invalid",
272 "data": {
273 "allowedValues": ["foo", "bar"],
274 "a": "foo",
275 "b": "baz"
276 },
277 "valid": false
278 }
279 ]
280 },
281 {
282 "description": "required schema in data property [absolute JSON pointer]",
283 "schema": {
284 "properties": {
285 "foo": {},
286 "bar": {},
287 "requiredProperties": {}
288 },
289 "required": {
290 "$data": "/requiredProperties"
291 }
292 },
293 "tests": [
294 {
295 "description": "present required property is valid",
296 "data": {
297 "foo": 1,
298 "requiredProperties": ["foo"]
299 },
300 "valid": true
301 },
302 {
303 "description": "non-present required property is invalid",
304 "data": {
305 "bar": 2,
306 "requiredProperties": ["foo"]
307 },
308 "valid": false
309 },
310 {
311 "description": "non-present second required property is invalid",
312 "data": {
313 "foo": 1,
314 "requiredProperties": ["foo", "bar"]
315 },
316 "valid": false
317 },
318 {
319 "description": "two present required properties is valid",
320 "data": {
321 "foo": 1,
322 "bar": 2,
323 "requiredProperties": ["foo", "bar"]
324 },
325 "valid": true
326 },
327 {
328 "description": "fails if value of required is not an array",
329 "data": {
330 "foo": 1,
331 "bar": 2,
332 "requiredProperties": true
333 },
334 "valid": false
335 },
336 {
337 "description": "valid if value of required is undefined",
338 "data": {
339 "foo": 1,
340 "bar": 2
341 },
342 "valid": true
343 }
344 ]
345 },
346 {
347 "description": "absolute JSON pointer can access data outside of a $ref",
348 "schema": {
349 "definitions": {
350 "baz": {
351 "type": "object",
352 "properties": {
353 "foo": {
354 "const": {
355 "$data": "/bar"
356 }
357 },
358 "bar": {}
359 }
360 }
361 },
362 "properties": {
363 "foo": {
364 "const": {
365 "$data": "/bar"
366 }
367 },
368 "bar": {},
369 "baz": {
370 "$ref": "#/definitions/baz"
371 }
372 }
373 },
374 "tests": [
375 {
376 "description": "$data reference with absolute JSON pointer resolves from root of data",
377 "data": {
378 "foo": 1,
379 "bar": 1,
380 "baz": {
381 "foo": 1,
382 "bar": 2
383 }
384 },
385 "valid": true
386 },
387 {
388 "description": "$data reference with absolute JSON pointer should NOT resolve to root of $ref",
389 "data": {
390 "foo": 2,
391 "bar": 2,
392 "baz": {
393 "foo": 1,
394 "bar": 1
395 }
396 },
397 "valid": false
398 }
399 ]
400 }
401 ]