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