Debian Codegraph @

share/tests/v1/unevaluatedItems.json

raw
1 [
2 {
3 "description": "unevaluatedItems true",
4 "schema": {
5 "$schema": "https://json-schema.org/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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/v1",
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 }
523 },
524 "tests": [
525 {
526 "description": "with no unevaluated items",
527 "data": ["foo", "bar"],
528 "valid": true
529 },
530 {
531 "description": "with unevaluated items",
532 "data": ["foo", "bar", "baz"],
533 "valid": false
534 }
535 ]
536 },
537 {
538 "description": "unevaluatedItems can't see inside cousins",
539 "schema": {
540 "$schema": "https://json-schema.org/v1",
541 "allOf": [
542 {
543 "prefixItems": [ true ]
544 },
545 { "unevaluatedItems": false }
546 ]
547 },
548 "tests": [
549 {
550 "description": "always fails",
551 "data": [ 1 ],
552 "valid": false
553 }
554 ]
555 },
556 {
557 "description": "item is evaluated in an uncle schema to unevaluatedItems",
558 "schema": {
559 "$schema": "https://json-schema.org/v1",
560 "properties": {
561 "foo": {
562 "prefixItems": [
563 { "type": "string" }
564 ],
565 "unevaluatedItems": false
566 }
567 },
568 "anyOf": [
569 {
570 "properties": {
571 "foo": {
572 "prefixItems": [
573 true,
574 { "type": "string" }
575 ]
576 }
577 }
578 }
579 ]
580 },
581 "tests": [
582 {
583 "description": "no extra items",
584 "data": {
585 "foo": [
586 "test"
587 ]
588 },
589 "valid": true
590 },
591 {
592 "description": "uncle keyword evaluation is not significant",
593 "data": {
594 "foo": [
595 "test",
596 "test"
597 ]
598 },
599 "valid": false
600 }
601 ]
602 },
603 {
604 "description": "unevaluatedItems depends on adjacent contains",
605 "schema": {
606 "$schema": "https://json-schema.org/v1",
607 "prefixItems": [true],
608 "contains": {"type": "string"},
609 "unevaluatedItems": false
610 },
611 "tests": [
612 {
613 "description": "second item is evaluated by contains",
614 "data": [ 1, "foo" ],
615 "valid": true
616 },
617 {
618 "description": "contains fails, second item is not evaluated",
619 "data": [ 1, 2 ],
620 "valid": false
621 },
622 {
623 "description": "contains passes, second item is not evaluated",
624 "data": [ 1, 2, "foo" ],
625 "valid": false
626 }
627 ]
628 },
629 {
630 "description": "unevaluatedItems depends on multiple nested contains",
631 "schema": {
632 "$schema": "https://json-schema.org/v1",
633 "allOf": [
634 { "contains": { "multipleOf": 2 } },
635 { "contains": { "multipleOf": 3 } }
636 ],
637 "unevaluatedItems": { "multipleOf": 5 }
638 },
639 "tests": [
640 {
641 "description": "5 not evaluated, passes unevaluatedItems",
642 "data": [ 2, 3, 4, 5, 6 ],
643 "valid": true
644 },
645 {
646 "description": "7 not evaluated, fails unevaluatedItems",
647 "data": [ 2, 3, 4, 7, 8 ],
648 "valid": false
649 }
650 ]
651 },
652 {
653 "description": "unevaluatedItems and contains interact to control item dependency relationship",
654 "schema": {
655 "$schema": "https://json-schema.org/v1",
656 "if": {
657 "contains": {"const": "a"}
658 },
659 "then": {
660 "if": {
661 "contains": {"const": "b"}
662 },
663 "then": {
664 "if": {
665 "contains": {"const": "c"}
666 }
667 }
668 },
669 "unevaluatedItems": false
670 },
671 "tests": [
672 {
673 "description": "empty array is valid",
674 "data": [],
675 "valid": true
676 },
677 {
678 "description": "only a's are valid",
679 "data": [ "a", "a" ],
680 "valid": true
681 },
682 {
683 "description": "a's and b's are valid",
684 "data": [ "a", "b", "a", "b", "a" ],
685 "valid": true
686 },
687 {
688 "description": "a's, b's and c's are valid",
689 "data": [ "c", "a", "c", "c", "b", "a" ],
690 "valid": true
691 },
692 {
693 "description": "only b's are invalid",
694 "data": [ "b", "b" ],
695 "valid": false
696 },
697 {
698 "description": "only c's are invalid",
699 "data": [ "c", "c" ],
700 "valid": false
701 },
702 {
703 "description": "only b's and c's are invalid",
704 "data": [ "c", "b", "c", "b", "c" ],
705 "valid": false
706 },
707 {
708 "description": "only a's and c's are invalid",
709 "data": [ "c", "a", "c", "a", "c" ],
710 "valid": false
711 }
712 ]
713 },
714 {
715 "description" : "unevaluatedItems with minContains = 0",
716 "schema" : {
717 "$schema": "https://json-schema.org/v1",
718 "contains": {"type": "string"},
719 "minContains": 0,
720 "unevaluatedItems": false
721 },
722 "tests" : [
723 {
724 "description": "empty array is valid",
725 "data": [],
726 "valid": true
727 },
728 {
729 "description": "no items evaluated by contains",
730 "data": [0],
731 "valid": false
732 },
733 {
734 "description": "some but not all items evaluated by contains",
735 "data": ["foo", 0],
736 "valid": false
737 },
738 {
739 "description": "all items evaluated by contains",
740 "data": ["foo", "bar"],
741 "valid": true
742 }
743 ]
744 },
745 {
746 "description": "non-array instances are valid",
747 "schema": {
748 "$schema": "https://json-schema.org/v1",
749 "unevaluatedItems": false
750 },
751 "tests": [
752 {
753 "description": "ignores booleans",
754 "data": true,
755 "valid": true
756 },
757 {
758 "description": "ignores integers",
759 "data": 123,
760 "valid": true
761 },
762 {
763 "description": "ignores floats",
764 "data": 1.0,
765 "valid": true
766 },
767 {
768 "description": "ignores objects",
769 "data": {},
770 "valid": true
771 },
772 {
773 "description": "ignores strings",
774 "data": "foo",
775 "valid": true
776 },
777 {
778 "description": "ignores null",
779 "data": null,
780 "valid": true
781 }
782 ]
783 },
784 {
785 "description": "unevaluatedItems with null instance elements",
786 "schema": {
787 "$schema": "https://json-schema.org/v1",
788 "unevaluatedItems": {
789 "type": "null"
790 }
791 },
792 "tests": [
793 {
794 "description": "allows null elements",
795 "data": [ null ],
796 "valid": true
797 }
798 ]
799 },
800 {
801 "description": "unevaluatedItems can see annotations from if without then and else",
802 "schema": {
803 "$schema": "https://json-schema.org/v1",
804 "if": {
805 "prefixItems": [{"const": "a"}]
806 },
807 "unevaluatedItems": false
808 },
809 "tests": [
810 {
811 "description": "valid in case if is evaluated",
812 "data": [ "a" ],
813 "valid": true
814 },
815 {
816 "description": "invalid in case if is evaluated",
817 "data": [ "b" ],
818 "valid": false
819 }
820
821 ]
822 },
823 {
824 "description": "Evaluated items collection needs to consider instance location",
825 "schema": {
826 "$schema": "https://json-schema.org/v1",
827 "prefixItems": [
828 {
829 "prefixItems": [
830 true,
831 { "type": "string" }
832 ]
833 }
834 ],
835 "unevaluatedItems": false
836 },
837 "tests": [
838 {
839 "description": "with an unevaluated item that exists at another location",
840 "data": [
841 ["foo", "bar"],
842 "bar"
843 ],
844 "valid": false
845 }
846 ]
847 }
848 ]