1[ 2 { 3 "description": "unevaluatedProperties true", 4 "schema": { 5 "$schema": "https://json-schema.org/draft/2020-12/schema", 6 "type": "object", 7 "unevaluatedProperties": true 8 }, 9 "tests": [ 10 { 11 "description": "with no unevaluated properties", 12 "data": {}, 13 "valid": true 14 }, 15 { 16 "description": "with unevaluated properties", 17 "data": { 18 "foo": "foo" 19 }, 20 "valid": true 21 } 22 ] 23 }, 24 { 25 "description": "unevaluatedProperties schema", 26 "schema": { 27 "$schema": "https://json-schema.org/draft/2020-12/schema", 28 "type": "object", 29 "unevaluatedProperties": { 30 "type": "string", 31 "minLength": 3 32 } 33 }, 34 "tests": [ 35 { 36 "description": "with no unevaluated properties", 37 "data": {}, 38 "valid": true 39 }, 40 { 41 "description": "with valid unevaluated properties", 42 "data": { 43 "foo": "foo" 44 }, 45 "valid": true 46 }, 47 { 48 "description": "with invalid unevaluated properties", 49 "data": { 50 "foo": "fo" 51 }, 52 "valid": false 53 } 54 ] 55 }, 56 { 57 "description": "unevaluatedProperties false", 58 "schema": { 59 "$schema": "https://json-schema.org/draft/2020-12/schema", 60 "type": "object", 61 "unevaluatedProperties": false 62 }, 63 "tests": [ 64 { 65 "description": "with no unevaluated properties", 66 "data": {}, 67 "valid": true 68 }, 69 { 70 "description": "with unevaluated properties", 71 "data": { 72 "foo": "foo" 73 }, 74 "valid": false 75 } 76 ] 77 }, 78 { 79 "description": "unevaluatedProperties with adjacent properties", 80 "schema": { 81 "$schema": "https://json-schema.org/draft/2020-12/schema", 82 "type": "object", 83 "properties": { 84 "foo": { "type": "string" } 85 }, 86 "unevaluatedProperties": false 87 }, 88 "tests": [ 89 { 90 "description": "with no unevaluated properties", 91 "data": { 92 "foo": "foo" 93 }, 94 "valid": true 95 }, 96 { 97 "description": "with unevaluated properties", 98 "data": { 99 "foo": "foo", 100 "bar": "bar" 101 }, 102 "valid": false 103 } 104 ] 105 }, 106 { 107 "description": "unevaluatedProperties with adjacent patternProperties", 108 "schema": { 109 "$schema": "https://json-schema.org/draft/2020-12/schema", 110 "type": "object", 111 "patternProperties": { 112 "^foo": { "type": "string" } 113 }, 114 "unevaluatedProperties": false 115 }, 116 "tests": [ 117 { 118 "description": "with no unevaluated properties", 119 "data": { 120 "foo": "foo" 121 }, 122 "valid": true 123 }, 124 { 125 "description": "with unevaluated properties", 126 "data": { 127 "foo": "foo", 128 "bar": "bar" 129 }, 130 "valid": false 131 } 132 ] 133 }, 134 { 135 "description": "unevaluatedProperties with adjacent additionalProperties", 136 "schema": { 137 "$schema": "https://json-schema.org/draft/2020-12/schema", 138 "type": "object", 139 "properties": { 140 "foo": { "type": "string" } 141 }, 142 "additionalProperties": true, 143 "unevaluatedProperties": false 144 }, 145 "tests": [ 146 { 147 "description": "with no additional properties", 148 "data": { 149 "foo": "foo" 150 }, 151 "valid": true 152 }, 153 { 154 "description": "with additional properties", 155 "data": { 156 "foo": "foo", 157 "bar": "bar" 158 }, 159 "valid": true 160 } 161 ] 162 }, 163 { 164 "description": "unevaluatedProperties with nested properties", 165 "schema": { 166 "$schema": "https://json-schema.org/draft/2020-12/schema", 167 "type": "object", 168 "properties": { 169 "foo": { "type": "string" } 170 }, 171 "allOf": [ 172 { 173 "properties": { 174 "bar": { "type": "string" } 175 } 176 } 177 ], 178 "unevaluatedProperties": false 179 }, 180 "tests": [ 181 { 182 "description": "with no additional properties", 183 "data": { 184 "foo": "foo", 185 "bar": "bar" 186 }, 187 "valid": true 188 }, 189 { 190 "description": "with additional properties", 191 "data": { 192 "foo": "foo", 193 "bar": "bar", 194 "baz": "baz" 195 }, 196 "valid": false 197 } 198 ] 199 }, 200 { 201 "description": "unevaluatedProperties with nested patternProperties", 202 "schema": { 203 "$schema": "https://json-schema.org/draft/2020-12/schema", 204 "type": "object", 205 "properties": { 206 "foo": { "type": "string" } 207 }, 208 "allOf": [ 209 { 210 "patternProperties": { 211 "^bar": { "type": "string" } 212 } 213 } 214 ], 215 "unevaluatedProperties": false 216 }, 217 "tests": [ 218 { 219 "description": "with no additional properties", 220 "data": { 221 "foo": "foo", 222 "bar": "bar" 223 }, 224 "valid": true 225 }, 226 { 227 "description": "with additional properties", 228 "data": { 229 "foo": "foo", 230 "bar": "bar", 231 "baz": "baz" 232 }, 233 "valid": false 234 } 235 ] 236 }, 237 { 238 "description": "unevaluatedProperties with nested additionalProperties", 239 "schema": { 240 "$schema": "https://json-schema.org/draft/2020-12/schema", 241 "type": "object", 242 "properties": { 243 "foo": { "type": "string" } 244 }, 245 "allOf": [ 246 { 247 "additionalProperties": true 248 } 249 ], 250 "unevaluatedProperties": false 251 }, 252 "tests": [ 253 { 254 "description": "with no additional properties", 255 "data": { 256 "foo": "foo" 257 }, 258 "valid": true 259 }, 260 { 261 "description": "with additional properties", 262 "data": { 263 "foo": "foo", 264 "bar": "bar" 265 }, 266 "valid": true 267 } 268 ] 269 }, 270 { 271 "description": "unevaluatedProperties with nested unevaluatedProperties", 272 "schema": { 273 "$schema": "https://json-schema.org/draft/2020-12/schema", 274 "type": "object", 275 "properties": { 276 "foo": { "type": "string" } 277 }, 278 "allOf": [ 279 { 280 "unevaluatedProperties": true 281 } 282 ], 283 "unevaluatedProperties": { 284 "type": "string", 285 "maxLength": 2 286 } 287 }, 288 "tests": [ 289 { 290 "description": "with no nested unevaluated properties", 291 "data": { 292 "foo": "foo" 293 }, 294 "valid": true 295 }, 296 { 297 "description": "with nested unevaluated properties", 298 "data": { 299 "foo": "foo", 300 "bar": "bar" 301 }, 302 "valid": true 303 } 304 ] 305 }, 306 { 307 "description": "unevaluatedProperties with anyOf", 308 "schema": { 309 "$schema": "https://json-schema.org/draft/2020-12/schema", 310 "type": "object", 311 "properties": { 312 "foo": { "type": "string" } 313 }, 314 "anyOf": [ 315 { 316 "properties": { 317 "bar": { "const": "bar" } 318 }, 319 "required": ["bar"] 320 }, 321 { 322 "properties": { 323 "baz": { "const": "baz" } 324 }, 325 "required": ["baz"] 326 }, 327 { 328 "properties": { 329 "quux": { "const": "quux" } 330 }, 331 "required": ["quux"] 332 } 333 ], 334 "unevaluatedProperties": false 335 }, 336 "tests": [ 337 { 338 "description": "when one matches and has no unevaluated properties", 339 "data": { 340 "foo": "foo", 341 "bar": "bar" 342 }, 343 "valid": true 344 }, 345 { 346 "description": "when one matches and has unevaluated properties", 347 "data": { 348 "foo": "foo", 349 "bar": "bar", 350 "baz": "not-baz" 351 }, 352 "valid": false 353 }, 354 { 355 "description": "when two match and has no unevaluated properties", 356 "data": { 357 "foo": "foo", 358 "bar": "bar", 359 "baz": "baz" 360 }, 361 "valid": true 362 }, 363 { 364 "description": "when two match and has unevaluated properties", 365 "data": { 366 "foo": "foo", 367 "bar": "bar", 368 "baz": "baz", 369 "quux": "not-quux" 370 }, 371 "valid": false 372 } 373 ] 374 }, 375 { 376 "description": "unevaluatedProperties with oneOf", 377 "schema": { 378 "$schema": "https://json-schema.org/draft/2020-12/schema", 379 "type": "object", 380 "properties": { 381 "foo": { "type": "string" } 382 }, 383 "oneOf": [ 384 { 385 "properties": { 386 "bar": { "const": "bar" } 387 }, 388 "required": ["bar"] 389 }, 390 { 391 "properties": { 392 "baz": { "const": "baz" } 393 }, 394 "required": ["baz"] 395 } 396 ], 397 "unevaluatedProperties": false 398 }, 399 "tests": [ 400 { 401 "description": "with no unevaluated properties", 402 "data": { 403 "foo": "foo", 404 "bar": "bar" 405 }, 406 "valid": true 407 }, 408 { 409 "description": "with unevaluated properties", 410 "data": { 411 "foo": "foo", 412 "bar": "bar", 413 "quux": "quux" 414 }, 415 "valid": false 416 } 417 ] 418 }, 419 { 420 "description": "unevaluatedProperties with not", 421 "schema": { 422 "$schema": "https://json-schema.org/draft/2020-12/schema", 423 "type": "object", 424 "properties": { 425 "foo": { "type": "string" } 426 }, 427 "not": { 428 "not": { 429 "properties": { 430 "bar": { "const": "bar" } 431 }, 432 "required": ["bar"] 433 } 434 }, 435 "unevaluatedProperties": false 436 }, 437 "tests": [ 438 { 439 "description": "with unevaluated properties", 440 "data": { 441 "foo": "foo", 442 "bar": "bar" 443 }, 444 "valid": false 445 } 446 ] 447 }, 448 { 449 "description": "unevaluatedProperties with if/then/else", 450 "schema": { 451 "$schema": "https://json-schema.org/draft/2020-12/schema", 452 "type": "object", 453 "if": { 454 "properties": { 455 "foo": { "const": "then" } 456 }, 457 "required": ["foo"] 458 }, 459 "then": { 460 "properties": { 461 "bar": { "type": "string" } 462 }, 463 "required": ["bar"] 464 }, 465 "else": { 466 "properties": { 467 "baz": { "type": "string" } 468 }, 469 "required": ["baz"] 470 }, 471 "unevaluatedProperties": false 472 }, 473 "tests": [ 474 { 475 "description": "when if is true and has no unevaluated properties", 476 "data": { 477 "foo": "then", 478 "bar": "bar" 479 }, 480 "valid": true 481 }, 482 { 483 "description": "when if is true and has unevaluated properties", 484 "data": { 485 "foo": "then", 486 "bar": "bar", 487 "baz": "baz" 488 }, 489 "valid": false 490 }, 491 { 492 "description": "when if is false and has no unevaluated properties", 493 "data": { 494 "baz": "baz" 495 }, 496 "valid": true 497 }, 498 { 499 "description": "when if is false and has unevaluated properties", 500 "data": { 501 "foo": "else", 502 "baz": "baz" 503 }, 504 "valid": false 505 } 506 ] 507 }, 508 { 509 "description": "unevaluatedProperties with if/then/else, then not defined", 510 "schema": { 511 "$schema": "https://json-schema.org/draft/2020-12/schema", 512 "type": "object", 513 "if": { 514 "properties": { 515 "foo": { "const": "then" } 516 }, 517 "required": ["foo"] 518 }, 519 "else": { 520 "properties": { 521 "baz": { "type": "string" } 522 }, 523 "required": ["baz"] 524 }, 525 "unevaluatedProperties": false 526 }, 527 "tests": [ 528 { 529 "description": "when if is true and has no unevaluated properties", 530 "data": { 531 "foo": "then", 532 "bar": "bar" 533 }, 534 "valid": false 535 }, 536 { 537 "description": "when if is true and has unevaluated properties", 538 "data": { 539 "foo": "then", 540 "bar": "bar", 541 "baz": "baz" 542 }, 543 "valid": false 544 }, 545 { 546 "description": "when if is false and has no unevaluated properties", 547 "data": { 548 "baz": "baz" 549 }, 550 "valid": true 551 }, 552 { 553 "description": "when if is false and has unevaluated properties", 554 "data": { 555 "foo": "else", 556 "baz": "baz" 557 }, 558 "valid": false 559 } 560 ] 561 }, 562 { 563 "description": "unevaluatedProperties with if/then/else, else not defined", 564 "schema": { 565 "$schema": "https://json-schema.org/draft/2020-12/schema", 566 "type": "object", 567 "if": { 568 "properties": { 569 "foo": { "const": "then" } 570 }, 571 "required": ["foo"] 572 }, 573 "then": { 574 "properties": { 575 "bar": { "type": "string" } 576 }, 577 "required": ["bar"] 578 }, 579 "unevaluatedProperties": false 580 }, 581 "tests": [ 582 { 583 "description": "when if is true and has no unevaluated properties", 584 "data": { 585 "foo": "then", 586 "bar": "bar" 587 }, 588 "valid": true 589 }, 590 { 591 "description": "when if is true and has unevaluated properties", 592 "data": { 593 "foo": "then", 594 "bar": "bar", 595 "baz": "baz" 596 }, 597 "valid": false 598 }, 599 { 600 "description": "when if is false and has no unevaluated properties", 601 "data": { 602 "baz": "baz" 603 }, 604 "valid": false 605 }, 606 { 607 "description": "when if is false and has unevaluated properties", 608 "data": { 609 "foo": "else", 610 "baz": "baz" 611 }, 612 "valid": false 613 } 614 ] 615 }, 616 { 617 "description": "unevaluatedProperties with dependentSchemas", 618 "schema": { 619 "$schema": "https://json-schema.org/draft/2020-12/schema", 620 "type": "object", 621 "properties": { 622 "foo": { "type": "string" } 623 }, 624 "dependentSchemas": { 625 "foo": { 626 "properties": { 627 "bar": { "const": "bar" } 628 }, 629 "required": ["bar"] 630 } 631 }, 632 "unevaluatedProperties": false 633 }, 634 "tests": [ 635 { 636 "description": "with no unevaluated properties", 637 "data": { 638 "foo": "foo", 639 "bar": "bar" 640 }, 641 "valid": true 642 }, 643 { 644 "description": "with unevaluated properties", 645 "data": { 646 "bar": "bar" 647 }, 648 "valid": false 649 } 650 ] 651 }, 652 { 653 "description": "unevaluatedProperties with boolean schemas", 654 "schema": { 655 "$schema": "https://json-schema.org/draft/2020-12/schema", 656 "type": "object", 657 "properties": { 658 "foo": { "type": "string" } 659 }, 660 "allOf": [true], 661 "unevaluatedProperties": false 662 }, 663 "tests": [ 664 { 665 "description": "with no unevaluated properties", 666 "data": { 667 "foo": "foo" 668 }, 669 "valid": true 670 }, 671 { 672 "description": "with unevaluated properties", 673 "data": { 674 "bar": "bar" 675 }, 676 "valid": false 677 } 678 ] 679 }, 680 { 681 "description": "unevaluatedProperties with $ref", 682 "schema": { 683 "$schema": "https://json-schema.org/draft/2020-12/schema", 684 "type": "object", 685 "$ref": "#/$defs/bar", 686 "properties": { 687 "foo": { "type": "string" } 688 }, 689 "unevaluatedProperties": false, 690 "$defs": { 691 "bar": { 692 "properties": { 693 "bar": { "type": "string" } 694 } 695 } 696 } 697 }, 698 "tests": [ 699 { 700 "description": "with no unevaluated properties", 701 "data": { 702 "foo": "foo", 703 "bar": "bar" 704 }, 705 "valid": true 706 }, 707 { 708 "description": "with unevaluated properties", 709 "data": { 710 "foo": "foo", 711 "bar": "bar", 712 "baz": "baz" 713 }, 714 "valid": false 715 } 716 ] 717 }, 718 { 719 "description": "unevaluatedProperties before $ref", 720 "schema": { 721 "$schema": "https://json-schema.org/draft/2020-12/schema", 722 "type": "object", 723 "unevaluatedProperties": false, 724 "properties": { 725 "foo": { "type": "string" } 726 }, 727 "$ref": "#/$defs/bar", 728 "$defs": { 729 "bar": { 730 "properties": { 731 "bar": { "type": "string" } 732 } 733 } 734 } 735 }, 736 "tests": [ 737 { 738 "description": "with no unevaluated properties", 739 "data": { 740 "foo": "foo", 741 "bar": "bar" 742 }, 743 "valid": true 744 }, 745 { 746 "description": "with unevaluated properties", 747 "data": { 748 "foo": "foo", 749 "bar": "bar", 750 "baz": "baz" 751 }, 752 "valid": false 753 } 754 ] 755 }, 756 { 757 "description": "unevaluatedProperties with $dynamicRef", 758 "schema": { 759 "$schema": "https://json-schema.org/draft/2020-12/schema", 760 "$id": "https://example.com/unevaluated-properties-with-dynamic-ref/derived", 761 762 "$ref": "./baseSchema", 763 764 "$defs": { 765 "derived": { 766 "$dynamicAnchor": "addons", 767 "properties": { 768 "bar": { "type": "string" } 769 } 770 }, 771 "baseSchema": { 772 "$id": "./baseSchema", 773 774 "$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering", 775 "unevaluatedProperties": false, 776 "type": "object", 777 "properties": { 778 "foo": { "type": "string" } 779 }, 780 "$dynamicRef": "#addons", 781 782 "$defs": { 783 "defaultAddons": { 784 "$comment": "Needed to satisfy the bookending requirement", 785 "$dynamicAnchor": "addons" 786 } 787 } 788 } 789 } 790 }, 791 "tests": [ 792 { 793 "description": "with no unevaluated properties", 794 "data": { 795 "foo": "foo", 796 "bar": "bar" 797 }, 798 "valid": true 799 }, 800 { 801 "description": "with unevaluated properties", 802 "data": { 803 "foo": "foo", 804 "bar": "bar", 805 "baz": "baz" 806 }, 807 "valid": false 808 } 809 ] 810 }, 811 { 812 "description": "unevaluatedProperties can't see inside cousins", 813 "schema": { 814 "$schema": "https://json-schema.org/draft/2020-12/schema", 815 "allOf": [ 816 { 817 "properties": { 818 "foo": true 819 } 820 }, 821 { 822 "unevaluatedProperties": false 823 } 824 ] 825 }, 826 "tests": [ 827 { 828 "description": "always fails", 829 "data": { 830 "foo": 1 831 }, 832 "valid": false 833 } 834 ] 835 }, 836 { 837 "description": "unevaluatedProperties can't see inside cousins (reverse order)", 838 "schema": { 839 "$schema": "https://json-schema.org/draft/2020-12/schema", 840 "allOf": [ 841 { 842 "unevaluatedProperties": false 843 }, 844 { 845 "properties": { 846 "foo": true 847 } 848 } 849 ] 850 }, 851 "tests": [ 852 { 853 "description": "always fails", 854 "data": { 855 "foo": 1 856 }, 857 "valid": false 858 } 859 ] 860 }, 861 { 862 "description": "nested unevaluatedProperties, outer false, inner true, properties outside", 863 "schema": { 864 "$schema": "https://json-schema.org/draft/2020-12/schema", 865 "type": "object", 866 "properties": { 867 "foo": { "type": "string" } 868 }, 869 "allOf": [ 870 { 871 "unevaluatedProperties": true 872 } 873 ], 874 "unevaluatedProperties": false 875 }, 876 "tests": [ 877 { 878 "description": "with no nested unevaluated properties", 879 "data": { 880 "foo": "foo" 881 }, 882 "valid": true 883 }, 884 { 885 "description": "with nested unevaluated properties", 886 "data": { 887 "foo": "foo", 888 "bar": "bar" 889 }, 890 "valid": true 891 } 892 ] 893 }, 894 { 895 "description": "nested unevaluatedProperties, outer false, inner true, properties inside", 896 "schema": { 897 "$schema": "https://json-schema.org/draft/2020-12/schema", 898 "type": "object", 899 "allOf": [ 900 { 901 "properties": { 902 "foo": { "type": "string" } 903 }, 904 "unevaluatedProperties": true 905 } 906 ], 907 "unevaluatedProperties": false 908 }, 909 "tests": [ 910 { 911 "description": "with no nested unevaluated properties", 912 "data": { 913 "foo": "foo" 914 }, 915 "valid": true 916 }, 917 { 918 "description": "with nested unevaluated properties", 919 "data": { 920 "foo": "foo", 921 "bar": "bar" 922 }, 923 "valid": true 924 } 925 ] 926 }, 927 { 928 "description": "nested unevaluatedProperties, outer true, inner false, properties outside", 929 "schema": { 930 "$schema": "https://json-schema.org/draft/2020-12/schema", 931 "type": "object", 932 "properties": { 933 "foo": { "type": "string" } 934 }, 935 "allOf": [ 936 { 937 "unevaluatedProperties": false 938 } 939 ], 940 "unevaluatedProperties": true 941 }, 942 "tests": [ 943 { 944 "description": "with no nested unevaluated properties", 945 "data": { 946 "foo": "foo" 947 }, 948 "valid": false 949 }, 950 { 951 "description": "with nested unevaluated properties", 952 "data": { 953 "foo": "foo", 954 "bar": "bar" 955 }, 956 "valid": false 957 } 958 ] 959 }, 960 { 961 "description": "nested unevaluatedProperties, outer true, inner false, properties inside", 962 "schema": { 963 "$schema": "https://json-schema.org/draft/2020-12/schema", 964 "type": "object", 965 "allOf": [ 966 { 967 "properties": { 968 "foo": { "type": "string" } 969 }, 970 "unevaluatedProperties": false 971 } 972 ], 973 "unevaluatedProperties": true 974 }, 975 "tests": [ 976 { 977 "description": "with no nested unevaluated properties", 978 "data": { 979 "foo": "foo" 980 }, 981 "valid": true 982 }, 983 { 984 "description": "with nested unevaluated properties", 985 "data": { 986 "foo": "foo", 987 "bar": "bar" 988 }, 989 "valid": false 990 } 991 ] 992 }, 993 { 994 "description": "cousin unevaluatedProperties, true and false, true with properties", 995 "schema": { 996 "$schema": "https://json-schema.org/draft/2020-12/schema", 997 "type": "object", 998 "allOf": [ 999 { 1000 "properties": { 1001 "foo": { "type": "string" } 1002 }, 1003 "unevaluatedProperties": true 1004 }, 1005 { 1006 "unevaluatedProperties": false 1007 } 1008 ] 1009 }, 1010 "tests": [ 1011 { 1012 "description": "with no nested unevaluated properties", 1013 "data": { 1014 "foo": "foo" 1015 }, 1016 "valid": false 1017 }, 1018 { 1019 "description": "with nested unevaluated properties", 1020 "data": { 1021 "foo": "foo", 1022 "bar": "bar" 1023 }, 1024 "valid": false 1025 } 1026 ] 1027 }, 1028 { 1029 "description": "cousin unevaluatedProperties, true and false, false with properties", 1030 "schema": { 1031 "$schema": "https://json-schema.org/draft/2020-12/schema", 1032 "type": "object", 1033 "allOf": [ 1034 { 1035 "unevaluatedProperties": true 1036 }, 1037 { 1038 "properties": { 1039 "foo": { "type": "string" } 1040 }, 1041 "unevaluatedProperties": false 1042 } 1043 ] 1044 }, 1045 "tests": [ 1046 { 1047 "description": "with no nested unevaluated properties", 1048 "data": { 1049 "foo": "foo" 1050 }, 1051 "valid": true 1052 }, 1053 { 1054 "description": "with nested unevaluated properties", 1055 "data": { 1056 "foo": "foo", 1057 "bar": "bar" 1058 }, 1059 "valid": false 1060 } 1061 ] 1062 }, 1063 { 1064 "description": "property is evaluated in an uncle schema to unevaluatedProperties", 1065 "comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations", 1066 "schema": { 1067 "$schema": "https://json-schema.org/draft/2020-12/schema", 1068 "type": "object", 1069 "properties": { 1070 "foo": { 1071 "type": "object", 1072 "properties": { 1073 "bar": { 1074 "type": "string" 1075 } 1076 }, 1077 "unevaluatedProperties": false 1078 } 1079 }, 1080 "anyOf": [ 1081 { 1082 "properties": { 1083 "foo": { 1084 "properties": { 1085 "faz": { 1086 "type": "string" 1087 } 1088 } 1089 } 1090 } 1091 } 1092 ] 1093 }, 1094 "tests": [ 1095 { 1096 "description": "no extra properties", 1097 "data": { 1098 "foo": { 1099 "bar": "test" 1100 } 1101 }, 1102 "valid": true 1103 }, 1104 { 1105 "description": "uncle keyword evaluation is not significant", 1106 "data": { 1107 "foo": { 1108 "bar": "test", 1109 "faz": "test" 1110 } 1111 }, 1112 "valid": false 1113 } 1114 ] 1115 }, 1116 { 1117 "description": "in-place applicator siblings, allOf has unevaluated", 1118 "schema": { 1119 "$schema": "https://json-schema.org/draft/2020-12/schema", 1120 "type": "object", 1121 "allOf": [ 1122 { 1123 "properties": { 1124 "foo": true 1125 }, 1126 "unevaluatedProperties": false 1127 } 1128 ], 1129 "anyOf": [ 1130 { 1131 "properties": { 1132 "bar": true 1133 } 1134 } 1135 ] 1136 }, 1137 "tests": [ 1138 { 1139 "description": "base case: both properties present", 1140 "data": { 1141 "foo": 1, 1142 "bar": 1 1143 }, 1144 "valid": false 1145 }, 1146 { 1147 "description": "in place applicator siblings, bar is missing", 1148 "data": { 1149 "foo": 1 1150 }, 1151 "valid": true 1152 }, 1153 { 1154 "description": "in place applicator siblings, foo is missing", 1155 "data": { 1156 "bar": 1 1157 }, 1158 "valid": false 1159 } 1160 ] 1161 }, 1162 { 1163 "description": "in-place applicator siblings, anyOf has unevaluated", 1164 "schema": { 1165 "$schema": "https://json-schema.org/draft/2020-12/schema", 1166 "type": "object", 1167 "allOf": [ 1168 { 1169 "properties": { 1170 "foo": true 1171 } 1172 } 1173 ], 1174 "anyOf": [ 1175 { 1176 "properties": { 1177 "bar": true 1178 }, 1179 "unevaluatedProperties": false 1180 } 1181 ] 1182 }, 1183 "tests": [ 1184 { 1185 "description": "base case: both properties present", 1186 "data": { 1187 "foo": 1, 1188 "bar": 1 1189 }, 1190 "valid": false 1191 }, 1192 { 1193 "description": "in place applicator siblings, bar is missing", 1194 "data": { 1195 "foo": 1 1196 }, 1197 "valid": false 1198 }, 1199 { 1200 "description": "in place applicator siblings, foo is missing", 1201 "data": { 1202 "bar": 1 1203 }, 1204 "valid": true 1205 } 1206 ] 1207 }, 1208 { 1209 "description": "unevaluatedProperties + single cyclic ref", 1210 "schema": { 1211 "$schema": "https://json-schema.org/draft/2020-12/schema", 1212 "type": "object", 1213 "properties": { 1214 "x": { "$ref": "#" } 1215 }, 1216 "unevaluatedProperties": false 1217 }, 1218 "tests": [ 1219 { 1220 "description": "Empty is valid", 1221 "data": {}, 1222 "valid": true 1223 }, 1224 { 1225 "description": "Single is valid", 1226 "data": { "x": {} }, 1227 "valid": true 1228 }, 1229 { 1230 "description": "Unevaluated on 1st level is invalid", 1231 "data": { "x": {}, "y": {} }, 1232 "valid": false 1233 }, 1234 { 1235 "description": "Nested is valid", 1236 "data": { "x": { "x": {} } }, 1237 "valid": true 1238 }, 1239 { 1240 "description": "Unevaluated on 2nd level is invalid", 1241 "data": { "x": { "x": {}, "y": {} } }, 1242 "valid": false 1243 }, 1244 { 1245 "description": "Deep nested is valid", 1246 "data": { "x": { "x": { "x": {} } } }, 1247 "valid": true 1248 }, 1249 { 1250 "description": "Unevaluated on 3rd level is invalid", 1251 "data": { "x": { "x": { "x": {}, "y": {} } } }, 1252 "valid": false 1253 } 1254 ] 1255 }, 1256 { 1257 "description": "unevaluatedProperties + ref inside allOf / oneOf", 1258 "schema": { 1259 "$schema": "https://json-schema.org/draft/2020-12/schema", 1260 "$defs": { 1261 "one": { 1262 "properties": { "a": true } 1263 }, 1264 "two": { 1265 "required": ["x"], 1266 "properties": { "x": true } 1267 } 1268 }, 1269 "allOf": [ 1270 { "$ref": "#/$defs/one" }, 1271 { "properties": { "b": true } }, 1272 { 1273 "oneOf": [ 1274 { "$ref": "#/$defs/two" }, 1275 { 1276 "required": ["y"], 1277 "properties": { "y": true } 1278 } 1279 ] 1280 } 1281 ], 1282 "unevaluatedProperties": false 1283 }, 1284 "tests": [ 1285 { 1286 "description": "Empty is invalid (no x or y)", 1287 "data": {}, 1288 "valid": false 1289 }, 1290 { 1291 "description": "a and b are invalid (no x or y)", 1292 "data": { "a": 1, "b": 1 }, 1293 "valid": false 1294 }, 1295 { 1296 "description": "x and y are invalid", 1297 "data": { "x": 1, "y": 1 }, 1298 "valid": false 1299 }, 1300 { 1301 "description": "a and x are valid", 1302 "data": { "a": 1, "x": 1 }, 1303 "valid": true 1304 }, 1305 { 1306 "description": "a and y are valid", 1307 "data": { "a": 1, "y": 1 }, 1308 "valid": true 1309 }, 1310 { 1311 "description": "a and b and x are valid", 1312 "data": { "a": 1, "b": 1, "x": 1 }, 1313 "valid": true 1314 }, 1315 { 1316 "description": "a and b and y are valid", 1317 "data": { "a": 1, "b": 1, "y": 1 }, 1318 "valid": true 1319 }, 1320 { 1321 "description": "a and b and x and y are invalid", 1322 "data": { "a": 1, "b": 1, "x": 1, "y": 1 }, 1323 "valid": false 1324 } 1325 ] 1326 }, 1327 { 1328 "description": "dynamic evalation inside nested refs", 1329 "schema": { 1330 "$schema": "https://json-schema.org/draft/2020-12/schema", 1331 "$defs": { 1332 "one": { 1333 "oneOf": [ 1334 { "$ref": "#/$defs/two" }, 1335 { "required": ["b"], "properties": { "b": true } }, 1336 { "required": ["xx"], "patternProperties": { "x": true } }, 1337 { "required": ["all"], "unevaluatedProperties": true } 1338 ] 1339 }, 1340 "two": { 1341 "oneOf": [ 1342 { "required": ["c"], "properties": { "c": true } }, 1343 { "required": ["d"], "properties": { "d": true } } 1344 ] 1345 } 1346 }, 1347 "oneOf": [ 1348 { "$ref": "#/$defs/one" }, 1349 { "required": ["a"], "properties": { "a": true } } 1350 ], 1351 "unevaluatedProperties": false 1352 }, 1353 "tests": [ 1354 { 1355 "description": "Empty is invalid", 1356 "data": {}, 1357 "valid": false 1358 }, 1359 { 1360 "description": "a is valid", 1361 "data": { "a": 1 }, 1362 "valid": true 1363 }, 1364 { 1365 "description": "b is valid", 1366 "data": { "b": 1 }, 1367 "valid": true 1368 }, 1369 { 1370 "description": "c is valid", 1371 "data": { "c": 1 }, 1372 "valid": true 1373 }, 1374 { 1375 "description": "d is valid", 1376 "data": { "d": 1 }, 1377 "valid": true 1378 }, 1379 { 1380 "description": "a + b is invalid", 1381 "data": { "a": 1, "b": 1 }, 1382 "valid": false 1383 }, 1384 { 1385 "description": "a + c is invalid", 1386 "data": { "a": 1, "c": 1 }, 1387 "valid": false 1388 }, 1389 { 1390 "description": "a + d is invalid", 1391 "data": { "a": 1, "d": 1 }, 1392 "valid": false 1393 }, 1394 { 1395 "description": "b + c is invalid", 1396 "data": { "b": 1, "c": 1 }, 1397 "valid": false 1398 }, 1399 { 1400 "description": "b + d is invalid", 1401 "data": { "b": 1, "d": 1 }, 1402 "valid": false 1403 }, 1404 { 1405 "description": "c + d is invalid", 1406 "data": { "c": 1, "d": 1 }, 1407 "valid": false 1408 }, 1409 { 1410 "description": "xx is valid", 1411 "data": { "xx": 1 }, 1412 "valid": true 1413 }, 1414 { 1415 "description": "xx + foox is valid", 1416 "data": { "xx": 1, "foox": 1 }, 1417 "valid": true 1418 }, 1419 { 1420 "description": "xx + foo is invalid", 1421 "data": { "xx": 1, "foo": 1 }, 1422 "valid": false 1423 }, 1424 { 1425 "description": "xx + a is invalid", 1426 "data": { "xx": 1, "a": 1 }, 1427 "valid": false 1428 }, 1429 { 1430 "description": "xx + b is invalid", 1431 "data": { "xx": 1, "b": 1 }, 1432 "valid": false 1433 }, 1434 { 1435 "description": "xx + c is invalid", 1436 "data": { "xx": 1, "c": 1 }, 1437 "valid": false 1438 }, 1439 { 1440 "description": "xx + d is invalid", 1441 "data": { "xx": 1, "d": 1 }, 1442 "valid": false 1443 }, 1444 { 1445 "description": "all is valid", 1446 "data": { "all": 1 }, 1447 "valid": true 1448 }, 1449 { 1450 "description": "all + foo is valid", 1451 "data": { "all": 1, "foo": 1 }, 1452 "valid": true 1453 }, 1454 { 1455 "description": "all + a is invalid", 1456 "data": { "all": 1, "a": 1 }, 1457 "valid": false 1458 } 1459 ] 1460 }, 1461 { 1462 "description": "non-object instances are valid", 1463 "schema": { 1464 "$schema": "https://json-schema.org/draft/2020-12/schema", 1465 "unevaluatedProperties": false 1466 }, 1467 "tests": [ 1468 { 1469 "description": "ignores booleans", 1470 "data": true, 1471 "valid": true 1472 }, 1473 { 1474 "description": "ignores integers", 1475 "data": 123, 1476 "valid": true 1477 }, 1478 { 1479 "description": "ignores floats", 1480 "data": 1.0, 1481 "valid": true 1482 }, 1483 { 1484 "description": "ignores arrays", 1485 "data": [], 1486 "valid": true 1487 }, 1488 { 1489 "description": "ignores strings", 1490 "data": "foo", 1491 "valid": true 1492 }, 1493 { 1494 "description": "ignores null", 1495 "data": null, 1496 "valid": true 1497 } 1498 ] 1499 }, 1500 { 1501 "description": "unevaluatedProperties with null valued instance properties", 1502 "schema": { 1503 "$schema": "https://json-schema.org/draft/2020-12/schema", 1504 "unevaluatedProperties": { 1505 "type": "null" 1506 } 1507 }, 1508 "tests": [ 1509 { 1510 "description": "allows null valued properties", 1511 "data": {"foo": null}, 1512 "valid": true 1513 } 1514 ] 1515 }, 1516 { 1517 "description": "unevaluatedProperties not affected by propertyNames", 1518 "schema": { 1519 "$schema": "https://json-schema.org/draft/2020-12/schema", 1520 "propertyNames": {"maxLength": 1}, 1521 "unevaluatedProperties": { 1522 "type": "number" 1523 } 1524 }, 1525 "tests": [ 1526 { 1527 "description": "allows only number properties", 1528 "data": {"a": 1}, 1529 "valid": true 1530 }, 1531 { 1532 "description": "string property is invalid", 1533 "data": {"a": "b"}, 1534 "valid": false 1535 } 1536 ] 1537 }, 1538 { 1539 "description": "unevaluatedProperties can see annotations from if without then and else", 1540 "schema": { 1541 "$schema": "https://json-schema.org/draft/2020-12/schema", 1542 "if": { 1543 "patternProperties": { 1544 "foo": { 1545 "type": "string" 1546 } 1547 } 1548 }, 1549 "unevaluatedProperties": false 1550 }, 1551 "tests": [ 1552 { 1553 "description": "valid in case if is evaluated", 1554 "data": { 1555 "foo": "a" 1556 }, 1557 "valid": true 1558 }, 1559 { 1560 "description": "invalid in case if is evaluated", 1561 "data": { 1562 "bar": "a" 1563 }, 1564 "valid": false 1565 } 1566 ] 1567 } 1568] 1569