cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft7/ref.json (about) 1 [ 2 { 3 "description": "root pointer ref", 4 "schema": { 5 "properties": { 6 "foo": { 7 "$ref": "#" 8 } 9 }, 10 "additionalProperties": false 11 }, 12 "tests": [ 13 { 14 "description": "match", 15 "data": { 16 "foo": false 17 }, 18 "valid": true 19 }, 20 { 21 "description": "recursive match", 22 "data": { 23 "foo": { 24 "foo": false 25 } 26 }, 27 "valid": true 28 }, 29 { 30 "description": "mismatch", 31 "data": { 32 "bar": false 33 }, 34 "valid": false 35 }, 36 { 37 "description": "recursive mismatch", 38 "data": { 39 "foo": { 40 "bar": false 41 } 42 }, 43 "valid": false 44 } 45 ] 46 }, 47 { 48 "description": "relative pointer ref to object", 49 "schema": { 50 "properties": { 51 "foo": { 52 "type": "integer" 53 }, 54 "bar": { 55 "$ref": "#/properties/foo" 56 } 57 } 58 }, 59 "tests": [ 60 { 61 "description": "match", 62 "data": { 63 "bar": 3 64 }, 65 "valid": true 66 }, 67 { 68 "description": "mismatch", 69 "data": { 70 "bar": true 71 }, 72 "valid": false 73 } 74 ] 75 }, 76 { 77 "description": "relative pointer ref to array", 78 "schema": { 79 "items": [ 80 { 81 "type": "integer" 82 }, 83 { 84 "$ref": "#/items/0" 85 } 86 ] 87 }, 88 "tests": [ 89 { 90 "description": "match array", 91 "data": [ 92 1, 93 2 94 ], 95 "valid": true 96 }, 97 { 98 "description": "mismatch array", 99 "data": [ 100 1, 101 "foo" 102 ], 103 "valid": false 104 } 105 ] 106 }, 107 { 108 "description": "escaped pointer ref", 109 "schema": { 110 "definitions": { 111 "tilde~field": { 112 "type": "integer" 113 }, 114 "slash/field": { 115 "type": "integer" 116 }, 117 "percent%field": { 118 "type": "integer" 119 } 120 }, 121 "properties": { 122 "tilde": { 123 "$ref": "#/definitions/tilde~0field" 124 }, 125 "slash": { 126 "$ref": "#/definitions/slash~1field" 127 }, 128 "percent": { 129 "$ref": "#/definitions/percent%25field" 130 } 131 } 132 }, 133 "tests": [ 134 { 135 "description": "slash invalid", 136 "data": { 137 "slash": "aoeu" 138 }, 139 "valid": false 140 }, 141 { 142 "description": "tilde invalid", 143 "data": { 144 "tilde": "aoeu" 145 }, 146 "valid": false 147 }, 148 { 149 "description": "percent invalid", 150 "data": { 151 "percent": "aoeu" 152 }, 153 "valid": false 154 }, 155 { 156 "description": "slash valid", 157 "data": { 158 "slash": 123 159 }, 160 "valid": true 161 }, 162 { 163 "description": "tilde valid", 164 "data": { 165 "tilde": 123 166 }, 167 "valid": true 168 }, 169 { 170 "description": "percent valid", 171 "data": { 172 "percent": 123 173 }, 174 "valid": true 175 } 176 ] 177 }, 178 { 179 "description": "nested refs", 180 "schema": { 181 "definitions": { 182 "a": { 183 "type": "integer" 184 }, 185 "b": { 186 "$ref": "#/definitions/a" 187 }, 188 "c": { 189 "$ref": "#/definitions/b" 190 } 191 }, 192 "allOf": [ 193 { 194 "$ref": "#/definitions/c" 195 } 196 ] 197 }, 198 "tests": [ 199 { 200 "description": "nested ref valid", 201 "data": 5, 202 "valid": true 203 }, 204 { 205 "description": "nested ref invalid", 206 "data": "a", 207 "valid": false 208 } 209 ] 210 }, 211 { 212 "description": "ref overrides any sibling keywords", 213 "schema": { 214 "definitions": { 215 "reffed": { 216 "type": "array" 217 } 218 }, 219 "properties": { 220 "foo": { 221 "$ref": "#/definitions/reffed", 222 "maxItems": 2 223 } 224 } 225 }, 226 "tests": [ 227 { 228 "description": "ref valid", 229 "data": { 230 "foo": [] 231 }, 232 "valid": true 233 }, 234 { 235 "description": "ref valid, maxItems ignored", 236 "data": { 237 "foo": [ 238 1, 239 2, 240 3 241 ] 242 }, 243 "valid": true 244 }, 245 { 246 "description": "ref invalid", 247 "data": { 248 "foo": "string" 249 }, 250 "valid": false 251 } 252 ] 253 }, 254 { 255 "description": "$ref prevents a sibling $id from changing the base uri", 256 "schema": { 257 "$id": "http://localhost:1234/sibling_id/base/", 258 "definitions": { 259 "foo": { 260 "$id": "http://localhost:1234/sibling_id/foo.json", 261 "type": "string" 262 }, 263 "base_foo": { 264 "$comment": "this canonical uri is http://localhost:1234/sibling_id/base/foo.json", 265 "$id": "foo.json", 266 "type": "number" 267 } 268 }, 269 "allOf": [ 270 { 271 "$comment": "$ref resolves to http://localhost:1234/sibling_id/base/foo.json, not http://localhost:1234/sibling_id/foo.json", 272 "$id": "http://localhost:1234/sibling_id/", 273 "$ref": "foo.json" 274 } 275 ] 276 }, 277 "tests": [ 278 { 279 "description": "$ref resolves to /definitions/base_foo, data does not validate", 280 "data": "a", 281 "valid": false 282 }, 283 { 284 "description": "$ref resolves to /definitions/base_foo, data validates", 285 "data": 1, 286 "valid": true 287 } 288 ] 289 }, 290 { 291 "description": "remote ref, containing refs itself", 292 "schema": { 293 "$ref": "http://json-schema.org/draft-07/schema#" 294 }, 295 "skip": { 296 "v2": "extract error: cannot compile resulting schema: package \"json-schema.org/draft-07/schema\" imported but not defined in :\n generated.cue:1:8\n", 297 "v3": "extract error: cannot compile resulting schema: package \"json-schema.org/draft-07/schema\" imported but not defined in :\n generated.cue:1:8\n" 298 }, 299 "tests": [ 300 { 301 "description": "remote ref valid", 302 "data": { 303 "minLength": 1 304 }, 305 "valid": true, 306 "skip": { 307 "v2": "could not compile schema", 308 "v3": "could not compile schema" 309 } 310 }, 311 { 312 "description": "remote ref invalid", 313 "data": { 314 "minLength": -1 315 }, 316 "valid": false, 317 "skip": { 318 "v2": "could not compile schema", 319 "v3": "could not compile schema" 320 } 321 } 322 ] 323 }, 324 { 325 "description": "property named $ref that is not a reference", 326 "schema": { 327 "properties": { 328 "$ref": { 329 "type": "string" 330 } 331 } 332 }, 333 "tests": [ 334 { 335 "description": "property named $ref valid", 336 "data": { 337 "$ref": "a" 338 }, 339 "valid": true 340 }, 341 { 342 "description": "property named $ref invalid", 343 "data": { 344 "$ref": 2 345 }, 346 "valid": false 347 } 348 ] 349 }, 350 { 351 "description": "property named $ref, containing an actual $ref", 352 "schema": { 353 "properties": { 354 "$ref": { 355 "$ref": "#/definitions/is-string" 356 } 357 }, 358 "definitions": { 359 "is-string": { 360 "type": "string" 361 } 362 } 363 }, 364 "tests": [ 365 { 366 "description": "property named $ref valid", 367 "data": { 368 "$ref": "a" 369 }, 370 "valid": true 371 }, 372 { 373 "description": "property named $ref invalid", 374 "data": { 375 "$ref": 2 376 }, 377 "valid": false 378 } 379 ] 380 }, 381 { 382 "description": "$ref to boolean schema true", 383 "schema": { 384 "allOf": [ 385 { 386 "$ref": "#/definitions/bool" 387 } 388 ], 389 "definitions": { 390 "bool": true 391 } 392 }, 393 "tests": [ 394 { 395 "description": "any value is valid", 396 "data": "foo", 397 "valid": true 398 } 399 ] 400 }, 401 { 402 "description": "$ref to boolean schema false", 403 "schema": { 404 "allOf": [ 405 { 406 "$ref": "#/definitions/bool" 407 } 408 ], 409 "definitions": { 410 "bool": false 411 } 412 }, 413 "skip": { 414 "v2": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:4:8\n", 415 "v3": "extract error: cannot compile resulting schema: explicit error (_|_ literal) in source:\n generated.cue:4:8\n" 416 }, 417 "tests": [ 418 { 419 "description": "any value is invalid", 420 "data": "foo", 421 "valid": false, 422 "skip": { 423 "v2": "could not compile schema", 424 "v3": "could not compile schema" 425 } 426 } 427 ] 428 }, 429 { 430 "description": "Recursive references between schemas", 431 "schema": { 432 "$id": "http://localhost:1234/tree", 433 "description": "tree of nodes", 434 "type": "object", 435 "properties": { 436 "meta": { 437 "type": "string" 438 }, 439 "nodes": { 440 "type": "array", 441 "items": { 442 "$ref": "node" 443 } 444 } 445 }, 446 "required": [ 447 "meta", 448 "nodes" 449 ], 450 "definitions": { 451 "node": { 452 "$id": "http://localhost:1234/node", 453 "description": "node", 454 "type": "object", 455 "properties": { 456 "value": { 457 "type": "number" 458 }, 459 "subtree": { 460 "$ref": "tree" 461 } 462 }, 463 "required": [ 464 "value" 465 ] 466 } 467 } 468 }, 469 "tests": [ 470 { 471 "description": "valid tree", 472 "data": { 473 "meta": "root", 474 "nodes": [ 475 { 476 "value": 1, 477 "subtree": { 478 "meta": "child", 479 "nodes": [ 480 { 481 "value": 1.1 482 }, 483 { 484 "value": 1.2 485 } 486 ] 487 } 488 }, 489 { 490 "value": 2, 491 "subtree": { 492 "meta": "child", 493 "nodes": [ 494 { 495 "value": 2.1 496 }, 497 { 498 "value": 2.2 499 } 500 ] 501 } 502 } 503 ] 504 }, 505 "valid": true 506 }, 507 { 508 "description": "invalid tree", 509 "data": { 510 "meta": "root", 511 "nodes": [ 512 { 513 "value": 1, 514 "subtree": { 515 "meta": "child", 516 "nodes": [ 517 { 518 "value": "string is invalid" 519 }, 520 { 521 "value": 1.2 522 } 523 ] 524 } 525 }, 526 { 527 "value": 2, 528 "subtree": { 529 "meta": "child", 530 "nodes": [ 531 { 532 "value": 2.1 533 }, 534 { 535 "value": 2.2 536 } 537 ] 538 } 539 } 540 ] 541 }, 542 "valid": false 543 } 544 ] 545 }, 546 { 547 "description": "refs with quote", 548 "schema": { 549 "properties": { 550 "foo\"bar": { 551 "$ref": "#/definitions/foo%22bar" 552 } 553 }, 554 "definitions": { 555 "foo\"bar": { 556 "type": "number" 557 } 558 } 559 }, 560 "tests": [ 561 { 562 "description": "object with numbers is valid", 563 "data": { 564 "foo\"bar": 1 565 }, 566 "valid": true 567 }, 568 { 569 "description": "object with strings is invalid", 570 "data": { 571 "foo\"bar": "1" 572 }, 573 "valid": false 574 } 575 ] 576 }, 577 { 578 "description": "Location-independent identifier", 579 "schema": { 580 "allOf": [ 581 { 582 "$ref": "#foo" 583 } 584 ], 585 "definitions": { 586 "A": { 587 "$id": "#foo", 588 "type": "integer" 589 } 590 } 591 }, 592 "skip": { 593 "v2": "extract error: $id URI may not contain a fragment (and 3 more errors)", 594 "v3": "extract error: $id URI may not contain a fragment (and 3 more errors)" 595 }, 596 "tests": [ 597 { 598 "description": "match", 599 "data": 1, 600 "valid": true, 601 "skip": { 602 "v2": "could not compile schema", 603 "v3": "could not compile schema" 604 } 605 }, 606 { 607 "description": "mismatch", 608 "data": "a", 609 "valid": false, 610 "skip": { 611 "v2": "could not compile schema", 612 "v3": "could not compile schema" 613 } 614 } 615 ] 616 }, 617 { 618 "description": "Reference an anchor with a non-relative URI", 619 "schema": { 620 "$id": "https://example.com/schema-with-anchor", 621 "allOf": [ 622 { 623 "$ref": "https://example.com/schema-with-anchor#foo" 624 } 625 ], 626 "definitions": { 627 "A": { 628 "$id": "#foo", 629 "type": "integer" 630 } 631 } 632 }, 633 "skip": { 634 "v2": "extract error: $id URI may not contain a fragment (and 3 more errors)", 635 "v3": "extract error: $id URI may not contain a fragment (and 3 more errors)" 636 }, 637 "tests": [ 638 { 639 "description": "match", 640 "data": 1, 641 "valid": true, 642 "skip": { 643 "v2": "could not compile schema", 644 "v3": "could not compile schema" 645 } 646 }, 647 { 648 "description": "mismatch", 649 "data": "a", 650 "valid": false, 651 "skip": { 652 "v2": "could not compile schema", 653 "v3": "could not compile schema" 654 } 655 } 656 ] 657 }, 658 { 659 "description": "Location-independent identifier with base URI change in subschema", 660 "schema": { 661 "$id": "http://localhost:1234/root", 662 "allOf": [ 663 { 664 "$ref": "http://localhost:1234/nested.json#foo" 665 } 666 ], 667 "definitions": { 668 "A": { 669 "$id": "nested.json", 670 "definitions": { 671 "B": { 672 "$id": "#foo", 673 "type": "integer" 674 } 675 } 676 } 677 } 678 }, 679 "skip": { 680 "v2": "extract error: $id URI may not contain a fragment (and 3 more errors)", 681 "v3": "extract error: $id URI may not contain a fragment (and 3 more errors)" 682 }, 683 "tests": [ 684 { 685 "description": "match", 686 "data": 1, 687 "valid": true, 688 "skip": { 689 "v2": "could not compile schema", 690 "v3": "could not compile schema" 691 } 692 }, 693 { 694 "description": "mismatch", 695 "data": "a", 696 "valid": false, 697 "skip": { 698 "v2": "could not compile schema", 699 "v3": "could not compile schema" 700 } 701 } 702 ] 703 }, 704 { 705 "description": "naive replacement of $ref with its destination is not correct", 706 "schema": { 707 "definitions": { 708 "a_string": { 709 "type": "string" 710 } 711 }, 712 "enum": [ 713 { 714 "$ref": "#/definitions/a_string" 715 } 716 ] 717 }, 718 "tests": [ 719 { 720 "description": "do not evaluate the $ref inside the enum, matching any string", 721 "data": "this is a string", 722 "valid": false 723 }, 724 { 725 "description": "do not evaluate the $ref inside the enum, definition exact match", 726 "data": { 727 "type": "string" 728 }, 729 "valid": false 730 }, 731 { 732 "description": "match the enum exactly", 733 "data": { 734 "$ref": "#/definitions/a_string" 735 }, 736 "valid": true 737 } 738 ] 739 }, 740 { 741 "description": "refs with relative uris and defs", 742 "schema": { 743 "$id": "http://example.com/schema-relative-uri-defs1.json", 744 "properties": { 745 "foo": { 746 "$id": "schema-relative-uri-defs2.json", 747 "definitions": { 748 "inner": { 749 "properties": { 750 "bar": { 751 "type": "string" 752 } 753 } 754 } 755 }, 756 "allOf": [ 757 { 758 "$ref": "#/definitions/inner" 759 } 760 ] 761 } 762 }, 763 "allOf": [ 764 { 765 "$ref": "schema-relative-uri-defs2.json" 766 } 767 ] 768 }, 769 "tests": [ 770 { 771 "description": "invalid on inner field", 772 "data": { 773 "foo": { 774 "bar": 1 775 }, 776 "bar": "a" 777 }, 778 "valid": false 779 }, 780 { 781 "description": "invalid on outer field", 782 "data": { 783 "foo": { 784 "bar": "a" 785 }, 786 "bar": 1 787 }, 788 "valid": false 789 }, 790 { 791 "description": "valid on both fields", 792 "data": { 793 "foo": { 794 "bar": "a" 795 }, 796 "bar": "a" 797 }, 798 "valid": true 799 } 800 ] 801 }, 802 { 803 "description": "relative refs with absolute uris and defs", 804 "schema": { 805 "$id": "http://example.com/schema-refs-absolute-uris-defs1.json", 806 "properties": { 807 "foo": { 808 "$id": "http://example.com/schema-refs-absolute-uris-defs2.json", 809 "definitions": { 810 "inner": { 811 "properties": { 812 "bar": { 813 "type": "string" 814 } 815 } 816 } 817 }, 818 "allOf": [ 819 { 820 "$ref": "#/definitions/inner" 821 } 822 ] 823 } 824 }, 825 "allOf": [ 826 { 827 "$ref": "schema-refs-absolute-uris-defs2.json" 828 } 829 ] 830 }, 831 "tests": [ 832 { 833 "description": "invalid on inner field", 834 "data": { 835 "foo": { 836 "bar": 1 837 }, 838 "bar": "a" 839 }, 840 "valid": false 841 }, 842 { 843 "description": "invalid on outer field", 844 "data": { 845 "foo": { 846 "bar": "a" 847 }, 848 "bar": 1 849 }, 850 "valid": false 851 }, 852 { 853 "description": "valid on both fields", 854 "data": { 855 "foo": { 856 "bar": "a" 857 }, 858 "bar": "a" 859 }, 860 "valid": true 861 } 862 ] 863 }, 864 { 865 "description": "$id must be resolved against nearest parent, not just immediate parent", 866 "schema": { 867 "$id": "http://example.com/a.json", 868 "definitions": { 869 "x": { 870 "$id": "http://example.com/b/c.json", 871 "not": { 872 "definitions": { 873 "y": { 874 "$id": "d.json", 875 "type": "number" 876 } 877 } 878 } 879 } 880 }, 881 "allOf": [ 882 { 883 "$ref": "http://example.com/b/d.json" 884 } 885 ] 886 }, 887 "tests": [ 888 { 889 "description": "number is valid", 890 "data": 1, 891 "valid": true 892 }, 893 { 894 "description": "non-number is invalid", 895 "data": "a", 896 "valid": false 897 } 898 ] 899 }, 900 { 901 "description": "simple URN base URI with $ref via the URN", 902 "schema": { 903 "$comment": "URIs do not have to have HTTP(s) schemes", 904 "$id": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed", 905 "minimum": 30, 906 "properties": { 907 "foo": { 908 "$ref": "urn:uuid:deadbeef-1234-ffff-ffff-4321feebdaed" 909 } 910 } 911 }, 912 "tests": [ 913 { 914 "description": "valid under the URN IDed schema", 915 "data": { 916 "foo": 37 917 }, 918 "valid": true 919 }, 920 { 921 "description": "invalid under the URN IDed schema", 922 "data": { 923 "foo": 12 924 }, 925 "valid": false 926 } 927 ] 928 }, 929 { 930 "description": "simple URN base URI with JSON pointer", 931 "schema": { 932 "$comment": "URIs do not have to have HTTP(s) schemes", 933 "$id": "urn:uuid:deadbeef-1234-00ff-ff00-4321feebdaed", 934 "properties": { 935 "foo": { 936 "$ref": "#/definitions/bar" 937 } 938 }, 939 "definitions": { 940 "bar": { 941 "type": "string" 942 } 943 } 944 }, 945 "tests": [ 946 { 947 "description": "a string is valid", 948 "data": { 949 "foo": "bar" 950 }, 951 "valid": true 952 }, 953 { 954 "description": "a non-string is invalid", 955 "data": { 956 "foo": 12 957 }, 958 "valid": false 959 } 960 ] 961 }, 962 { 963 "description": "URN base URI with NSS", 964 "schema": { 965 "$comment": "RFC 8141 §2.2", 966 "$id": "urn:example:1/406/47452/2", 967 "properties": { 968 "foo": { 969 "$ref": "#/definitions/bar" 970 } 971 }, 972 "definitions": { 973 "bar": { 974 "type": "string" 975 } 976 } 977 }, 978 "tests": [ 979 { 980 "description": "a string is valid", 981 "data": { 982 "foo": "bar" 983 }, 984 "valid": true 985 }, 986 { 987 "description": "a non-string is invalid", 988 "data": { 989 "foo": 12 990 }, 991 "valid": false 992 } 993 ] 994 }, 995 { 996 "description": "URN base URI with r-component", 997 "schema": { 998 "$comment": "RFC 8141 §2.3.1", 999 "$id": "urn:example:foo-bar-baz-qux?+CCResolve:cc=uk", 1000 "properties": { 1001 "foo": { 1002 "$ref": "#/definitions/bar" 1003 } 1004 }, 1005 "definitions": { 1006 "bar": { 1007 "type": "string" 1008 } 1009 } 1010 }, 1011 "tests": [ 1012 { 1013 "description": "a string is valid", 1014 "data": { 1015 "foo": "bar" 1016 }, 1017 "valid": true 1018 }, 1019 { 1020 "description": "a non-string is invalid", 1021 "data": { 1022 "foo": 12 1023 }, 1024 "valid": false 1025 } 1026 ] 1027 }, 1028 { 1029 "description": "URN base URI with q-component", 1030 "schema": { 1031 "$comment": "RFC 8141 §2.3.2", 1032 "$id": "urn:example:weather?=op=map\u0026lat=39.56\u0026lon=-104.85\u0026datetime=1969-07-21T02:56:15Z", 1033 "properties": { 1034 "foo": { 1035 "$ref": "#/definitions/bar" 1036 } 1037 }, 1038 "definitions": { 1039 "bar": { 1040 "type": "string" 1041 } 1042 } 1043 }, 1044 "tests": [ 1045 { 1046 "description": "a string is valid", 1047 "data": { 1048 "foo": "bar" 1049 }, 1050 "valid": true 1051 }, 1052 { 1053 "description": "a non-string is invalid", 1054 "data": { 1055 "foo": 12 1056 }, 1057 "valid": false 1058 } 1059 ] 1060 }, 1061 { 1062 "description": "URN base URI with URN and JSON pointer ref", 1063 "schema": { 1064 "$id": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed", 1065 "properties": { 1066 "foo": { 1067 "$ref": "urn:uuid:deadbeef-1234-0000-0000-4321feebdaed#/definitions/bar" 1068 } 1069 }, 1070 "definitions": { 1071 "bar": { 1072 "type": "string" 1073 } 1074 } 1075 }, 1076 "tests": [ 1077 { 1078 "description": "a string is valid", 1079 "data": { 1080 "foo": "bar" 1081 }, 1082 "valid": true 1083 }, 1084 { 1085 "description": "a non-string is invalid", 1086 "data": { 1087 "foo": 12 1088 }, 1089 "valid": false 1090 } 1091 ] 1092 }, 1093 { 1094 "description": "URN base URI with URN and anchor ref", 1095 "schema": { 1096 "$id": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed", 1097 "properties": { 1098 "foo": { 1099 "$ref": "urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something" 1100 } 1101 }, 1102 "definitions": { 1103 "bar": { 1104 "$id": "#something", 1105 "type": "string" 1106 } 1107 } 1108 }, 1109 "skip": { 1110 "v2": "extract error: cannot determine CUE location for JSON Schema location id=urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something: anchors (something) not supported (and 3 more errors)", 1111 "v3": "extract error: cannot determine CUE location for JSON Schema location id=urn:uuid:deadbeef-1234-ff00-00ff-4321feebdaed#something: anchors (something) not supported (and 3 more errors)" 1112 }, 1113 "tests": [ 1114 { 1115 "description": "a string is valid", 1116 "data": { 1117 "foo": "bar" 1118 }, 1119 "valid": true, 1120 "skip": { 1121 "v2": "could not compile schema", 1122 "v3": "could not compile schema" 1123 } 1124 }, 1125 { 1126 "description": "a non-string is invalid", 1127 "data": { 1128 "foo": 12 1129 }, 1130 "valid": false, 1131 "skip": { 1132 "v2": "could not compile schema", 1133 "v3": "could not compile schema" 1134 } 1135 } 1136 ] 1137 }, 1138 { 1139 "description": "ref to if", 1140 "schema": { 1141 "allOf": [ 1142 { 1143 "$ref": "http://example.com/ref/if" 1144 }, 1145 { 1146 "if": { 1147 "$id": "http://example.com/ref/if", 1148 "type": "integer" 1149 } 1150 } 1151 ] 1152 }, 1153 "skip": { 1154 "v2": "extract error: cannot compile resulting schema: package \"example.com/ref/if\" imported but not defined in :\n generated.cue:1:8\n", 1155 "v3": "extract error: cannot compile resulting schema: package \"example.com/ref/if\" imported but not defined in :\n generated.cue:1:8\n" 1156 }, 1157 "tests": [ 1158 { 1159 "description": "a non-integer is invalid due to the $ref", 1160 "data": "foo", 1161 "valid": false, 1162 "skip": { 1163 "v2": "could not compile schema", 1164 "v3": "could not compile schema" 1165 } 1166 }, 1167 { 1168 "description": "an integer is valid", 1169 "data": 12, 1170 "valid": true, 1171 "skip": { 1172 "v2": "could not compile schema", 1173 "v3": "could not compile schema" 1174 } 1175 } 1176 ] 1177 }, 1178 { 1179 "description": "ref to then", 1180 "schema": { 1181 "allOf": [ 1182 { 1183 "$ref": "http://example.com/ref/then" 1184 }, 1185 { 1186 "then": { 1187 "$id": "http://example.com/ref/then", 1188 "type": "integer" 1189 } 1190 } 1191 ] 1192 }, 1193 "skip": { 1194 "v2": "extract error: cannot compile resulting schema: package \"example.com/ref/then\" imported but not defined in :\n generated.cue:1:8\n", 1195 "v3": "extract error: cannot compile resulting schema: package \"example.com/ref/then\" imported but not defined in :\n generated.cue:1:8\n" 1196 }, 1197 "tests": [ 1198 { 1199 "description": "a non-integer is invalid due to the $ref", 1200 "data": "foo", 1201 "valid": false, 1202 "skip": { 1203 "v2": "could not compile schema", 1204 "v3": "could not compile schema" 1205 } 1206 }, 1207 { 1208 "description": "an integer is valid", 1209 "data": 12, 1210 "valid": true, 1211 "skip": { 1212 "v2": "could not compile schema", 1213 "v3": "could not compile schema" 1214 } 1215 } 1216 ] 1217 }, 1218 { 1219 "description": "ref to else", 1220 "schema": { 1221 "allOf": [ 1222 { 1223 "$ref": "http://example.com/ref/else" 1224 }, 1225 { 1226 "else": { 1227 "$id": "http://example.com/ref/else", 1228 "type": "integer" 1229 } 1230 } 1231 ] 1232 }, 1233 "skip": { 1234 "v2": "extract error: cannot compile resulting schema: package \"example.com/ref/else\" imported but not defined in :\n generated.cue:1:8\n", 1235 "v3": "extract error: cannot compile resulting schema: package \"example.com/ref/else\" imported but not defined in :\n generated.cue:1:8\n" 1236 }, 1237 "tests": [ 1238 { 1239 "description": "a non-integer is invalid due to the $ref", 1240 "data": "foo", 1241 "valid": false, 1242 "skip": { 1243 "v2": "could not compile schema", 1244 "v3": "could not compile schema" 1245 } 1246 }, 1247 { 1248 "description": "an integer is valid", 1249 "data": 12, 1250 "valid": true, 1251 "skip": { 1252 "v2": "could not compile schema", 1253 "v3": "could not compile schema" 1254 } 1255 } 1256 ] 1257 }, 1258 { 1259 "description": "ref with absolute-path-reference", 1260 "schema": { 1261 "$id": "http://example.com/ref/absref.json", 1262 "definitions": { 1263 "a": { 1264 "$id": "http://example.com/ref/absref/foobar.json", 1265 "type": "number" 1266 }, 1267 "b": { 1268 "$id": "http://example.com/absref/foobar.json", 1269 "type": "string" 1270 } 1271 }, 1272 "allOf": [ 1273 { 1274 "$ref": "/absref/foobar.json" 1275 } 1276 ] 1277 }, 1278 "tests": [ 1279 { 1280 "description": "a string is valid", 1281 "data": "foo", 1282 "valid": true 1283 }, 1284 { 1285 "description": "an integer is invalid", 1286 "data": 12, 1287 "valid": false 1288 } 1289 ] 1290 }, 1291 { 1292 "description": "$id with file URI still resolves pointers - *nix", 1293 "schema": { 1294 "$id": "file:///folder/file.json", 1295 "definitions": { 1296 "foo": { 1297 "type": "number" 1298 } 1299 }, 1300 "allOf": [ 1301 { 1302 "$ref": "#/definitions/foo" 1303 } 1304 ] 1305 }, 1306 "tests": [ 1307 { 1308 "description": "number is valid", 1309 "data": 1, 1310 "valid": true 1311 }, 1312 { 1313 "description": "non-number is invalid", 1314 "data": "a", 1315 "valid": false 1316 } 1317 ] 1318 }, 1319 { 1320 "description": "$id with file URI still resolves pointers - windows", 1321 "schema": { 1322 "$id": "file:///c:/folder/file.json", 1323 "definitions": { 1324 "foo": { 1325 "type": "number" 1326 } 1327 }, 1328 "allOf": [ 1329 { 1330 "$ref": "#/definitions/foo" 1331 } 1332 ] 1333 }, 1334 "tests": [ 1335 { 1336 "description": "number is valid", 1337 "data": 1, 1338 "valid": true 1339 }, 1340 { 1341 "description": "non-number is invalid", 1342 "data": "a", 1343 "valid": false 1344 } 1345 ] 1346 }, 1347 { 1348 "description": "empty tokens in $ref json-pointer", 1349 "schema": { 1350 "definitions": { 1351 "": { 1352 "definitions": { 1353 "": { 1354 "type": "number" 1355 } 1356 } 1357 } 1358 }, 1359 "allOf": [ 1360 { 1361 "$ref": "#/definitions//definitions/" 1362 } 1363 ] 1364 }, 1365 "tests": [ 1366 { 1367 "description": "number is valid", 1368 "data": 1, 1369 "valid": true 1370 }, 1371 { 1372 "description": "non-number is invalid", 1373 "data": "a", 1374 "valid": false 1375 } 1376 ] 1377 } 1378 ]