1[ 2 { 3 "description": "unevaluatedProperties true", 4 "schema": { 5 "$schema": "https://json-schema.org/draft/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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/2019-09/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 $recursiveRef", 758 "schema": { 759 "$schema": "https://json-schema.org/draft/2019-09/schema", 760 "$id": "https://example.com/unevaluated-properties-with-recursive-ref/extended-tree", 761 762 "$recursiveAnchor": true, 763 764 "$ref": "./tree", 765 "properties": { 766 "name": { "type": "string" } 767 }, 768 769 "$defs": { 770 "tree": { 771 "$id": "./tree", 772 "$recursiveAnchor": true, 773 774 "type": "object", 775 "properties": { 776 "node": true, 777 "branches": { 778 "$comment": "unevaluatedProperties comes first so it's more likely to bugs errors with implementations that are sensitive to keyword ordering", 779 "unevaluatedProperties": false, 780 "$recursiveRef": "#" 781 } 782 }, 783 "required": ["node"] 784 } 785 } 786 }, 787 "tests": [ 788 { 789 "description": "with no unevaluated properties", 790 "data": { 791 "name": "a", 792 "node": 1, 793 "branches": { 794 "name": "b", 795 "node": 2 796 } 797 }, 798 "valid": true 799 }, 800 { 801 "description": "with unevaluated properties", 802 "data": { 803 "name": "a", 804 "node": 1, 805 "branches": { 806 "foo": "b", 807 "node": 2 808 } 809 }, 810 "valid": false 811 } 812 ] 813 }, 814 { 815 "description": "unevaluatedProperties can't see inside cousins", 816 "schema": { 817 "$schema": "https://json-schema.org/draft/2019-09/schema", 818 "allOf": [ 819 { 820 "properties": { 821 "foo": true 822 } 823 }, 824 { 825 "unevaluatedProperties": false 826 } 827 ] 828 }, 829 "tests": [ 830 { 831 "description": "always fails", 832 "data": { 833 "foo": 1 834 }, 835 "valid": false 836 } 837 ] 838 }, 839 { 840 "description": "unevaluatedProperties can't see inside cousins (reverse order)", 841 "schema": { 842 "$schema": "https://json-schema.org/draft/2019-09/schema", 843 "allOf": [ 844 { 845 "unevaluatedProperties": false 846 }, 847 { 848 "properties": { 849 "foo": true 850 } 851 } 852 ] 853 }, 854 "tests": [ 855 { 856 "description": "always fails", 857 "data": { 858 "foo": 1 859 }, 860 "valid": false 861 } 862 ] 863 }, 864 { 865 "description": "nested unevaluatedProperties, outer false, inner true, properties outside", 866 "schema": { 867 "$schema": "https://json-schema.org/draft/2019-09/schema", 868 "type": "object", 869 "properties": { 870 "foo": { "type": "string" } 871 }, 872 "allOf": [ 873 { 874 "unevaluatedProperties": true 875 } 876 ], 877 "unevaluatedProperties": false 878 }, 879 "tests": [ 880 { 881 "description": "with no nested unevaluated properties", 882 "data": { 883 "foo": "foo" 884 }, 885 "valid": true 886 }, 887 { 888 "description": "with nested unevaluated properties", 889 "data": { 890 "foo": "foo", 891 "bar": "bar" 892 }, 893 "valid": true 894 } 895 ] 896 }, 897 { 898 "description": "nested unevaluatedProperties, outer false, inner true, properties inside", 899 "schema": { 900 "$schema": "https://json-schema.org/draft/2019-09/schema", 901 "type": "object", 902 "allOf": [ 903 { 904 "properties": { 905 "foo": { "type": "string" } 906 }, 907 "unevaluatedProperties": true 908 } 909 ], 910 "unevaluatedProperties": false 911 }, 912 "tests": [ 913 { 914 "description": "with no nested unevaluated properties", 915 "data": { 916 "foo": "foo" 917 }, 918 "valid": true 919 }, 920 { 921 "description": "with nested unevaluated properties", 922 "data": { 923 "foo": "foo", 924 "bar": "bar" 925 }, 926 "valid": true 927 } 928 ] 929 }, 930 { 931 "description": "nested unevaluatedProperties, outer true, inner false, properties outside", 932 "schema": { 933 "$schema": "https://json-schema.org/draft/2019-09/schema", 934 "type": "object", 935 "properties": { 936 "foo": { "type": "string" } 937 }, 938 "allOf": [ 939 { 940 "unevaluatedProperties": false 941 } 942 ], 943 "unevaluatedProperties": true 944 }, 945 "tests": [ 946 { 947 "description": "with no nested unevaluated properties", 948 "data": { 949 "foo": "foo" 950 }, 951 "valid": false 952 }, 953 { 954 "description": "with nested unevaluated properties", 955 "data": { 956 "foo": "foo", 957 "bar": "bar" 958 }, 959 "valid": false 960 } 961 ] 962 }, 963 { 964 "description": "nested unevaluatedProperties, outer true, inner false, properties inside", 965 "schema": { 966 "$schema": "https://json-schema.org/draft/2019-09/schema", 967 "type": "object", 968 "allOf": [ 969 { 970 "properties": { 971 "foo": { "type": "string" } 972 }, 973 "unevaluatedProperties": false 974 } 975 ], 976 "unevaluatedProperties": true 977 }, 978 "tests": [ 979 { 980 "description": "with no nested unevaluated properties", 981 "data": { 982 "foo": "foo" 983 }, 984 "valid": true 985 }, 986 { 987 "description": "with nested unevaluated properties", 988 "data": { 989 "foo": "foo", 990 "bar": "bar" 991 }, 992 "valid": false 993 } 994 ] 995 }, 996 { 997 "description": "cousin unevaluatedProperties, true and false, true with properties", 998 "schema": { 999 "$schema": "https://json-schema.org/draft/2019-09/schema", 1000 "type": "object", 1001 "allOf": [ 1002 { 1003 "properties": { 1004 "foo": { "type": "string" } 1005 }, 1006 "unevaluatedProperties": true 1007 }, 1008 { 1009 "unevaluatedProperties": false 1010 } 1011 ] 1012 }, 1013 "tests": [ 1014 { 1015 "description": "with no nested unevaluated properties", 1016 "data": { 1017 "foo": "foo" 1018 }, 1019 "valid": false 1020 }, 1021 { 1022 "description": "with nested unevaluated properties", 1023 "data": { 1024 "foo": "foo", 1025 "bar": "bar" 1026 }, 1027 "valid": false 1028 } 1029 ] 1030 }, 1031 { 1032 "description": "cousin unevaluatedProperties, true and false, false with properties", 1033 "schema": { 1034 "$schema": "https://json-schema.org/draft/2019-09/schema", 1035 "type": "object", 1036 "allOf": [ 1037 { 1038 "unevaluatedProperties": true 1039 }, 1040 { 1041 "properties": { 1042 "foo": { "type": "string" } 1043 }, 1044 "unevaluatedProperties": false 1045 } 1046 ] 1047 }, 1048 "tests": [ 1049 { 1050 "description": "with no nested unevaluated properties", 1051 "data": { 1052 "foo": "foo" 1053 }, 1054 "valid": true 1055 }, 1056 { 1057 "description": "with nested unevaluated properties", 1058 "data": { 1059 "foo": "foo", 1060 "bar": "bar" 1061 }, 1062 "valid": false 1063 } 1064 ] 1065 }, 1066 { 1067 "description": "property is evaluated in an uncle schema to unevaluatedProperties", 1068 "comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations", 1069 "schema": { 1070 "$schema": "https://json-schema.org/draft/2019-09/schema", 1071 "type": "object", 1072 "properties": { 1073 "foo": { 1074 "type": "object", 1075 "properties": { 1076 "bar": { 1077 "type": "string" 1078 } 1079 }, 1080 "unevaluatedProperties": false 1081 } 1082 }, 1083 "anyOf": [ 1084 { 1085 "properties": { 1086 "foo": { 1087 "properties": { 1088 "faz": { 1089 "type": "string" 1090 } 1091 } 1092 } 1093 } 1094 } 1095 ] 1096 }, 1097 "tests": [ 1098 { 1099 "description": "no extra properties", 1100 "data": { 1101 "foo": { 1102 "bar": "test" 1103 } 1104 }, 1105 "valid": true 1106 }, 1107 { 1108 "description": "uncle keyword evaluation is not significant", 1109 "data": { 1110 "foo": { 1111 "bar": "test", 1112 "faz": "test" 1113 } 1114 }, 1115 "valid": false 1116 } 1117 ] 1118 }, 1119 { 1120 "description": "in-place applicator siblings, allOf has unevaluated", 1121 "schema": { 1122 "$schema": "https://json-schema.org/draft/2019-09/schema", 1123 "type": "object", 1124 "allOf": [ 1125 { 1126 "properties": { 1127 "foo": true 1128 }, 1129 "unevaluatedProperties": false 1130 } 1131 ], 1132 "anyOf": [ 1133 { 1134 "properties": { 1135 "bar": true 1136 } 1137 } 1138 ] 1139 }, 1140 "tests": [ 1141 { 1142 "description": "base case: both properties present", 1143 "data": { 1144 "foo": 1, 1145 "bar": 1 1146 }, 1147 "valid": false 1148 }, 1149 { 1150 "description": "in place applicator siblings, bar is missing", 1151 "data": { 1152 "foo": 1 1153 }, 1154 "valid": true 1155 }, 1156 { 1157 "description": "in place applicator siblings, foo is missing", 1158 "data": { 1159 "bar": 1 1160 }, 1161 "valid": false 1162 } 1163 ] 1164 }, 1165 { 1166 "description": "in-place applicator siblings, anyOf has unevaluated", 1167 "schema": { 1168 "$schema": "https://json-schema.org/draft/2019-09/schema", 1169 "type": "object", 1170 "allOf": [ 1171 { 1172 "properties": { 1173 "foo": true 1174 } 1175 } 1176 ], 1177 "anyOf": [ 1178 { 1179 "properties": { 1180 "bar": true 1181 }, 1182 "unevaluatedProperties": false 1183 } 1184 ] 1185 }, 1186 "tests": [ 1187 { 1188 "description": "base case: both properties present", 1189 "data": { 1190 "foo": 1, 1191 "bar": 1 1192 }, 1193 "valid": false 1194 }, 1195 { 1196 "description": "in place applicator siblings, bar is missing", 1197 "data": { 1198 "foo": 1 1199 }, 1200 "valid": false 1201 }, 1202 { 1203 "description": "in place applicator siblings, foo is missing", 1204 "data": { 1205 "bar": 1 1206 }, 1207 "valid": true 1208 } 1209 ] 1210 }, 1211 { 1212 "description": "unevaluatedProperties + single cyclic ref", 1213 "schema": { 1214 "$schema": "https://json-schema.org/draft/2019-09/schema", 1215 "type": "object", 1216 "properties": { 1217 "x": { "$ref": "#" } 1218 }, 1219 "unevaluatedProperties": false 1220 }, 1221 "tests": [ 1222 { 1223 "description": "Empty is valid", 1224 "data": {}, 1225 "valid": true 1226 }, 1227 { 1228 "description": "Single is valid", 1229 "data": { "x": {} }, 1230 "valid": true 1231 }, 1232 { 1233 "description": "Unevaluated on 1st level is invalid", 1234 "data": { "x": {}, "y": {} }, 1235 "valid": false 1236 }, 1237 { 1238 "description": "Nested is valid", 1239 "data": { "x": { "x": {} } }, 1240 "valid": true 1241 }, 1242 { 1243 "description": "Unevaluated on 2nd level is invalid", 1244 "data": { "x": { "x": {}, "y": {} } }, 1245 "valid": false 1246 }, 1247 { 1248 "description": "Deep nested is valid", 1249 "data": { "x": { "x": { "x": {} } } }, 1250 "valid": true 1251 }, 1252 { 1253 "description": "Unevaluated on 3rd level is invalid", 1254 "data": { "x": { "x": { "x": {}, "y": {} } } }, 1255 "valid": false 1256 } 1257 ] 1258 }, 1259 { 1260 "description": "unevaluatedProperties + ref inside allOf / oneOf", 1261 "schema": { 1262 "$schema": "https://json-schema.org/draft/2019-09/schema", 1263 "$defs": { 1264 "one": { 1265 "properties": { "a": true } 1266 }, 1267 "two": { 1268 "required": ["x"], 1269 "properties": { "x": true } 1270 } 1271 }, 1272 "allOf": [ 1273 { "$ref": "#/$defs/one" }, 1274 { "properties": { "b": true } }, 1275 { 1276 "oneOf": [ 1277 { "$ref": "#/$defs/two" }, 1278 { 1279 "required": ["y"], 1280 "properties": { "y": true } 1281 } 1282 ] 1283 } 1284 ], 1285 "unevaluatedProperties": false 1286 }, 1287 "tests": [ 1288 { 1289 "description": "Empty is invalid (no x or y)", 1290 "data": {}, 1291 "valid": false 1292 }, 1293 { 1294 "description": "a and b are invalid (no x or y)", 1295 "data": { "a": 1, "b": 1 }, 1296 "valid": false 1297 }, 1298 { 1299 "description": "x and y are invalid", 1300 "data": { "x": 1, "y": 1 }, 1301 "valid": false 1302 }, 1303 { 1304 "description": "a and x are valid", 1305 "data": { "a": 1, "x": 1 }, 1306 "valid": true 1307 }, 1308 { 1309 "description": "a and y are valid", 1310 "data": { "a": 1, "y": 1 }, 1311 "valid": true 1312 }, 1313 { 1314 "description": "a and b and x are valid", 1315 "data": { "a": 1, "b": 1, "x": 1 }, 1316 "valid": true 1317 }, 1318 { 1319 "description": "a and b and y are valid", 1320 "data": { "a": 1, "b": 1, "y": 1 }, 1321 "valid": true 1322 }, 1323 { 1324 "description": "a and b and x and y are invalid", 1325 "data": { "a": 1, "b": 1, "x": 1, "y": 1 }, 1326 "valid": false 1327 } 1328 ] 1329 }, 1330 { 1331 "description": "dynamic evalation inside nested refs", 1332 "schema": { 1333 "$schema": "https://json-schema.org/draft/2019-09/schema", 1334 "$defs": { 1335 "one": { 1336 "oneOf": [ 1337 { "$ref": "#/$defs/two" }, 1338 { "required": ["b"], "properties": { "b": true } }, 1339 { "required": ["xx"], "patternProperties": { "x": true } }, 1340 { "required": ["all"], "unevaluatedProperties": true } 1341 ] 1342 }, 1343 "two": { 1344 "oneOf": [ 1345 { "required": ["c"], "properties": { "c": true } }, 1346 { "required": ["d"], "properties": { "d": true } } 1347 ] 1348 } 1349 }, 1350 "oneOf": [ 1351 { "$ref": "#/$defs/one" }, 1352 { "required": ["a"], "properties": { "a": true } } 1353 ], 1354 "unevaluatedProperties": false 1355 }, 1356 "tests": [ 1357 { 1358 "description": "Empty is invalid", 1359 "data": {}, 1360 "valid": false 1361 }, 1362 { 1363 "description": "a is valid", 1364 "data": { "a": 1 }, 1365 "valid": true 1366 }, 1367 { 1368 "description": "b is valid", 1369 "data": { "b": 1 }, 1370 "valid": true 1371 }, 1372 { 1373 "description": "c is valid", 1374 "data": { "c": 1 }, 1375 "valid": true 1376 }, 1377 { 1378 "description": "d is valid", 1379 "data": { "d": 1 }, 1380 "valid": true 1381 }, 1382 { 1383 "description": "a + b is invalid", 1384 "data": { "a": 1, "b": 1 }, 1385 "valid": false 1386 }, 1387 { 1388 "description": "a + c is invalid", 1389 "data": { "a": 1, "c": 1 }, 1390 "valid": false 1391 }, 1392 { 1393 "description": "a + d is invalid", 1394 "data": { "a": 1, "d": 1 }, 1395 "valid": false 1396 }, 1397 { 1398 "description": "b + c is invalid", 1399 "data": { "b": 1, "c": 1 }, 1400 "valid": false 1401 }, 1402 { 1403 "description": "b + d is invalid", 1404 "data": { "b": 1, "d": 1 }, 1405 "valid": false 1406 }, 1407 { 1408 "description": "c + d is invalid", 1409 "data": { "c": 1, "d": 1 }, 1410 "valid": false 1411 }, 1412 { 1413 "description": "xx is valid", 1414 "data": { "xx": 1 }, 1415 "valid": true 1416 }, 1417 { 1418 "description": "xx + foox is valid", 1419 "data": { "xx": 1, "foox": 1 }, 1420 "valid": true 1421 }, 1422 { 1423 "description": "xx + foo is invalid", 1424 "data": { "xx": 1, "foo": 1 }, 1425 "valid": false 1426 }, 1427 { 1428 "description": "xx + a is invalid", 1429 "data": { "xx": 1, "a": 1 }, 1430 "valid": false 1431 }, 1432 { 1433 "description": "xx + b is invalid", 1434 "data": { "xx": 1, "b": 1 }, 1435 "valid": false 1436 }, 1437 { 1438 "description": "xx + c is invalid", 1439 "data": { "xx": 1, "c": 1 }, 1440 "valid": false 1441 }, 1442 { 1443 "description": "xx + d is invalid", 1444 "data": { "xx": 1, "d": 1 }, 1445 "valid": false 1446 }, 1447 { 1448 "description": "all is valid", 1449 "data": { "all": 1 }, 1450 "valid": true 1451 }, 1452 { 1453 "description": "all + foo is valid", 1454 "data": { "all": 1, "foo": 1 }, 1455 "valid": true 1456 }, 1457 { 1458 "description": "all + a is invalid", 1459 "data": { "all": 1, "a": 1 }, 1460 "valid": false 1461 } 1462 ] 1463 }, 1464 { 1465 "description": "non-object instances are valid", 1466 "schema": { 1467 "$schema": "https://json-schema.org/draft/2019-09/schema", 1468 "unevaluatedProperties": false 1469 }, 1470 "tests": [ 1471 { 1472 "description": "ignores booleans", 1473 "data": true, 1474 "valid": true 1475 }, 1476 { 1477 "description": "ignores integers", 1478 "data": 123, 1479 "valid": true 1480 }, 1481 { 1482 "description": "ignores floats", 1483 "data": 1.0, 1484 "valid": true 1485 }, 1486 { 1487 "description": "ignores arrays", 1488 "data": [], 1489 "valid": true 1490 }, 1491 { 1492 "description": "ignores strings", 1493 "data": "foo", 1494 "valid": true 1495 }, 1496 { 1497 "description": "ignores null", 1498 "data": null, 1499 "valid": true 1500 } 1501 ] 1502 }, 1503 { 1504 "description": "unevaluatedProperties with null valued instance properties", 1505 "schema": { 1506 "$schema": "https://json-schema.org/draft/2019-09/schema", 1507 "unevaluatedProperties": { 1508 "type": "null" 1509 } 1510 }, 1511 "tests": [ 1512 { 1513 "description": "allows null valued properties", 1514 "data": {"foo": null}, 1515 "valid": true 1516 } 1517 ] 1518 }, 1519 { 1520 "description": "unevaluatedProperties not affected by propertyNames", 1521 "schema": { 1522 "$schema": "https://json-schema.org/draft/2019-09/schema", 1523 "propertyNames": {"maxLength": 1}, 1524 "unevaluatedProperties": { 1525 "type": "number" 1526 } 1527 }, 1528 "tests": [ 1529 { 1530 "description": "allows only number properties", 1531 "data": {"a": 1}, 1532 "valid": true 1533 }, 1534 { 1535 "description": "string property is invalid", 1536 "data": {"a": "b"}, 1537 "valid": false 1538 } 1539 ] 1540 }, 1541 { 1542 "description": "unevaluatedProperties can see annotations from if without then and else", 1543 "schema": { 1544 "$schema": "https://json-schema.org/draft/2019-09/schema", 1545 "if": { 1546 "patternProperties": { 1547 "foo": { 1548 "type": "string" 1549 } 1550 } 1551 }, 1552 "unevaluatedProperties": false 1553 }, 1554 "tests": [ 1555 { 1556 "description": "valid in case if is evaluated", 1557 "data": { 1558 "foo": "a" 1559 }, 1560 "valid": true 1561 }, 1562 { 1563 "description": "invalid in case if is evaluated", 1564 "data": { 1565 "bar": "a" 1566 }, 1567 "valid": false 1568 } 1569 ] 1570 } 1571] 1572