1[ 2 { 3 "description": "schema with a $ref", 4 "schema": { 5 "title": "Person", 6 "type": "object", 7 "definitions": { 8 "address": { 9 "properties": { 10 "residence": { 11 "$ref": "#/definitions/residence", 12 "description": "Residence details where the person lives" 13 }, 14 "city": { 15 "type": "string", 16 "description": "City where the person lives." 17 }, 18 "street": { 19 "type": "string", 20 "description": "street where the person lives." 21 }, 22 "pinCode": { 23 "type": "number", 24 "description": "pincode of street" 25 } 26 }, 27 "unevaluatedProperties": false 28 }, 29 "residence": { 30 "properties": { 31 "flatNumber": { 32 "type": "string" 33 }, 34 "flatName": { 35 "type": "string" 36 }, 37 "landmark": { 38 "type": "string" 39 } 40 }, 41 "unevaluatedProperties": false 42 } 43 }, 44 "properties": { 45 "firstName": { 46 "type": "string", 47 "description": "The person's first name." 48 }, 49 "lastName": { 50 "type": "string", 51 "description": "The person's last name." 52 }, 53 "age": { 54 "description": "Age in years which must be equal to or greater than zero.", 55 "type": "integer", 56 "minimum": 0 57 }, 58 "address": { 59 "description": "Address of the person.", 60 "$ref": "#/definitions/address" 61 } 62 }, 63 "unevaluatedProperties": false 64 }, 65 "tests": [ 66 { 67 "description": "Basic Success Test", 68 "data": { 69 "firstName": "First Name", 70 "age": 18, 71 "lastName": "Last Name", 72 "address": { 73 "city": "Hyderabad", 74 "pinCode": 500025 75 } 76 }, 77 "valid": true 78 }, 79 { 80 "description": "Unevaluated Property - Outside $ref", 81 "data": { 82 "firstName": "First Name", 83 "invalid": 18, 84 "lastName": "Last Name", 85 "address": { 86 "city": "Hyderabad", 87 "pinCode": 500025 88 } 89 }, 90 "valid": false, 91 "validationMessages": [ 92 "$: property 'invalid' is not evaluated and the schema does not allow unevaluated properties" 93 ] 94 }, 95 { 96 "description": "Unevaluated Property - inside $ref", 97 "data": { 98 "firstName": "First Name", 99 "age": 18, 100 "lastName": "Last Name", 101 "address": { 102 "city": "Hyderabad", 103 "pinCode": 500025, 104 "invalid": "invalid" 105 } 106 }, 107 "valid": false, 108 "validationMessages": [ 109 "$.address: property 'invalid' is not evaluated and the schema does not allow unevaluated properties" 110 ] 111 }, 112 { 113 "description": "Unevaluated - multiple properties", 114 "data": { 115 "invalid1": "First Name", 116 "age": 18, 117 "lastName": "Last Name", 118 "address": { 119 "city": "Hyderabad", 120 "pinCode": 500025, 121 "invalid2": "invalid" 122 } 123 }, 124 "valid": false, 125 "validationMessages": [ 126 "$.address: property 'invalid2' is not evaluated and the schema does not allow unevaluated properties" 127 ] 128 }, 129 { 130 "description": "Inside nested $ref", 131 "data": { 132 "firstName": "First Name", 133 "age": 18, 134 "lastName": "Last Name", 135 "address": { 136 "city": "Hyderabad", 137 "pinCode": 500025, 138 "residence": { 139 "invalid": "" 140 } 141 } 142 }, 143 "valid": false, 144 "validationMessages": [ 145 "$.address.residence: property 'invalid' is not evaluated and the schema does not allow unevaluated properties" 146 ] 147 } 148 ] 149 }, 150 { 151 "description": "schema with a oneOf", 152 "schema": { 153 "title": "Person", 154 "type": "object", 155 "properties": { 156 "firstName": { 157 "type": "string", 158 "description": "The person's first name." 159 }, 160 "lastName": { 161 "type": "string", 162 "description": "The person's last name." 163 }, 164 "age": { 165 "description": "Age in years which must be equal to or greater than zero.", 166 "type": "integer", 167 "minimum": 0 168 }, 169 "vehicle": { 170 "oneOf": [ 171 { 172 "title": "Car", 173 "required": [ 174 "wheels", 175 "headlights" 176 ], 177 "properties": { 178 "wheels": { 179 "type": "string" 180 }, 181 "headlights": { 182 "type": "string" 183 } 184 } 185 }, 186 { 187 "title": "Boat", 188 "required": [ 189 "pontoons" 190 ], 191 "properties": { 192 "pontoons": { 193 "type": "string" 194 } 195 } 196 }, 197 { 198 "title": "Plane", 199 "required": [ 200 "wings" 201 ], 202 "properties": { 203 "wings": { 204 "type": "string" 205 } 206 } 207 } 208 ], 209 "unevaluatedProperties": false 210 }, 211 "unevaluatedProperties": false 212 } 213 }, 214 "tests": [ 215 { 216 "description": "Data with oneOf and one property", 217 "data": { 218 "firstName": "First Name", 219 "age": 18, 220 "lastName": "Last Name", 221 "vehicle": { 222 "pontoons": "pontoons" 223 } 224 }, 225 "valid": true 226 }, 227 { 228 "description": "Data which satisfies 1 oneOf schemas, but fails due to unevaluated prop", 229 "data": { 230 "firstName": "First Name", 231 "age": 18, 232 "lastName": "Last Name", 233 "vehicle": { 234 "pontoons": "pontoons", 235 "wheels": "wheels" 236 } 237 }, 238 "valid": false, 239 "validationMessages": [ 240 "$.vehicle: property 'wheels' is not evaluated and the schema does not allow unevaluated properties" 241 ] 242 }, 243 { 244 "description": "Data which satisfies 2 oneOf schemas", 245 "data": { 246 "firstName": "First Name", 247 "age": 18, 248 "lastName": "Last Name", 249 "vehicle": { 250 "pontoons": "pontoons", 251 "wings": "wings" 252 } 253 }, 254 "valid": false, 255 "validationMessages": [ 256 "$.vehicle: must be valid to one and only one schema, but 2 are valid with indexes '1, 2'", 257 "$.vehicle: required property 'wheels' not found", 258 "$.vehicle: required property 'headlights' not found" 259 ] 260 }, 261 { 262 "description": "Data which satisfies 2 oneOf schemas and an invalid prop", 263 "data": { 264 "firstName": "First Name", 265 "age": 18, 266 "lastName": "Last Name", 267 "vehicle": { 268 "pontoons": "pontoons", 269 "wings": "wings", 270 "invalid": "invalid" 271 } 272 }, 273 "valid": false, 274 "validationMessages": [ 275 "$.vehicle: must be valid to one and only one schema, but 2 are valid with indexes '1, 2'", 276 "$.vehicle: property 'invalid' is not evaluated and the schema does not allow unevaluated properties", 277 "$.vehicle: required property 'wheels' not found", 278 "$.vehicle: required property 'headlights' not found" 279 ] 280 }, 281 { 282 "description": "Data which doesn't satisfy any of oneOf schemas but having an invalid prop", 283 "data": { 284 "firstName": "First Name", 285 "age": 18, 286 "lastName": "Last Name", 287 "vehicle": { 288 "invalid": "invalid" 289 } 290 }, 291 "valid": false, 292 "validationMessages": [ 293 "$.vehicle: must be valid to one and only one schema, but 0 are valid", 294 "$.vehicle: property 'invalid' is not evaluated and the schema does not allow unevaluated properties" 295 ] 296 } 297 ] 298 }, 299 { 300 "description": "schema with a anyOf", 301 "schema": { 302 "title": "Person", 303 "type": "object", 304 "properties": { 305 "firstName": { 306 "type": "string", 307 "description": "The person's first name." 308 }, 309 "lastName": { 310 "type": "string", 311 "description": "The person's last name." 312 }, 313 "age": { 314 "description": "Age in years which must be equal to or greater than zero.", 315 "type": "integer", 316 "minimum": 0 317 }, 318 "vehicle": { 319 "anyOf": [ 320 { 321 "title": "Car", 322 "required": [ 323 "wheels", 324 "headlights" 325 ], 326 "properties": { 327 "wheels": { 328 "type": "string" 329 }, 330 "headlights": { 331 "type": "string" 332 } 333 } 334 }, 335 { 336 "title": "Boat", 337 "required": [ 338 "pontoons" 339 ], 340 "properties": { 341 "pontoons": { 342 "type": "string" 343 } 344 } 345 }, 346 { 347 "title": "Plane", 348 "required": [ 349 "wings" 350 ], 351 "properties": { 352 "wings": { 353 "type": "string" 354 } 355 } 356 } 357 ], 358 "unevaluatedProperties": false 359 }, 360 "unevaluatedProperties": false 361 } 362 }, 363 "tests": [ 364 { 365 "description": "Data with 1 valid AnyOf", 366 "data": { 367 "firstName": "First Name", 368 "age": 18, 369 "lastName": "Last Name", 370 "vehicle": { 371 "pontoons": "pontoons" 372 } 373 }, 374 "valid": true 375 }, 376 { 377 "description": "Data with 1 AnyOf and 1 unevaluated property", 378 "data": { 379 "firstName": "First Name", 380 "age": 18, 381 "lastName": "Last Name", 382 "vehicle": { 383 "pontoons": "pontoons", 384 "unevaluated": true 385 } 386 }, 387 "valid": false, 388 "validationMessages": [ 389 "$.vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" 390 ] 391 }, 392 { 393 "description": "Data with just unevaluated property", 394 "data": { 395 "firstName": "First Name", 396 "age": 18, 397 "lastName": "Last Name", 398 "vehicle": { 399 "unevaluated": true 400 } 401 }, 402 "valid": false, 403 "validationMessages": [ 404 "$.vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" 405 ] 406 }, 407 { 408 "description": "Data with 2 valid AnyOf and 1 unevaluated property", 409 "data": { 410 "firstName": "First Name", 411 "age": 18, 412 "lastName": "Last Name", 413 "vehicle": { 414 "pontoons": "pontoons", 415 "wings": "wings", 416 "unevaluated": true 417 } 418 }, 419 "valid": false, 420 "validationMessages": [ 421 "$.vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" 422 ] 423 } 424 ] 425 }, 426 { 427 "description": "schema with a allOf", 428 "schema": { 429 "title": "Person", 430 "type": "object", 431 "properties": { 432 "firstName": { 433 "type": "string", 434 "description": "The person's first name." 435 }, 436 "lastName": { 437 "type": "string", 438 "description": "The person's last name." 439 }, 440 "age": { 441 "description": "Age in years which must be equal to or greater than zero.", 442 "type": "integer", 443 "minimum": 0 444 }, 445 "vehicle": { 446 "allOf": [ 447 { 448 "title": "Car", 449 "required": [ 450 "wheels" 451 ], 452 "properties": { 453 "wheels": { 454 "type": "string" 455 }, 456 "headlights": { 457 "type": "string" 458 } 459 } 460 }, 461 { 462 "title": "Boat", 463 "required": [ 464 "pontoons" 465 ], 466 "properties": { 467 "pontoons": { 468 "type": "string" 469 } 470 } 471 }, 472 { 473 "title": "Plane", 474 "required": [ 475 "wings" 476 ], 477 "properties": { 478 "wings": { 479 "type": "string" 480 } 481 } 482 } 483 ], 484 "unevaluatedProperties": false 485 }, 486 "unevaluatedProperties": false 487 } 488 }, 489 "tests": [ 490 { 491 "description": "Data with allOf", 492 "data": { 493 "firstName": "First Name", 494 "age": 18, 495 "lastName": "Last Name", 496 "vehicle": { 497 "wheels": "wheels", 498 "pontoons": "pontoons", 499 "wings": "wings" 500 } 501 }, 502 "valid": true 503 }, 504 { 505 "description": "Data with invalid allOf and one unevaluated property", 506 "data": { 507 "firstName": "First Name", 508 "age": 18, 509 "lastName": "Last Name", 510 "vehicle": { 511 "wheels": "wheels", 512 "pontoons": "pontoons", 513 "unevaluated": true 514 } 515 }, 516 "valid": false, 517 "validationMessages": [ 518 "$.vehicle: required property 'wings' not found", 519 "$.vehicle: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" 520 ] 521 } 522 ] 523 }, 524 { 525 "description": "schema with if then and else", 526 "schema": { 527 "title": "Person", 528 "type": "object", 529 "if": { 530 "properties": { 531 "firstName": { 532 "type": "string", 533 "description": "The person's first name." 534 }, 535 "age": { 536 "description": "Age in years which must be equal to or greater than zero.", 537 "type": "integer", 538 "minimum": 0 539 } 540 }, 541 "required": [ 542 "firstName" 543 ] 544 }, 545 "then": { 546 "properties": { 547 "lastName": { 548 "type": "string", 549 "description": "The person's last name." 550 } 551 } 552 }, 553 "else": { 554 "properties": { 555 "surName": { 556 "type": "string", 557 "description": "The person's sur name." 558 } 559 } 560 }, 561 "unevaluatedProperties": false 562 }, 563 "tests": [ 564 { 565 "description": "Data with if then and else", 566 "data": { 567 "age": 18, 568 "surName": "Sur Name" 569 }, 570 "valid": false 571 }, 572 { 573 "description": "Data - else schema with one unevaluated property", 574 "data": { 575 "age": 18, 576 "surName": "Sur Name", 577 "unevaluated": true 578 }, 579 "valid": false, 580 "validationMessages": [ 581 "$: property 'age' is not evaluated and the schema does not allow unevaluated properties", 582 "$: property 'unevaluated' is not evaluated and the schema does not allow unevaluated properties" 583 ] 584 } 585 ] 586 }, 587 { 588 "description": "schema with additional properties as object", 589 "schema": { 590 "title": "Person", 591 "type": "object", 592 "properties": { 593 "firstName": { 594 "type": "string", 595 "description": "The person's first name." 596 }, 597 "lastName": { 598 "type": "string", 599 "description": "The person's last name." 600 }, 601 "age": { 602 "description": "Age in years which must be equal to or greater than zero.", 603 "type": "integer", 604 "minimum": 0 605 } 606 }, 607 "additionalProperties": { 608 "properties": { 609 "location": { 610 "type": "string", 611 "description": "The person's location." 612 } 613 } 614 }, 615 "unevaluatedProperties": false 616 }, 617 "tests": [ 618 { 619 "description": "Data with additional properties as object", 620 "data": { 621 "age": 18, 622 "otherProperty": { 623 "location": "hello" 624 } 625 }, 626 "valid": true 627 } 628 ] 629 }, 630 { 631 "description": "schema with additional properties as type", 632 "schema": { 633 "title": "Person", 634 "type": "object", 635 "properties": { 636 "firstName": { 637 "type": "string", 638 "description": "The person's first name." 639 }, 640 "lastName": { 641 "type": "string", 642 "description": "The person's last name." 643 }, 644 "age": { 645 "description": "Age in years which must be equal to or greater than zero.", 646 "type": "integer", 647 "minimum": 0 648 } 649 }, 650 "additionalProperties": { 651 "type": "string" 652 }, 653 "unevaluatedProperties": false 654 }, 655 "tests": [ 656 { 657 "description": "Data with additional properties as type", 658 "data": { 659 "age": 18, 660 "otherProperty": "test" 661 }, 662 "valid": true 663 } 664 ] 665 }, 666 { 667 "description": "unevaluatedProperties should not affect sub-schemas", 668 "schema": { 669 "properties": { 670 "foo": {} 671 }, 672 "unevaluatedProperties": false 673 }, 674 "tests": [ 675 { 676 "description": "unevaluated property bar is in sub-schema", 677 "data": { 678 "foo": { 679 "bar": "baz" 680 } 681 }, 682 "valid": true 683 } 684 ] 685 }, 686 { 687 "description": "unevaluatedProperties true", 688 "schema": { 689 "type": "object", 690 "unevaluatedProperties": true 691 }, 692 "tests": [ 693 { 694 "description": "with no unevaluated properties", 695 "data": {}, 696 "valid": true 697 }, 698 { 699 "description": "with unevaluated properties", 700 "data": { 701 "foo": "foo" 702 }, 703 "valid": true 704 } 705 ] 706 }, 707 { 708 "description": "unevaluatedProperties false", 709 "schema": { 710 "type": "object", 711 "unevaluatedProperties": false 712 }, 713 "tests": [ 714 { 715 "description": "with no unevaluated properties", 716 "data": {}, 717 "valid": true 718 }, 719 { 720 "description": "with unevaluated properties", 721 "data": { 722 "foo": "foo" 723 }, 724 "valid": false 725 } 726 ] 727 }, 728 { 729 "description": "unevaluatedProperties with adjacent properties", 730 "schema": { 731 "type": "object", 732 "properties": { 733 "foo": { 734 "type": "string" 735 } 736 }, 737 "unevaluatedProperties": false 738 }, 739 "tests": [ 740 { 741 "description": "with no unevaluated properties", 742 "data": { 743 "foo": "foo" 744 }, 745 "valid": true 746 }, 747 { 748 "description": "with unevaluated properties", 749 "data": { 750 "foo": "foo", 751 "bar": "bar" 752 }, 753 "valid": false 754 } 755 ] 756 }, 757 { 758 "description": "unevaluatedProperties with adjacent patternProperties", 759 "schema": { 760 "type": "object", 761 "patternProperties": { 762 "^foo": { 763 "type": "string" 764 } 765 }, 766 "unevaluatedProperties": false 767 }, 768 "tests": [ 769 { 770 "description": "with no unevaluated properties", 771 "data": { 772 "foo": "foo" 773 }, 774 "valid": true 775 }, 776 { 777 "description": "with unevaluated properties", 778 "data": { 779 "foo": "foo", 780 "bar": "bar" 781 }, 782 "valid": false 783 } 784 ] 785 }, 786 { 787 "description": "unevaluatedProperties with adjacent additionalProperties", 788 "schema": { 789 "type": "object", 790 "properties": { 791 "foo": { 792 "type": "string" 793 } 794 }, 795 "additionalProperties": true, 796 "unevaluatedProperties": false 797 }, 798 "tests": [ 799 { 800 "description": "with no additional properties", 801 "data": { 802 "foo": "foo" 803 }, 804 "valid": true 805 }, 806 { 807 "description": "with additional properties", 808 "data": { 809 "foo": "foo", 810 "bar": "bar" 811 }, 812 "valid": true 813 } 814 ] 815 }, 816 { 817 "description": "unevaluatedProperties with nested properties", 818 "schema": { 819 "type": "object", 820 "properties": { 821 "foo": { 822 "type": "string" 823 } 824 }, 825 "allOf": [ 826 { 827 "properties": { 828 "bar": { 829 "type": "string" 830 } 831 } 832 } 833 ], 834 "unevaluatedProperties": false 835 }, 836 "tests": [ 837 { 838 "description": "with no additional properties", 839 "data": { 840 "foo": "foo", 841 "bar": "bar" 842 }, 843 "valid": true 844 }, 845 { 846 "description": "with additional properties", 847 "data": { 848 "foo": "foo", 849 "bar": "bar", 850 "baz": "baz" 851 }, 852 "valid": false 853 } 854 ] 855 }, 856 { 857 "description": "unevaluatedProperties with nested patternProperties", 858 "schema": { 859 "type": "object", 860 "properties": { 861 "foo": { 862 "type": "string" 863 } 864 }, 865 "allOf": [ 866 { 867 "patternProperties": { 868 "^bar": { 869 "type": "string" 870 } 871 } 872 } 873 ], 874 "unevaluatedProperties": false 875 }, 876 "tests": [ 877 { 878 "description": "with no additional properties", 879 "data": { 880 "foo": "foo", 881 "bar": "bar" 882 }, 883 "valid": true 884 }, 885 { 886 "description": "with additional properties", 887 "data": { 888 "foo": "foo", 889 "bar": "bar", 890 "baz": "baz" 891 }, 892 "valid": false 893 } 894 ] 895 }, 896 { 897 "description": "unevaluatedProperties with nested additionalProperties", 898 "schema": { 899 "type": "object", 900 "properties": { 901 "foo": { 902 "type": "string" 903 } 904 }, 905 "allOf": [ 906 { 907 "additionalProperties": true 908 } 909 ], 910 "unevaluatedProperties": false 911 }, 912 "tests": [ 913 { 914 "description": "with no additional properties", 915 "data": { 916 "foo": "foo" 917 }, 918 "valid": true 919 }, 920 { 921 "description": "with additional properties", 922 "data": { 923 "foo": "foo", 924 "bar": "bar" 925 }, 926 "valid": true 927 } 928 ] 929 }, 930 { 931 "description": "unevaluatedProperties with nested unevaluatedProperties", 932 "schema": { 933 "type": "object", 934 "properties": { 935 "foo": { 936 "type": "string" 937 } 938 }, 939 "allOf": [ 940 { 941 "unevaluatedProperties": true 942 } 943 ], 944 "unevaluatedProperties": { 945 "type": "string", 946 "maxLength": 2 947 } 948 }, 949 "tests": [ 950 { 951 "description": "with no nested unevaluated properties", 952 "data": { 953 "foo": "foo" 954 }, 955 "valid": true 956 }, 957 { 958 "description": "with nested unevaluated properties", 959 "data": { 960 "foo": "foo", 961 "bar": "bar" 962 }, 963 "valid": true 964 } 965 ] 966 }, 967 { 968 "description": "unevaluatedProperties with anyOf", 969 "schema": { 970 "type": "object", 971 "properties": { 972 "foo": { 973 "type": "string" 974 } 975 }, 976 "anyOf": [ 977 { 978 "properties": { 979 "bar": { 980 "const": "bar" 981 } 982 }, 983 "required": [ 984 "bar" 985 ] 986 }, 987 { 988 "properties": { 989 "baz": { 990 "const": "baz" 991 } 992 }, 993 "required": [ 994 "baz" 995 ] 996 }, 997 { 998 "properties": { 999 "quux": { 1000 "const": "quux" 1001 } 1002 }, 1003 "required": [ 1004 "quux" 1005 ] 1006 } 1007 ], 1008 "unevaluatedProperties": false 1009 }, 1010 "tests": [ 1011 { 1012 "description": "when one matches and has no unevaluated properties", 1013 "data": { 1014 "foo": "foo", 1015 "bar": "bar" 1016 }, 1017 "valid": true 1018 }, 1019 { 1020 "description": "when one matches and has unevaluated properties", 1021 "data": { 1022 "foo": "foo", 1023 "bar": "bar", 1024 "baz": "not-baz" 1025 }, 1026 "valid": false 1027 }, 1028 { 1029 "description": "when two match and has unevaluated properties", 1030 "data": { 1031 "foo": "foo", 1032 "bar": "bar", 1033 "baz": "baz", 1034 "quux": "not-quux" 1035 }, 1036 "valid": false 1037 } 1038 ] 1039 }, 1040 { 1041 "description": "unevaluatedProperties with oneOf", 1042 "schema": { 1043 "type": "object", 1044 "properties": { 1045 "foo": { 1046 "type": "string" 1047 } 1048 }, 1049 "oneOf": [ 1050 { 1051 "properties": { 1052 "bar": { 1053 "const": "bar" 1054 } 1055 }, 1056 "required": [ 1057 "bar" 1058 ] 1059 }, 1060 { 1061 "properties": { 1062 "baz": { 1063 "const": "baz" 1064 } 1065 }, 1066 "required": [ 1067 "baz" 1068 ] 1069 } 1070 ], 1071 "unevaluatedProperties": false 1072 }, 1073 "tests": [ 1074 { 1075 "description": "with no unevaluated properties", 1076 "data": { 1077 "foo": "foo", 1078 "bar": "bar" 1079 }, 1080 "valid": true 1081 }, 1082 { 1083 "description": "with unevaluated properties", 1084 "data": { 1085 "foo": "foo", 1086 "bar": "bar", 1087 "quux": "quux" 1088 }, 1089 "valid": false 1090 } 1091 ] 1092 }, 1093 { 1094 "description": "unevaluatedProperties with not", 1095 "schema": { 1096 "type": "object", 1097 "properties": { 1098 "foo": { 1099 "type": "string" 1100 } 1101 }, 1102 "not": { 1103 "not": { 1104 "properties": { 1105 "bar": { 1106 "const": "bar" 1107 } 1108 }, 1109 "required": [ 1110 "bar" 1111 ] 1112 } 1113 }, 1114 "unevaluatedProperties": false 1115 }, 1116 "tests": [ 1117 { 1118 "description": "with unevaluated properties", 1119 "data": { 1120 "foo": "foo", 1121 "bar": "bar" 1122 }, 1123 "valid": false 1124 } 1125 ] 1126 }, 1127 { 1128 "description": "unevaluatedProperties with if/then/else", 1129 "schema": { 1130 "type": "object", 1131 "if": { 1132 "properties": { 1133 "foo": { 1134 "const": "then" 1135 } 1136 }, 1137 "required": [ 1138 "foo" 1139 ] 1140 }, 1141 "then": { 1142 "properties": { 1143 "bar": { 1144 "type": "string" 1145 } 1146 }, 1147 "required": [ 1148 "bar" 1149 ] 1150 }, 1151 "else": { 1152 "properties": { 1153 "baz": { 1154 "type": "string" 1155 } 1156 }, 1157 "required": [ 1158 "baz" 1159 ] 1160 }, 1161 "unevaluatedProperties": false 1162 }, 1163 "tests": [ 1164 { 1165 "description": "when if is true and has no unevaluated properties", 1166 "data": { 1167 "foo": "then", 1168 "bar": "bar" 1169 }, 1170 "valid": true 1171 }, 1172 { 1173 "description": "when if is true and has unevaluated properties", 1174 "data": { 1175 "foo": "then", 1176 "bar": "bar", 1177 "baz": "baz" 1178 }, 1179 "valid": false 1180 }, 1181 { 1182 "description": "when if is false and has no unevaluated properties", 1183 "data": { 1184 "baz": "baz" 1185 }, 1186 "valid": true 1187 }, 1188 { 1189 "description": "when if is false and has unevaluated properties", 1190 "data": { 1191 "foo": "else", 1192 "baz": "baz" 1193 }, 1194 "valid": false 1195 } 1196 ] 1197 }, 1198 { 1199 "description": "unevaluatedProperties with if/then/else, then not defined", 1200 "schema": { 1201 "type": "object", 1202 "if": { 1203 "properties": { 1204 "foo": { 1205 "const": "then" 1206 } 1207 }, 1208 "required": [ 1209 "foo" 1210 ] 1211 }, 1212 "else": { 1213 "properties": { 1214 "baz": { 1215 "type": "string" 1216 } 1217 }, 1218 "required": [ 1219 "baz" 1220 ] 1221 }, 1222 "unevaluatedProperties": false 1223 }, 1224 "tests": [ 1225 { 1226 "description": "when if is true and has no unevaluated properties", 1227 "data": { 1228 "foo": "then", 1229 "bar": "bar" 1230 }, 1231 "valid": false 1232 }, 1233 { 1234 "description": "when if is true and has unevaluated properties", 1235 "data": { 1236 "foo": "then", 1237 "bar": "bar", 1238 "baz": "baz" 1239 }, 1240 "valid": false 1241 }, 1242 { 1243 "description": "when if is false and has no unevaluated properties", 1244 "data": { 1245 "baz": "baz" 1246 }, 1247 "valid": true 1248 }, 1249 { 1250 "description": "when if is false and has unevaluated properties", 1251 "data": { 1252 "foo": "else", 1253 "baz": "baz" 1254 }, 1255 "valid": false 1256 } 1257 ] 1258 }, 1259 { 1260 "description": "unevaluatedProperties with if/then/else, else not defined", 1261 "schema": { 1262 "type": "object", 1263 "if": { 1264 "properties": { 1265 "foo": { 1266 "const": "then" 1267 } 1268 }, 1269 "required": [ 1270 "foo" 1271 ] 1272 }, 1273 "then": { 1274 "properties": { 1275 "bar": { 1276 "type": "string" 1277 } 1278 }, 1279 "required": [ 1280 "bar" 1281 ] 1282 }, 1283 "unevaluatedProperties": false 1284 }, 1285 "tests": [ 1286 { 1287 "description": "when if is true and has no unevaluated properties", 1288 "data": { 1289 "foo": "then", 1290 "bar": "bar" 1291 }, 1292 "valid": true 1293 }, 1294 { 1295 "description": "when if is true and has unevaluated properties", 1296 "data": { 1297 "foo": "then", 1298 "bar": "bar", 1299 "baz": "baz" 1300 }, 1301 "valid": false 1302 }, 1303 { 1304 "description": "when if is false and has no unevaluated properties", 1305 "data": { 1306 "baz": "baz" 1307 }, 1308 "valid": false 1309 }, 1310 { 1311 "description": "when if is false and has unevaluated properties", 1312 "data": { 1313 "foo": "else", 1314 "baz": "baz" 1315 }, 1316 "valid": false 1317 } 1318 ] 1319 }, 1320 { 1321 "description": "unevaluatedProperties with dependentSchemas", 1322 "schema": { 1323 "type": "object", 1324 "properties": { 1325 "foo": { 1326 "type": "string" 1327 } 1328 }, 1329 "dependentSchemas": { 1330 "foo": { 1331 "properties": { 1332 "bar": { 1333 "const": "bar" 1334 } 1335 }, 1336 "required": [ 1337 "bar" 1338 ] 1339 } 1340 }, 1341 "unevaluatedProperties": false 1342 }, 1343 "tests": [ 1344 { 1345 "description": "with no unevaluated properties", 1346 "data": { 1347 "foo": "foo", 1348 "bar": "bar" 1349 }, 1350 "valid": true 1351 }, 1352 { 1353 "description": "with unevaluated properties", 1354 "data": { 1355 "bar": "bar" 1356 }, 1357 "valid": false 1358 } 1359 ] 1360 }, 1361 { 1362 "description": "unevaluatedProperties with boolean schemas", 1363 "schema": { 1364 "type": "object", 1365 "properties": { 1366 "foo": { 1367 "type": "string" 1368 } 1369 }, 1370 "allOf": [ 1371 true 1372 ], 1373 "unevaluatedProperties": false 1374 }, 1375 "tests": [ 1376 { 1377 "description": "with no unevaluated properties", 1378 "data": { 1379 "foo": "foo" 1380 }, 1381 "valid": true 1382 }, 1383 { 1384 "description": "with unevaluated properties", 1385 "data": { 1386 "bar": "bar" 1387 }, 1388 "valid": false 1389 } 1390 ] 1391 }, 1392 { 1393 "description": "unevaluatedProperties with $ref", 1394 "schema": { 1395 "type": "object", 1396 "$ref": "#/$defs/bar", 1397 "properties": { 1398 "foo": { 1399 "type": "string" 1400 } 1401 }, 1402 "unevaluatedProperties": false, 1403 "$defs": { 1404 "bar": { 1405 "properties": { 1406 "bar": { 1407 "type": "string" 1408 } 1409 } 1410 } 1411 } 1412 }, 1413 "tests": [ 1414 { 1415 "description": "with no unevaluated properties", 1416 "data": { 1417 "foo": "foo", 1418 "bar": "bar" 1419 }, 1420 "valid": true 1421 }, 1422 { 1423 "description": "with unevaluated properties", 1424 "data": { 1425 "foo": "foo", 1426 "bar": "bar", 1427 "baz": "baz" 1428 }, 1429 "valid": false 1430 } 1431 ] 1432 }, 1433 { 1434 "description": "unevaluatedProperties can't see inside cousins", 1435 "schema": { 1436 "allOf": [ 1437 { 1438 "properties": { 1439 "foo": true 1440 } 1441 }, 1442 { 1443 "unevaluatedProperties": false 1444 } 1445 ] 1446 }, 1447 "tests": [ 1448 { 1449 "description": "always fails", 1450 "data": { 1451 "foo": 1 1452 }, 1453 "valid": false 1454 } 1455 ] 1456 }, 1457 { 1458 "description": "nested unevaluatedProperties, outer false, inner true, properties outside", 1459 "schema": { 1460 "type": "object", 1461 "properties": { 1462 "foo": { 1463 "type": "string" 1464 } 1465 }, 1466 "allOf": [ 1467 { 1468 "unevaluatedProperties": true 1469 } 1470 ], 1471 "unevaluatedProperties": false 1472 }, 1473 "tests": [ 1474 { 1475 "description": "with no nested unevaluated properties", 1476 "data": { 1477 "foo": "foo" 1478 }, 1479 "valid": true 1480 }, 1481 { 1482 "description": "with nested unevaluated properties", 1483 "data": { 1484 "foo": "foo", 1485 "bar": "bar" 1486 }, 1487 "valid": true 1488 } 1489 ] 1490 }, 1491 { 1492 "description": "nested unevaluatedProperties, outer false, inner true, properties inside", 1493 "schema": { 1494 "type": "object", 1495 "allOf": [ 1496 { 1497 "properties": { 1498 "foo": { 1499 "type": "string" 1500 } 1501 }, 1502 "unevaluatedProperties": true 1503 } 1504 ], 1505 "unevaluatedProperties": false 1506 }, 1507 "tests": [ 1508 { 1509 "description": "with no nested unevaluated properties", 1510 "data": { 1511 "foo": "foo" 1512 }, 1513 "valid": true 1514 }, 1515 { 1516 "description": "with nested unevaluated properties", 1517 "data": { 1518 "foo": "foo", 1519 "bar": "bar" 1520 }, 1521 "valid": true 1522 } 1523 ] 1524 }, 1525 { 1526 "description": "nested unevaluatedProperties, outer true, inner false, properties outside", 1527 "schema": { 1528 "type": "object", 1529 "properties": { 1530 "foo": { 1531 "type": "string" 1532 } 1533 }, 1534 "allOf": [ 1535 { 1536 "unevaluatedProperties": false 1537 } 1538 ], 1539 "unevaluatedProperties": true 1540 }, 1541 "tests": [ 1542 { 1543 "description": "with no nested unevaluated properties", 1544 "data": { 1545 "foo": "foo" 1546 }, 1547 "valid": false 1548 }, 1549 { 1550 "description": "with nested unevaluated properties", 1551 "data": { 1552 "foo": "foo", 1553 "bar": "bar" 1554 }, 1555 "valid": false 1556 } 1557 ] 1558 }, 1559 { 1560 "description": "nested unevaluatedProperties, outer true, inner false, properties inside", 1561 "schema": { 1562 "type": "object", 1563 "allOf": [ 1564 { 1565 "properties": { 1566 "foo": { 1567 "type": "string" 1568 } 1569 }, 1570 "unevaluatedProperties": false 1571 } 1572 ], 1573 "unevaluatedProperties": true 1574 }, 1575 "tests": [ 1576 { 1577 "description": "with no nested unevaluated properties", 1578 "data": { 1579 "foo": "foo" 1580 }, 1581 "valid": true 1582 }, 1583 { 1584 "description": "with nested unevaluated properties", 1585 "data": { 1586 "foo": "foo", 1587 "bar": "bar" 1588 }, 1589 "valid": false 1590 } 1591 ] 1592 }, 1593 { 1594 "description": "cousin unevaluatedProperties, true and false, true with properties", 1595 "schema": { 1596 "type": "object", 1597 "allOf": [ 1598 { 1599 "properties": { 1600 "foo": { 1601 "type": "string" 1602 } 1603 }, 1604 "unevaluatedProperties": true 1605 }, 1606 { 1607 "unevaluatedProperties": false 1608 } 1609 ] 1610 }, 1611 "tests": [ 1612 { 1613 "description": "with no nested unevaluated properties", 1614 "data": { 1615 "foo": "foo" 1616 }, 1617 "valid": false 1618 }, 1619 { 1620 "description": "with nested unevaluated properties", 1621 "data": { 1622 "foo": "foo", 1623 "bar": "bar" 1624 }, 1625 "valid": false 1626 } 1627 ] 1628 }, 1629 { 1630 "description": "cousin unevaluatedProperties, true and false, false with properties", 1631 "schema": { 1632 "type": "object", 1633 "allOf": [ 1634 { 1635 "unevaluatedProperties": true 1636 }, 1637 { 1638 "properties": { 1639 "foo": { 1640 "type": "string" 1641 } 1642 }, 1643 "unevaluatedProperties": false 1644 } 1645 ] 1646 }, 1647 "tests": [ 1648 { 1649 "description": "with no nested unevaluated properties", 1650 "data": { 1651 "foo": "foo" 1652 }, 1653 "valid": true 1654 }, 1655 { 1656 "description": "with nested unevaluated properties", 1657 "data": { 1658 "foo": "foo", 1659 "bar": "bar" 1660 }, 1661 "valid": false 1662 } 1663 ] 1664 }, 1665 { 1666 "description": "property is evaluated in an uncle schema to unevaluatedProperties", 1667 "comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations", 1668 "schema": { 1669 "type": "object", 1670 "properties": { 1671 "foo": { 1672 "type": "object", 1673 "properties": { 1674 "bar": { 1675 "type": "string" 1676 } 1677 }, 1678 "unevaluatedProperties": false 1679 } 1680 }, 1681 "anyOf": [ 1682 { 1683 "properties": { 1684 "foo": { 1685 "properties": { 1686 "faz": { 1687 "type": "string" 1688 } 1689 } 1690 } 1691 } 1692 } 1693 ] 1694 }, 1695 "tests": [ 1696 { 1697 "description": "no extra properties", 1698 "data": { 1699 "foo": { 1700 "bar": "test" 1701 } 1702 }, 1703 "valid": true 1704 }, 1705 { 1706 "description": "uncle keyword evaluation is not significant", 1707 "data": { 1708 "foo": { 1709 "bar": "test", 1710 "faz": "test" 1711 } 1712 }, 1713 "valid": false 1714 } 1715 ] 1716 }, 1717 { 1718 "description": "in-place applicator siblings, allOf has unevaluated", 1719 "schema": { 1720 "type": "object", 1721 "allOf": [ 1722 { 1723 "properties": { 1724 "foo": true 1725 }, 1726 "unevaluatedProperties": false 1727 } 1728 ], 1729 "anyOf": [ 1730 { 1731 "properties": { 1732 "bar": true 1733 } 1734 } 1735 ] 1736 }, 1737 "tests": [ 1738 { 1739 "description": "base case: both properties present", 1740 "data": { 1741 "foo": 1, 1742 "bar": 1 1743 }, 1744 "valid": false 1745 }, 1746 { 1747 "description": "in place applicator siblings, bar is missing", 1748 "data": { 1749 "foo": 1 1750 }, 1751 "valid": true 1752 }, 1753 { 1754 "description": "in place applicator siblings, foo is missing", 1755 "data": { 1756 "bar": 1 1757 }, 1758 "valid": false 1759 } 1760 ] 1761 }, 1762 { 1763 "description": "in-place applicator siblings, anyOf has unevaluated", 1764 "schema": { 1765 "type": "object", 1766 "allOf": [ 1767 { 1768 "properties": { 1769 "foo": true 1770 } 1771 } 1772 ], 1773 "anyOf": [ 1774 { 1775 "properties": { 1776 "bar": true 1777 }, 1778 "unevaluatedProperties": false 1779 } 1780 ] 1781 }, 1782 "tests": [ 1783 { 1784 "description": "base case: both properties present", 1785 "data": { 1786 "foo": 1, 1787 "bar": 1 1788 }, 1789 "valid": false 1790 }, 1791 { 1792 "description": "in place applicator siblings, bar is missing", 1793 "data": { 1794 "foo": 1 1795 }, 1796 "valid": false 1797 }, 1798 { 1799 "description": "in place applicator siblings, foo is missing", 1800 "data": { 1801 "bar": 1 1802 }, 1803 "valid": true 1804 } 1805 ] 1806 }, 1807 { 1808 "description": "unevaluatedProperties + single cyclic ref", 1809 "schema": { 1810 "type": "object", 1811 "properties": { 1812 "x": { 1813 "$ref": "#" 1814 } 1815 }, 1816 "unevaluatedProperties": false 1817 }, 1818 "tests": [ 1819 { 1820 "description": "Empty is valid", 1821 "data": {}, 1822 "valid": true 1823 }, 1824 { 1825 "description": "Single is valid", 1826 "data": { 1827 "x": {} 1828 }, 1829 "valid": true 1830 }, 1831 { 1832 "description": "Unevaluated on 1st level is invalid", 1833 "data": { 1834 "x": {}, 1835 "y": {} 1836 }, 1837 "valid": false 1838 }, 1839 { 1840 "description": "Nested is valid", 1841 "data": { 1842 "x": { 1843 "x": {} 1844 } 1845 }, 1846 "valid": true 1847 }, 1848 { 1849 "description": "Unevaluated on 2nd level is invalid", 1850 "data": { 1851 "x": { 1852 "x": {}, 1853 "y": {} 1854 } 1855 }, 1856 "valid": false 1857 }, 1858 { 1859 "description": "Deep nested is valid", 1860 "data": { 1861 "x": { 1862 "x": { 1863 "x": {} 1864 } 1865 } 1866 }, 1867 "valid": true 1868 }, 1869 { 1870 "description": "Unevaluated on 3rd level is invalid", 1871 "data": { 1872 "x": { 1873 "x": { 1874 "x": {}, 1875 "y": {} 1876 } 1877 } 1878 }, 1879 "valid": false 1880 } 1881 ] 1882 }, 1883 { 1884 "description": "unevaluatedProperties + ref inside allOf / oneOf", 1885 "schema": { 1886 "$defs": { 1887 "one": { 1888 "properties": { 1889 "a": true 1890 } 1891 }, 1892 "two": { 1893 "required": [ 1894 "x" 1895 ], 1896 "properties": { 1897 "x": true 1898 } 1899 } 1900 }, 1901 "allOf": [ 1902 { 1903 "$ref": "#/$defs/one" 1904 }, 1905 { 1906 "properties": { 1907 "b": true 1908 } 1909 }, 1910 { 1911 "oneOf": [ 1912 { 1913 "$ref": "#/$defs/two" 1914 }, 1915 { 1916 "required": [ 1917 "y" 1918 ], 1919 "properties": { 1920 "y": true 1921 } 1922 } 1923 ] 1924 } 1925 ], 1926 "unevaluatedProperties": false 1927 }, 1928 "tests": [ 1929 { 1930 "description": "Empty is invalid (no x or y)", 1931 "data": {}, 1932 "valid": false 1933 }, 1934 { 1935 "description": "a and b are invalid (no x or y)", 1936 "data": { 1937 "a": 1, 1938 "b": 1 1939 }, 1940 "valid": false 1941 }, 1942 { 1943 "description": "x and y are invalid", 1944 "data": { 1945 "x": 1, 1946 "y": 1 1947 }, 1948 "valid": false 1949 }, 1950 { 1951 "description": "a and x are valid", 1952 "data": { 1953 "a": 1, 1954 "x": 1 1955 }, 1956 "valid": true 1957 }, 1958 { 1959 "description": "a and y are valid", 1960 "data": { 1961 "a": 1, 1962 "y": 1 1963 }, 1964 "valid": true 1965 }, 1966 { 1967 "description": "a and b and x are valid", 1968 "data": { 1969 "a": 1, 1970 "b": 1, 1971 "x": 1 1972 }, 1973 "valid": true 1974 }, 1975 { 1976 "description": "a and b and y are valid", 1977 "data": { 1978 "a": 1, 1979 "b": 1, 1980 "y": 1 1981 }, 1982 "valid": true 1983 }, 1984 { 1985 "description": "a and b and x and y are invalid", 1986 "data": { 1987 "a": 1, 1988 "b": 1, 1989 "x": 1, 1990 "y": 1 1991 }, 1992 "valid": false 1993 } 1994 ] 1995 }, 1996 { 1997 "description": "dynamic evalation inside nested refs", 1998 "schema": { 1999 "$defs": { 2000 "one": { 2001 "oneOf": [ 2002 { 2003 "$ref": "#/$defs/two" 2004 }, 2005 { 2006 "required": [ 2007 "b" 2008 ], 2009 "properties": { 2010 "b": true 2011 } 2012 }, 2013 { 2014 "required": [ 2015 "xx" 2016 ], 2017 "patternProperties": { 2018 "x": true 2019 } 2020 }, 2021 { 2022 "required": [ 2023 "all" 2024 ], 2025 "unevaluatedProperties": true 2026 } 2027 ] 2028 }, 2029 "two": { 2030 "oneOf": [ 2031 { 2032 "required": [ 2033 "c" 2034 ], 2035 "properties": { 2036 "c": true 2037 } 2038 }, 2039 { 2040 "required": [ 2041 "d" 2042 ], 2043 "properties": { 2044 "d": true 2045 } 2046 } 2047 ] 2048 } 2049 }, 2050 "oneOf": [ 2051 { 2052 "$ref": "#/$defs/one" 2053 }, 2054 { 2055 "required": [ 2056 "a" 2057 ], 2058 "properties": { 2059 "a": true 2060 } 2061 } 2062 ], 2063 "unevaluatedProperties": false 2064 }, 2065 "tests": [ 2066 { 2067 "description": "Empty is invalid", 2068 "data": {}, 2069 "valid": false 2070 }, 2071 { 2072 "description": "a is valid", 2073 "data": { 2074 "a": 1 2075 }, 2076 "valid": true 2077 }, 2078 { 2079 "description": "b is valid", 2080 "data": { 2081 "b": 1 2082 }, 2083 "valid": true 2084 }, 2085 { 2086 "description": "c is valid", 2087 "data": { 2088 "c": 1 2089 }, 2090 "valid": true 2091 }, 2092 { 2093 "description": "d is valid", 2094 "data": { 2095 "d": 1 2096 }, 2097 "valid": true 2098 }, 2099 { 2100 "description": "a + b is invalid", 2101 "data": { 2102 "a": 1, 2103 "b": 1 2104 }, 2105 "valid": false 2106 }, 2107 { 2108 "description": "a + c is invalid", 2109 "data": { 2110 "a": 1, 2111 "c": 1 2112 }, 2113 "valid": false 2114 }, 2115 { 2116 "description": "a + d is invalid", 2117 "data": { 2118 "a": 1, 2119 "d": 1 2120 }, 2121 "valid": false 2122 }, 2123 { 2124 "description": "b + c is invalid", 2125 "data": { 2126 "b": 1, 2127 "c": 1 2128 }, 2129 "valid": false 2130 }, 2131 { 2132 "description": "b + d is invalid", 2133 "data": { 2134 "b": 1, 2135 "d": 1 2136 }, 2137 "valid": false 2138 }, 2139 { 2140 "description": "c + d is invalid", 2141 "data": { 2142 "c": 1, 2143 "d": 1 2144 }, 2145 "valid": false 2146 }, 2147 { 2148 "description": "xx + a is invalid", 2149 "data": { 2150 "xx": 1, 2151 "a": 1 2152 }, 2153 "valid": false 2154 }, 2155 { 2156 "description": "xx + b is invalid", 2157 "data": { 2158 "xx": 1, 2159 "b": 1 2160 }, 2161 "valid": false 2162 }, 2163 { 2164 "description": "xx + c is invalid", 2165 "data": { 2166 "xx": 1, 2167 "c": 1 2168 }, 2169 "valid": false 2170 }, 2171 { 2172 "description": "xx + d is invalid", 2173 "data": { 2174 "xx": 1, 2175 "d": 1 2176 }, 2177 "valid": false 2178 }, 2179 { 2180 "description": "all is valid", 2181 "data": { 2182 "all": 1 2183 }, 2184 "valid": true 2185 }, 2186 { 2187 "description": "all + foo is valid", 2188 "data": { 2189 "all": 1, 2190 "foo": 1 2191 }, 2192 "valid": true 2193 }, 2194 { 2195 "description": "all + a is invalid", 2196 "data": { 2197 "all": 1, 2198 "a": 1 2199 }, 2200 "valid": false 2201 } 2202 ] 2203 }, 2204 { 2205 "description": "unevaluatedProperties with patternProperties and type union", 2206 "schema": { 2207 "type": "object", 2208 "patternProperties": { 2209 "^valid_": { 2210 "type": ["array", "string"], 2211 "items": { 2212 "type": "string" 2213 } 2214 } 2215 }, 2216 "unevaluatedProperties": false 2217 }, 2218 "tests": [ 2219 { 2220 "description": "Not valid key against pattern", 2221 "data": { 2222 "valid_array": ["array1_value", "array2_value"], 2223 "valid_string": "string_value", 2224 "invalid_key": "this is an unevaluated properties due to key not matching the pattern" 2225 }, 2226 "valid": false 2227 }, 2228 { 2229 "description": "Not valid type", 2230 "data": { 2231 "valid_array": ["array1_value", "array2_value"], 2232 "valid_string": "string_value", 2233 "valid_key": 5 2234 }, 2235 "valid": false 2236 }, 2237 { 2238 "description": "Valid", 2239 "data": { 2240 "valid_array": ["array1_value", "array2_value"], 2241 "valid_string": "string_value" 2242 }, 2243 "valid": true 2244 } 2245 ] 2246 } 2247]