Debian Codegraph @

share/tests/draft2020-12/unevaluatedItems.json

raw
1 [
2 {
3 "description": "unevaluatedItems true",
4 "schema": {
5 "$schema": "https://json-schema.org/draft/2020-12/schema",
6 "unevaluatedItems": true
7 },
8 "tests": [
9 {
10 "description": "with no unevaluated items",
11 "data": [],
12 "valid": true
13 },
14 {
15 "description": "with unevaluated items",
16 "data": ["foo"],
17 "valid": true
18 }
19 ]
20 },
21 {
22 "description": "unevaluatedItems false",
23 "schema": {
24 "$schema": "https://json-schema.org/draft/2020-12/schema",
25 "unevaluatedItems": false
26 },
27 "tests": [
28 {
29 "description": "with no unevaluated items",
30 "data": [],
31 "valid": true
32 },
33 {
34 "description": "with unevaluated items",
35 "data": ["foo"],
36 "valid": false
37 }
38 ]
39 },
40 {
41 "description": "unevaluatedItems as schema",
42 "schema": {
43 "$schema": "https://json-schema.org/draft/2020-12/schema",
44 "unevaluatedItems": { "type": "string" }
45 },
46 "tests": [
47 {
48 "description": "with no unevaluated items",
49 "data": [],
50 "valid": true
51 },
52 {
53 "description": "with valid unevaluated items",
54 "data": ["foo"],
55 "valid": true
56 },
57 {
58 "description": "with invalid unevaluated items",
59 "data": [42],
60 "valid": false
61 }
62 ]
63 },
64 {
65 "description": "unevaluatedItems with uniform items",
66 "schema": {
67 "$schema": "https://json-schema.org/draft/2020-12/schema",
68 "items": { "type": "string" },
69 "unevaluatedItems": false
70 },
71 "tests": [
72 {
73 "description": "unevaluatedItems doesn't apply",
74 "data": ["foo", "bar"],
75 "valid": true
76 }
77 ]
78 },
79 {
80 "description": "unevaluatedItems with tuple",
81 "schema": {
82 "$schema": "https://json-schema.org/draft/2020-12/schema",
83 "prefixItems": [
84 { "type": "string" }
85 ],
86 "unevaluatedItems": false
87 },
88 "tests": [
89 {
90 "description": "with no unevaluated items",
91 "data": ["foo"],
92 "valid": true
93 },
94 {
95 "description": "with unevaluated items",
96 "data": ["foo", "bar"],
97 "valid": false
98 }
99 ]
100 },
101 {
102 "description": "unevaluatedItems with items and prefixItems",
103 "schema": {
104 "$schema": "https://json-schema.org/draft/2020-12/schema",
105 "prefixItems": [
106 { "type": "string" }
107 ],
108 "items": true,
109 "unevaluatedItems": false
110 },
111 "tests": [
112 {
113 "description": "unevaluatedItems doesn't apply",
114 "data": ["foo", 42],
115 "valid": true
116 }
117 ]
118 },
119 {
120 "description": "unevaluatedItems with items",
121 "schema": {
122 "$schema": "https://json-schema.org/draft/2020-12/schema",
123 "items": {"type": "number"},
124 "unevaluatedItems": {"type": "string"}
125 },
126 "tests": [
127 {
128 "description": "valid under items",
129 "comment": "no elements are considered by unevaluatedItems",
130 "data": [5, 6, 7, 8],
131 "valid": true
132 },
133 {
134 "description": "invalid under items",
135 "data": ["foo", "bar", "baz"],
136 "valid": false
137 }
138 ]
139 },
140 {
141 "description": "unevaluatedItems with nested tuple",
142 "schema": {
143 "$schema": "https://json-schema.org/draft/2020-12/schema",
144 "prefixItems": [
145 { "type": "string" }
146 ],
147 "allOf": [
148 {
149 "prefixItems": [
150 true,
151 { "type": "number" }
152 ]
153 }
154 ],
155 "unevaluatedItems": false
156 },
157 "tests": [
158 {
159 "description": "with no unevaluated items",
160 "data": ["foo", 42],
161 "valid": true
162 },
163 {
164 "description": "with unevaluated items",
165 "data": ["foo", 42, true],
166 "valid": false
167 }
168 ]
169 },
170 {
171 "description": "unevaluatedItems with nested items",
172 "schema": {
173 "$schema": "https://json-schema.org/draft/2020-12/schema",
174 "unevaluatedItems": {"type": "boolean"},
175 "anyOf": [
176 { "items": {"type": "string"} },
177 true
178 ]
179 },
180 "tests": [
181 {
182 "description": "with only (valid) additional items",
183 "data": [true, false],
184 "valid": true
185 },
186 {
187 "description": "with no additional items",
188 "data": ["yes", "no"],
189 "valid": true
190 },
191 {
192 "description": "with invalid additional item",
193 "data": ["yes", false],
194 "valid": false
195 }
196 ]
197 },
198 {
199 "description": "unevaluatedItems with nested prefixItems and items",
200 "schema": {
201 "$schema": "https://json-schema.org/draft/2020-12/schema",
202 "allOf": [
203 {
204 "prefixItems": [
205 { "type": "string" }
206 ],
207 "items": true
208 }
209 ],
210 "unevaluatedItems": false
211 },
212 "tests": [
213 {
214 "description": "with no additional items",
215 "data": ["foo"],
216 "valid": true
217 },
218 {
219 "description": "with additional items",
220 "data": ["foo", 42, true],
221 "valid": true
222 }
223 ]
224 },
225 {
226 "description": "unevaluatedItems with nested unevaluatedItems",
227 "schema": {
228 "$schema": "https://json-schema.org/draft/2020-12/schema",
229 "allOf": [
230 {
231 "prefixItems": [
232 { "type": "string" }
233 ]
234 },
235 { "unevaluatedItems": true }
236 ],
237 "unevaluatedItems": false
238 },
239 "tests": [
240 {
241 "description": "with no additional items",
242 "data": ["foo"],
243 "valid": true
244 },
245 {
246 "description": "with additional items",
247 "data": ["foo", 42, true],
248 "valid": true
249 }
250 ]
251 },
252 {
253 "description": "unevaluatedItems with anyOf",
254 "schema": {
255 "$schema": "https://json-schema.org/draft/2020-12/schema",
256 "prefixItems": [
257 { "const": "foo" }
258 ],
259 "anyOf": [
260 {
261 "prefixItems": [
262 true,
263 { "const": "bar" }
264 ]
265 },
266 {
267 "prefixItems": [
268 true,
269 true,
270 { "const": "baz" }
271 ]
272 }
273 ],
274 "unevaluatedItems": false
275 },
276 "tests": [
277 {
278 "description": "when one schema matches and has no unevaluated items",
279 "data": ["foo", "bar"],
280 "valid": true
281 },
282 {
283 "description": "when one schema matches and has unevaluated items",
284 "data": ["foo", "bar", 42],
285 "valid": false
286 },
287 {
288 "description": "when two schemas match and has no unevaluated items",
289 "data": ["foo", "bar", "baz"],
290 "valid": true
291 },
292 {
293 "description": "when two schemas match and has unevaluated items",
294 "data": ["foo", "bar", "baz", 42],
295 "valid": false
296 }
297 ]
298 },
299 {
300 "description": "unevaluatedItems with oneOf",
301 "schema": {
302 "$schema": "https://json-schema.org/draft/2020-12/schema",
303 "prefixItems": [
304 { "const": "foo" }
305 ],
306 "oneOf": [
307 {
308 "prefixItems": [
309 true,
310 { "const": "bar" }
311 ]
312 },
313 {
314 "prefixItems": [
315 true,
316 { "const": "baz" }
317 ]
318 }
319 ],
320 "unevaluatedItems": false
321 },
322 "tests": [
323 {
324 "description": "with no unevaluated items",
325 "data": ["foo", "bar"],
326 "valid": true
327 },
328 {
329 "description": "with unevaluated items",
330 "data": ["foo", "bar", 42],
331 "valid": false
332 }
333 ]
334 },
335 {
336 "description": "unevaluatedItems with not",
337 "schema": {
338 "$schema": "https://json-schema.org/draft/2020-12/schema",
339 "prefixItems": [
340 { "const": "foo" }
341 ],
342 "not": {
343 "not": {
344 "prefixItems": [
345 true,
346 { "const": "bar" }
347 ]
348 }
349 },
350 "unevaluatedItems": false
351 },
352 "tests": [
353 {
354 "description": "with unevaluated items",
355 "data": ["foo", "bar"],
356 "valid": false
357 }
358 ]
359 },
360 {
361 "description": "unevaluatedItems with if/then/else",
362 "schema": {
363 "$schema": "https://json-schema.org/draft/2020-12/schema",
364 "prefixItems": [
365 { "const": "foo" }
366 ],
367 "if": {
368 "prefixItems": [
369 true,
370 { "const": "bar" }
371 ]
372 },
373 "then": {
374 "prefixItems": [
375 true,
376 true,
377 { "const": "then" }
378 ]
379 },
380 "else": {
381 "prefixItems": [
382 true,
383 true,
384 true,
385 { "const": "else" }
386 ]
387 },
388 "unevaluatedItems": false
389 },
390 "tests": [
391 {
392 "description": "when if matches and it has no unevaluated items",
393 "data": ["foo", "bar", "then"],
394 "valid": true
395 },
396 {
397 "description": "when if matches and it has unevaluated items",
398 "data": ["foo", "bar", "then", "else"],
399 "valid": false
400 },
401 {
402 "description": "when if doesn't match and it has no unevaluated items",
403 "data": ["foo", 42, 42, "else"],
404 "valid": true
405 },
406 {
407 "description": "when if doesn't match and it has unevaluated items",
408 "data": ["foo", 42, 42, "else", 42],
409 "valid": false
410 }
411 ]
412 },
413 {
414 "description": "unevaluatedItems with boolean schemas",
415 "schema": {
416 "$schema": "https://json-schema.org/draft/2020-12/schema",
417 "allOf": [true],
418 "unevaluatedItems": false
419 },
420 "tests": [
421 {
422 "description": "with no unevaluated items",
423 "data": [],
424 "valid": true
425 },
426 {
427 "description": "with unevaluated items",
428 "data": ["foo"],
429 "valid": false
430 }
431 ]
432 },
433 {
434 "description": "unevaluatedItems with $ref",
435 "schema": {
436 "$schema": "https://json-schema.org/draft/2020-12/schema",
437 "$ref": "#/$defs/bar",
438 "prefixItems": [
439 { "type": "string" }
440 ],
441 "unevaluatedItems": false,
442 "$defs": {
443 "bar": {
444 "prefixItems": [
445 true,
446 { "type": "string" }
447 ]
448 }
449 }
450 },
451 "tests": [
452 {
453 "description": "with no unevaluated items",
454 "data": ["foo", "bar"],
455 "valid": true
456 },
457 {
458 "description": "with unevaluated items",
459 "data": ["foo", "bar", "baz"],
460 "valid": false
461 }
462 ]
463 },
464 {
465 "description": "unevaluatedItems before $ref",
466 "schema": {
467 "$schema": "https://json-schema.org/draft/2020-12/schema",
468 "unevaluatedItems": false,
469 "prefixItems": [
470 { "type": "string" }
471 ],
472 "$ref": "#/$defs/bar",
473 "$defs": {
474 "bar": {
475 "prefixItems": [
476 true,
477 { "type": "string" }
478 ]
479 }
480 }
481 },
482 "tests": [
483 {
484 "description": "with no unevaluated items",
485 "data": ["foo", "bar"],
486 "valid": true
487 },
488 {
489 "description": "with unevaluated items",
490 "data": ["foo", "bar", "baz"],
491 "valid": false
492 }
493 ]
494 },
495 {
496 "description": "unevaluatedItems with $dynamicRef",
497 "schema": {
498 "$schema": "https://json-schema.org/draft/2020-12/schema",
499 "$id": "https://example.com/unevaluated-items-with-dynamic-ref/derived",
500
501 "$ref": "./baseSchema",
502
503 "$defs": {
504 "derived": {
505 "$dynamicAnchor": "addons",
506 "prefixItems": [
507 true,
508 { "type": "string" }
509 ]
510 },
511 "baseSchema": {
512 "$id": "./baseSchema",
513
514 "$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
515 "unevaluatedItems": false,
516 "type": "array",
517 "prefixItems": [
518 { "type": "string" }
519 ],
520 "$dynamicRef": "#addons",
521
522 "$defs": {
523 "defaultAddons": {
524 "$comment": "Needed to satisfy the bookending requirement",
525 "$dynamicAnchor": "addons"
526 }
527 }
528 }
529 }
530 },
531 "tests": [
532 {
533 "description": "with no unevaluated items",
534 "data": ["foo", "bar"],
535 "valid": true
536 },
537 {
538 "description": "with unevaluated items",
539 "data": ["foo", "bar", "baz"],
540 "valid": false
541 }
542 ]
543 },
544 {
545 "description": "unevaluatedItems can't see inside cousins",
546 "schema": {
547 "$schema": "https://json-schema.org/draft/2020-12/schema",
548 "allOf": [
549 {
550 "prefixItems": [ true ]
551 },
552 { "unevaluatedItems": false }
553 ]
554 },
555 "tests": [
556 {
557 "description": "always fails",
558 "data": [ 1 ],
559 "valid": false
560 }
561 ]
562 },
563 {
564 "description": "item is evaluated in an uncle schema to unevaluatedItems",
565 "schema": {
566 "$schema": "https://json-schema.org/draft/2020-12/schema",
567 "properties": {
568 "foo": {
569 "prefixItems": [
570 { "type": "string" }
571 ],
572 "unevaluatedItems": false
573 }
574 },
575 "anyOf": [
576 {
577 "properties": {
578 "foo": {
579 "prefixItems": [
580 true,
581 { "type": "string" }
582 ]
583 }
584 }
585 }
586 ]
587 },
588 "tests": [
589 {
590 "description": "no extra items",
591 "data": {
592 "foo": [
593 "test"
594 ]
595 },
596 "valid": true
597 },
598 {
599 "description": "uncle keyword evaluation is not significant",
600 "data": {
601 "foo": [
602 "test",
603 "test"
604 ]
605 },
606 "valid": false
607 }
608 ]
609 },
610 {
611 "description": "unevaluatedItems depends on adjacent contains",
612 "schema": {
613 "$schema": "https://json-schema.org/draft/2020-12/schema",
614 "prefixItems": [true],
615 "contains": {"type": "string"},
616 "unevaluatedItems": false
617 },
618 "tests": [
619 {
620 "description": "second item is evaluated by contains",
621 "data": [ 1, "foo" ],
622 "valid": true
623 },
624 {
625 "description": "contains fails, second item is not evaluated",
626 "data": [ 1, 2 ],
627 "valid": false
628 },
629 {
630 "description": "contains passes, second item is not evaluated",
631 "data": [ 1, 2, "foo" ],
632 "valid": false
633 }
634 ]
635 },
636 {
637 "description": "unevaluatedItems depends on multiple nested contains",
638 "schema": {
639 "$schema": "https://json-schema.org/draft/2020-12/schema",
640 "allOf": [
641 { "contains": { "multipleOf": 2 } },
642 { "contains": { "multipleOf": 3 } }
643 ],
644 "unevaluatedItems": { "multipleOf": 5 }
645 },
646 "tests": [
647 {
648 "description": "5 not evaluated, passes unevaluatedItems",
649 "data": [ 2, 3, 4, 5, 6 ],
650 "valid": true
651 },
652 {
653 "description": "7 not evaluated, fails unevaluatedItems",
654 "data": [ 2, 3, 4, 7, 8 ],
655 "valid": false
656 }
657 ]
658 },
659 {
660 "description": "unevaluatedItems and contains interact to control item dependency relationship",
661 "schema": {
662 "$schema": "https://json-schema.org/draft/2020-12/schema",
663 "if": {
664 "contains": {"const": "a"}
665 },
666 "then": {
667 "if": {
668 "contains": {"const": "b"}
669 },
670 "then": {
671 "if": {
672 "contains": {"const": "c"}
673 }
674 }
675 },
676 "unevaluatedItems": false
677 },
678 "tests": [
679 {
680 "description": "empty array is valid",
681 "data": [],
682 "valid": true
683 },
684 {
685 "description": "only a's are valid",
686 "data": [ "a", "a" ],
687 "valid": true
688 },
689 {
690 "description": "a's and b's are valid",
691 "data": [ "a", "b", "a", "b", "a" ],
692 "valid": true
693 },
694 {
695 "description": "a's, b's and c's are valid",
696 "data": [ "c", "a", "c", "c", "b", "a" ],
697 "valid": true
698 },
699 {
700 "description": "only b's are invalid",
701 "data": [ "b", "b" ],
702 "valid": false
703 },
704 {
705 "description": "only c's are invalid",
706 "data": [ "c", "c" ],
707 "valid": false
708 },
709 {
710 "description": "only b's and c's are invalid",
711 "data": [ "c", "b", "c", "b", "c" ],
712 "valid": false
713 },
714 {
715 "description": "only a's and c's are invalid",
716 "data": [ "c", "a", "c", "a", "c" ],
717 "valid": false
718 }
719 ]
720 },
721 {
722 "description" : "unevaluatedItems with minContains = 0",
723 "schema" : {
724 "$schema": "https://json-schema.org/draft/2020-12/schema",
725 "contains": {"type": "string"},
726 "minContains": 0,
727 "unevaluatedItems": false
728 },
729 "tests" : [
730 {
731 "description": "empty array is valid",
732 "data": [],
733 "valid": true
734 },
735 {
736 "description": "no items evaluated by contains",
737 "data": [0],
738 "valid": false
739 },
740 {
741 "description": "some but not all items evaluated by contains",
742 "data": ["foo", 0],
743 "valid": false
744 },
745 {
746 "description": "all items evaluated by contains",
747 "data": ["foo", "bar"],
748 "valid": true
749 }
750 ]
751 },
752 {
753 "description": "non-array instances are valid",
754 "schema": {
755 "$schema": "https://json-schema.org/draft/2020-12/schema",
756 "unevaluatedItems": false
757 },
758 "tests": [
759 {
760 "description": "ignores booleans",
761 "data": true,
762 "valid": true
763 },
764 {
765 "description": "ignores integers",
766 "data": 123,
767 "valid": true
768 },
769 {
770 "description": "ignores floats",
771 "data": 1.0,
772 "valid": true
773 },
774 {
775 "description": "ignores objects",
776 "data": {},
777 "valid": true
778 },
779 {
780 "description": "ignores strings",
781 "data": "foo",
782 "valid": true
783 },
784 {
785 "description": "ignores null",
786 "data": null,
787 "valid": true
788 }
789 ]
790 },
791 {
792 "description": "unevaluatedItems with null instance elements",
793 "schema": {
794 "$schema": "https://json-schema.org/draft/2020-12/schema",
795 "unevaluatedItems": {
796 "type": "null"
797 }
798 },
799 "tests": [
800 {
801 "description": "allows null elements",
802 "data": [ null ],
803 "valid": true
804 }
805 ]
806 },
807 {
808 "description": "unevaluatedItems can see annotations from if without then and else",
809 "schema": {
810 "$schema": "https://json-schema.org/draft/2020-12/schema",
811 "if": {
812 "prefixItems": [{"const": "a"}]
813 },
814 "unevaluatedItems": false
815 },
816 "tests": [
817 {
818 "description": "valid in case if is evaluated",
819 "data": [ "a" ],
820 "valid": true
821 },
822 {
823 "description": "invalid in case if is evaluated",
824 "data": [ "b" ],
825 "valid": false
826 }
827 ]
828 },
829 {
830 "description": "Evaluated items collection needs to consider instance location",
831 "schema": {
832 "$schema": "https://json-schema.org/draft/2020-12/schema",
833 "prefixItems": [
834 {
835 "prefixItems": [
836 true,
837 { "type": "string" }
838 ]
839 }
840 ],
841 "unevaluatedItems": false
842 },
843 "tests": [
844 {
845 "description": "with an unevaluated item that exists at another location",
846 "data": [
847 ["foo", "bar"],
848 "bar"
849 ],
850 "valid": false
851 }
852 ]
853 }
854 ]