cuelang.org/go@v0.13.0/encoding/jsonschema/testdata/external/tests/draft2020-12/dynamicRef.json (about) 1 [ 2 { 3 "description": "A $dynamicRef to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor", 4 "schema": { 5 "$schema": "https://json-schema.org/draft/2020-12/schema", 6 "$id": "https://test.json-schema.org/dynamicRef-dynamicAnchor-same-schema/root", 7 "type": "array", 8 "items": { 9 "$dynamicRef": "#items" 10 }, 11 "$defs": { 12 "foo": { 13 "$dynamicAnchor": "items", 14 "type": "string" 15 } 16 } 17 }, 18 "skip": { 19 "v2": "extract error: keyword \"$dynamicRef\" not yet implemented (and 3 more errors)", 20 "v3": "extract error: keyword \"$dynamicRef\" not yet implemented (and 3 more errors)" 21 }, 22 "tests": [ 23 { 24 "description": "An array of strings is valid", 25 "data": [ 26 "foo", 27 "bar" 28 ], 29 "valid": true, 30 "skip": { 31 "v2": "could not compile schema", 32 "v3": "could not compile schema" 33 } 34 }, 35 { 36 "description": "An array containing non-strings is invalid", 37 "data": [ 38 "foo", 39 42 40 ], 41 "valid": false, 42 "skip": { 43 "v2": "could not compile schema", 44 "v3": "could not compile schema" 45 } 46 } 47 ] 48 }, 49 { 50 "description": "A $dynamicRef to an $anchor in the same schema resource behaves like a normal $ref to an $anchor", 51 "schema": { 52 "$schema": "https://json-schema.org/draft/2020-12/schema", 53 "$id": "https://test.json-schema.org/dynamicRef-anchor-same-schema/root", 54 "type": "array", 55 "items": { 56 "$dynamicRef": "#items" 57 }, 58 "$defs": { 59 "foo": { 60 "$anchor": "items", 61 "type": "string" 62 } 63 } 64 }, 65 "skip": { 66 "v2": "extract error: keyword \"$dynamicRef\" not yet implemented (and 3 more errors)", 67 "v3": "extract error: keyword \"$dynamicRef\" not yet implemented (and 3 more errors)" 68 }, 69 "tests": [ 70 { 71 "description": "An array of strings is valid", 72 "data": [ 73 "foo", 74 "bar" 75 ], 76 "valid": true, 77 "skip": { 78 "v2": "could not compile schema", 79 "v3": "could not compile schema" 80 } 81 }, 82 { 83 "description": "An array containing non-strings is invalid", 84 "data": [ 85 "foo", 86 42 87 ], 88 "valid": false, 89 "skip": { 90 "v2": "could not compile schema", 91 "v3": "could not compile schema" 92 } 93 } 94 ] 95 }, 96 { 97 "description": "A $ref to a $dynamicAnchor in the same schema resource behaves like a normal $ref to an $anchor", 98 "schema": { 99 "$schema": "https://json-schema.org/draft/2020-12/schema", 100 "$id": "https://test.json-schema.org/ref-dynamicAnchor-same-schema/root", 101 "type": "array", 102 "items": { 103 "$ref": "#items" 104 }, 105 "$defs": { 106 "foo": { 107 "$dynamicAnchor": "items", 108 "type": "string" 109 } 110 } 111 }, 112 "skip": { 113 "v2": "extract error: cannot determine CUE location for JSON Schema location id=https://test.json-schema.org/ref-dynamicAnchor-same-schema/root#items: anchors (items) not supported (and 3 more errors)", 114 "v3": "extract error: cannot determine CUE location for JSON Schema location id=https://test.json-schema.org/ref-dynamicAnchor-same-schema/root#items: anchors (items) not supported (and 3 more errors)" 115 }, 116 "tests": [ 117 { 118 "description": "An array of strings is valid", 119 "data": [ 120 "foo", 121 "bar" 122 ], 123 "valid": true, 124 "skip": { 125 "v2": "could not compile schema", 126 "v3": "could not compile schema" 127 } 128 }, 129 { 130 "description": "An array containing non-strings is invalid", 131 "data": [ 132 "foo", 133 42 134 ], 135 "valid": false, 136 "skip": { 137 "v2": "could not compile schema", 138 "v3": "could not compile schema" 139 } 140 } 141 ] 142 }, 143 { 144 "description": "A $dynamicRef resolves to the first $dynamicAnchor still in scope that is encountered when the schema is evaluated", 145 "schema": { 146 "$schema": "https://json-schema.org/draft/2020-12/schema", 147 "$id": "https://test.json-schema.org/typical-dynamic-resolution/root", 148 "$ref": "list", 149 "$defs": { 150 "foo": { 151 "$dynamicAnchor": "items", 152 "type": "string" 153 }, 154 "list": { 155 "$id": "list", 156 "type": "array", 157 "items": { 158 "$dynamicRef": "#items" 159 }, 160 "$defs": { 161 "items": { 162 "$comment": "This is only needed to satisfy the bookending requirement", 163 "$dynamicAnchor": "items" 164 } 165 } 166 } 167 } 168 }, 169 "skip": { 170 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)", 171 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)" 172 }, 173 "tests": [ 174 { 175 "description": "An array of strings is valid", 176 "data": [ 177 "foo", 178 "bar" 179 ], 180 "valid": true, 181 "skip": { 182 "v2": "could not compile schema", 183 "v3": "could not compile schema" 184 } 185 }, 186 { 187 "description": "An array containing non-strings is invalid", 188 "data": [ 189 "foo", 190 42 191 ], 192 "valid": false, 193 "skip": { 194 "v2": "could not compile schema", 195 "v3": "could not compile schema" 196 } 197 } 198 ] 199 }, 200 { 201 "description": "A $dynamicRef without anchor in fragment behaves identical to $ref", 202 "schema": { 203 "$schema": "https://json-schema.org/draft/2020-12/schema", 204 "$id": "https://test.json-schema.org/dynamicRef-without-anchor/root", 205 "$ref": "list", 206 "$defs": { 207 "foo": { 208 "$dynamicAnchor": "items", 209 "type": "string" 210 }, 211 "list": { 212 "$id": "list", 213 "type": "array", 214 "items": { 215 "$dynamicRef": "#/$defs/items" 216 }, 217 "$defs": { 218 "items": { 219 "$comment": "This is only needed to satisfy the bookending requirement", 220 "$dynamicAnchor": "items", 221 "type": "number" 222 } 223 } 224 } 225 } 226 }, 227 "skip": { 228 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)", 229 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)" 230 }, 231 "tests": [ 232 { 233 "description": "An array of strings is invalid", 234 "data": [ 235 "foo", 236 "bar" 237 ], 238 "valid": false, 239 "skip": { 240 "v2": "could not compile schema", 241 "v3": "could not compile schema" 242 } 243 }, 244 { 245 "description": "An array of numbers is valid", 246 "data": [ 247 24, 248 42 249 ], 250 "valid": true, 251 "skip": { 252 "v2": "could not compile schema", 253 "v3": "could not compile schema" 254 } 255 } 256 ] 257 }, 258 { 259 "description": "A $dynamicRef with intermediate scopes that don't include a matching $dynamicAnchor does not affect dynamic scope resolution", 260 "schema": { 261 "$schema": "https://json-schema.org/draft/2020-12/schema", 262 "$id": "https://test.json-schema.org/dynamic-resolution-with-intermediate-scopes/root", 263 "$ref": "intermediate-scope", 264 "$defs": { 265 "foo": { 266 "$dynamicAnchor": "items", 267 "type": "string" 268 }, 269 "intermediate-scope": { 270 "$id": "intermediate-scope", 271 "$ref": "list" 272 }, 273 "list": { 274 "$id": "list", 275 "type": "array", 276 "items": { 277 "$dynamicRef": "#items" 278 }, 279 "$defs": { 280 "items": { 281 "$comment": "This is only needed to satisfy the bookending requirement", 282 "$dynamicAnchor": "items" 283 } 284 } 285 } 286 } 287 }, 288 "skip": { 289 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)", 290 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)" 291 }, 292 "tests": [ 293 { 294 "description": "An array of strings is valid", 295 "data": [ 296 "foo", 297 "bar" 298 ], 299 "valid": true, 300 "skip": { 301 "v2": "could not compile schema", 302 "v3": "could not compile schema" 303 } 304 }, 305 { 306 "description": "An array containing non-strings is invalid", 307 "data": [ 308 "foo", 309 42 310 ], 311 "valid": false, 312 "skip": { 313 "v2": "could not compile schema", 314 "v3": "could not compile schema" 315 } 316 } 317 ] 318 }, 319 { 320 "description": "An $anchor with the same name as a $dynamicAnchor is not used for dynamic scope resolution", 321 "schema": { 322 "$schema": "https://json-schema.org/draft/2020-12/schema", 323 "$id": "https://test.json-schema.org/dynamic-resolution-ignores-anchors/root", 324 "$ref": "list", 325 "$defs": { 326 "foo": { 327 "$anchor": "items", 328 "type": "string" 329 }, 330 "list": { 331 "$id": "list", 332 "type": "array", 333 "items": { 334 "$dynamicRef": "#items" 335 }, 336 "$defs": { 337 "items": { 338 "$comment": "This is only needed to satisfy the bookending requirement", 339 "$dynamicAnchor": "items" 340 } 341 } 342 } 343 } 344 }, 345 "skip": { 346 "v2": "extract error: keyword \"$anchor\" not yet implemented (and 5 more errors)", 347 "v3": "extract error: keyword \"$anchor\" not yet implemented (and 5 more errors)" 348 }, 349 "tests": [ 350 { 351 "description": "Any array is valid", 352 "data": [ 353 "foo", 354 42 355 ], 356 "valid": true, 357 "skip": { 358 "v2": "could not compile schema", 359 "v3": "could not compile schema" 360 } 361 } 362 ] 363 }, 364 { 365 "description": "A $dynamicRef without a matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor", 366 "schema": { 367 "$schema": "https://json-schema.org/draft/2020-12/schema", 368 "$id": "https://test.json-schema.org/dynamic-resolution-without-bookend/root", 369 "$ref": "list", 370 "$defs": { 371 "foo": { 372 "$dynamicAnchor": "items", 373 "type": "string" 374 }, 375 "list": { 376 "$id": "list", 377 "type": "array", 378 "items": { 379 "$dynamicRef": "#items" 380 }, 381 "$defs": { 382 "items": { 383 "$comment": "This is only needed to give the reference somewhere to resolve to when it behaves like $ref", 384 "$anchor": "items" 385 } 386 } 387 } 388 } 389 }, 390 "skip": { 391 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)", 392 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)" 393 }, 394 "tests": [ 395 { 396 "description": "Any array is valid", 397 "data": [ 398 "foo", 399 42 400 ], 401 "valid": true, 402 "skip": { 403 "v2": "could not compile schema", 404 "v3": "could not compile schema" 405 } 406 } 407 ] 408 }, 409 { 410 "description": "A $dynamicRef with a non-matching $dynamicAnchor in the same schema resource behaves like a normal $ref to $anchor", 411 "schema": { 412 "$schema": "https://json-schema.org/draft/2020-12/schema", 413 "$id": "https://test.json-schema.org/unmatched-dynamic-anchor/root", 414 "$ref": "list", 415 "$defs": { 416 "foo": { 417 "$dynamicAnchor": "items", 418 "type": "string" 419 }, 420 "list": { 421 "$id": "list", 422 "type": "array", 423 "items": { 424 "$dynamicRef": "#items" 425 }, 426 "$defs": { 427 "items": { 428 "$comment": "This is only needed to give the reference somewhere to resolve to when it behaves like $ref", 429 "$anchor": "items", 430 "$dynamicAnchor": "foo" 431 } 432 } 433 } 434 } 435 }, 436 "skip": { 437 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 7 more errors)", 438 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 7 more errors)" 439 }, 440 "tests": [ 441 { 442 "description": "Any array is valid", 443 "data": [ 444 "foo", 445 42 446 ], 447 "valid": true, 448 "skip": { 449 "v2": "could not compile schema", 450 "v3": "could not compile schema" 451 } 452 } 453 ] 454 }, 455 { 456 "description": "A $dynamicRef that initially resolves to a schema with a matching $dynamicAnchor resolves to the first $dynamicAnchor in the dynamic scope", 457 "schema": { 458 "$schema": "https://json-schema.org/draft/2020-12/schema", 459 "$id": "https://test.json-schema.org/relative-dynamic-reference/root", 460 "$dynamicAnchor": "meta", 461 "type": "object", 462 "properties": { 463 "foo": { 464 "const": "pass" 465 } 466 }, 467 "$ref": "extended", 468 "$defs": { 469 "extended": { 470 "$id": "extended", 471 "$dynamicAnchor": "meta", 472 "type": "object", 473 "properties": { 474 "bar": { 475 "$ref": "bar" 476 } 477 } 478 }, 479 "bar": { 480 "$id": "bar", 481 "type": "object", 482 "properties": { 483 "baz": { 484 "$dynamicRef": "extended#meta" 485 } 486 } 487 } 488 } 489 }, 490 "skip": { 491 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)", 492 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)" 493 }, 494 "tests": [ 495 { 496 "description": "The recursive part is valid against the root", 497 "data": { 498 "foo": "pass", 499 "bar": { 500 "baz": { 501 "foo": "pass" 502 } 503 } 504 }, 505 "valid": true, 506 "skip": { 507 "v2": "could not compile schema", 508 "v3": "could not compile schema" 509 } 510 }, 511 { 512 "description": "The recursive part is not valid against the root", 513 "data": { 514 "foo": "pass", 515 "bar": { 516 "baz": { 517 "foo": "fail" 518 } 519 } 520 }, 521 "valid": false, 522 "skip": { 523 "v2": "could not compile schema", 524 "v3": "could not compile schema" 525 } 526 } 527 ] 528 }, 529 { 530 "description": "A $dynamicRef that initially resolves to a schema without a matching $dynamicAnchor behaves like a normal $ref to $anchor", 531 "schema": { 532 "$schema": "https://json-schema.org/draft/2020-12/schema", 533 "$id": "https://test.json-schema.org/relative-dynamic-reference-without-bookend/root", 534 "$dynamicAnchor": "meta", 535 "type": "object", 536 "properties": { 537 "foo": { 538 "const": "pass" 539 } 540 }, 541 "$ref": "extended", 542 "$defs": { 543 "extended": { 544 "$id": "extended", 545 "$anchor": "meta", 546 "type": "object", 547 "properties": { 548 "bar": { 549 "$ref": "bar" 550 } 551 } 552 }, 553 "bar": { 554 "$id": "bar", 555 "type": "object", 556 "properties": { 557 "baz": { 558 "$dynamicRef": "extended#meta" 559 } 560 } 561 } 562 } 563 }, 564 "skip": { 565 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)", 566 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 5 more errors)" 567 }, 568 "tests": [ 569 { 570 "description": "The recursive part doesn't need to validate against the root", 571 "data": { 572 "foo": "pass", 573 "bar": { 574 "baz": { 575 "foo": "fail" 576 } 577 } 578 }, 579 "valid": true, 580 "skip": { 581 "v2": "could not compile schema", 582 "v3": "could not compile schema" 583 } 584 } 585 ] 586 }, 587 { 588 "description": "multiple dynamic paths to the $dynamicRef keyword", 589 "schema": { 590 "$schema": "https://json-schema.org/draft/2020-12/schema", 591 "$id": "https://test.json-schema.org/dynamic-ref-with-multiple-paths/main", 592 "if": { 593 "properties": { 594 "kindOfList": { 595 "const": "numbers" 596 } 597 }, 598 "required": [ 599 "kindOfList" 600 ] 601 }, 602 "then": { 603 "$ref": "numberList" 604 }, 605 "else": { 606 "$ref": "stringList" 607 }, 608 "$defs": { 609 "genericList": { 610 "$id": "genericList", 611 "properties": { 612 "list": { 613 "items": { 614 "$dynamicRef": "#itemType" 615 } 616 } 617 }, 618 "$defs": { 619 "defaultItemType": { 620 "$comment": "Only needed to satisfy bookending requirement", 621 "$dynamicAnchor": "itemType" 622 } 623 } 624 }, 625 "numberList": { 626 "$id": "numberList", 627 "$defs": { 628 "itemType": { 629 "$dynamicAnchor": "itemType", 630 "type": "number" 631 } 632 }, 633 "$ref": "genericList" 634 }, 635 "stringList": { 636 "$id": "stringList", 637 "$defs": { 638 "itemType": { 639 "$dynamicAnchor": "itemType", 640 "type": "string" 641 } 642 }, 643 "$ref": "genericList" 644 } 645 } 646 }, 647 "skip": { 648 "v2": "extract error: keyword \"$dynamicRef\" not yet implemented (and 7 more errors)", 649 "v3": "extract error: keyword \"$dynamicRef\" not yet implemented (and 7 more errors)" 650 }, 651 "tests": [ 652 { 653 "description": "number list with number values", 654 "data": { 655 "kindOfList": "numbers", 656 "list": [ 657 1.1 658 ] 659 }, 660 "valid": true, 661 "skip": { 662 "v2": "could not compile schema", 663 "v3": "could not compile schema" 664 } 665 }, 666 { 667 "description": "number list with string values", 668 "data": { 669 "kindOfList": "numbers", 670 "list": [ 671 "foo" 672 ] 673 }, 674 "valid": false, 675 "skip": { 676 "v2": "could not compile schema", 677 "v3": "could not compile schema" 678 } 679 }, 680 { 681 "description": "string list with number values", 682 "data": { 683 "kindOfList": "strings", 684 "list": [ 685 1.1 686 ] 687 }, 688 "valid": false, 689 "skip": { 690 "v2": "could not compile schema", 691 "v3": "could not compile schema" 692 } 693 }, 694 { 695 "description": "string list with string values", 696 "data": { 697 "kindOfList": "strings", 698 "list": [ 699 "foo" 700 ] 701 }, 702 "valid": true, 703 "skip": { 704 "v2": "could not compile schema", 705 "v3": "could not compile schema" 706 } 707 } 708 ] 709 }, 710 { 711 "description": "after leaving a dynamic scope, it is not used by a $dynamicRef", 712 "schema": { 713 "$schema": "https://json-schema.org/draft/2020-12/schema", 714 "$id": "https://test.json-schema.org/dynamic-ref-leaving-dynamic-scope/main", 715 "if": { 716 "$id": "first_scope", 717 "$defs": { 718 "thingy": { 719 "$comment": "this is first_scope#thingy", 720 "$dynamicAnchor": "thingy", 721 "type": "number" 722 } 723 } 724 }, 725 "then": { 726 "$id": "second_scope", 727 "$ref": "start", 728 "$defs": { 729 "thingy": { 730 "$comment": "this is second_scope#thingy, the final destination of the $dynamicRef", 731 "$dynamicAnchor": "thingy", 732 "type": "null" 733 } 734 } 735 }, 736 "$defs": { 737 "start": { 738 "$comment": "this is the landing spot from $ref", 739 "$id": "start", 740 "$dynamicRef": "inner_scope#thingy" 741 }, 742 "thingy": { 743 "$comment": "this is the first stop for the $dynamicRef", 744 "$id": "inner_scope", 745 "$dynamicAnchor": "thingy", 746 "type": "string" 747 } 748 } 749 }, 750 "skip": { 751 "v2": "extract error: keyword \"$dynamicRef\" not yet implemented (and 7 more errors)", 752 "v3": "extract error: keyword \"$dynamicRef\" not yet implemented (and 7 more errors)" 753 }, 754 "tests": [ 755 { 756 "description": "string matches /$defs/thingy, but the $dynamicRef does not stop here", 757 "data": "a string", 758 "valid": false, 759 "skip": { 760 "v2": "could not compile schema", 761 "v3": "could not compile schema" 762 } 763 }, 764 { 765 "description": "first_scope is not in dynamic scope for the $dynamicRef", 766 "data": 42, 767 "valid": false, 768 "skip": { 769 "v2": "could not compile schema", 770 "v3": "could not compile schema" 771 } 772 }, 773 { 774 "description": "/then/$defs/thingy is the final stop for the $dynamicRef", 775 "data": null, 776 "valid": true, 777 "skip": { 778 "v2": "could not compile schema", 779 "v3": "could not compile schema" 780 } 781 } 782 ] 783 }, 784 { 785 "description": "strict-tree schema, guards against misspelled properties", 786 "schema": { 787 "$schema": "https://json-schema.org/draft/2020-12/schema", 788 "$id": "http://localhost:1234/draft2020-12/strict-tree.json", 789 "$dynamicAnchor": "node", 790 "$ref": "tree.json", 791 "unevaluatedProperties": false 792 }, 793 "skip": { 794 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 3 more errors)", 795 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 3 more errors)" 796 }, 797 "tests": [ 798 { 799 "description": "instance with misspelled field", 800 "data": { 801 "children": [ 802 { 803 "daat": 1 804 } 805 ] 806 }, 807 "valid": false, 808 "skip": { 809 "v2": "could not compile schema", 810 "v3": "could not compile schema" 811 } 812 }, 813 { 814 "description": "instance with correct field", 815 "data": { 816 "children": [ 817 { 818 "data": 1 819 } 820 ] 821 }, 822 "valid": true, 823 "skip": { 824 "v2": "could not compile schema", 825 "v3": "could not compile schema" 826 } 827 } 828 ] 829 }, 830 { 831 "description": "tests for implementation dynamic anchor and reference link", 832 "schema": { 833 "$schema": "https://json-schema.org/draft/2020-12/schema", 834 "$id": "http://localhost:1234/draft2020-12/strict-extendible.json", 835 "$ref": "extendible-dynamic-ref.json", 836 "$defs": { 837 "elements": { 838 "$dynamicAnchor": "elements", 839 "properties": { 840 "a": true 841 }, 842 "required": [ 843 "a" 844 ], 845 "additionalProperties": false 846 } 847 } 848 }, 849 "skip": { 850 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 1 more errors)", 851 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 1 more errors)" 852 }, 853 "tests": [ 854 { 855 "description": "incorrect parent schema", 856 "data": { 857 "a": true 858 }, 859 "valid": false, 860 "skip": { 861 "v2": "could not compile schema", 862 "v3": "could not compile schema" 863 } 864 }, 865 { 866 "description": "incorrect extended schema", 867 "data": { 868 "elements": [ 869 { 870 "b": 1 871 } 872 ] 873 }, 874 "valid": false, 875 "skip": { 876 "v2": "could not compile schema", 877 "v3": "could not compile schema" 878 } 879 }, 880 { 881 "description": "correct extended schema", 882 "data": { 883 "elements": [ 884 { 885 "a": 1 886 } 887 ] 888 }, 889 "valid": true, 890 "skip": { 891 "v2": "could not compile schema", 892 "v3": "could not compile schema" 893 } 894 } 895 ] 896 }, 897 { 898 "description": "$ref and $dynamicAnchor are independent of order - $defs first", 899 "schema": { 900 "$schema": "https://json-schema.org/draft/2020-12/schema", 901 "$id": "http://localhost:1234/draft2020-12/strict-extendible-allof-defs-first.json", 902 "allOf": [ 903 { 904 "$ref": "extendible-dynamic-ref.json" 905 }, 906 { 907 "$defs": { 908 "elements": { 909 "$dynamicAnchor": "elements", 910 "properties": { 911 "a": true 912 }, 913 "required": [ 914 "a" 915 ], 916 "additionalProperties": false 917 } 918 } 919 } 920 ] 921 }, 922 "skip": { 923 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 1 more errors)", 924 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 1 more errors)" 925 }, 926 "tests": [ 927 { 928 "description": "incorrect parent schema", 929 "data": { 930 "a": true 931 }, 932 "valid": false, 933 "skip": { 934 "v2": "could not compile schema", 935 "v3": "could not compile schema" 936 } 937 }, 938 { 939 "description": "incorrect extended schema", 940 "data": { 941 "elements": [ 942 { 943 "b": 1 944 } 945 ] 946 }, 947 "valid": false, 948 "skip": { 949 "v2": "could not compile schema", 950 "v3": "could not compile schema" 951 } 952 }, 953 { 954 "description": "correct extended schema", 955 "data": { 956 "elements": [ 957 { 958 "a": 1 959 } 960 ] 961 }, 962 "valid": true, 963 "skip": { 964 "v2": "could not compile schema", 965 "v3": "could not compile schema" 966 } 967 } 968 ] 969 }, 970 { 971 "description": "$ref and $dynamicAnchor are independent of order - $ref first", 972 "schema": { 973 "$schema": "https://json-schema.org/draft/2020-12/schema", 974 "$id": "http://localhost:1234/draft2020-12/strict-extendible-allof-ref-first.json", 975 "allOf": [ 976 { 977 "$defs": { 978 "elements": { 979 "$dynamicAnchor": "elements", 980 "properties": { 981 "a": true 982 }, 983 "required": [ 984 "a" 985 ], 986 "additionalProperties": false 987 } 988 } 989 }, 990 { 991 "$ref": "extendible-dynamic-ref.json" 992 } 993 ] 994 }, 995 "skip": { 996 "v2": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 1 more errors)", 997 "v3": "extract error: keyword \"$dynamicAnchor\" not yet implemented (and 1 more errors)" 998 }, 999 "tests": [ 1000 { 1001 "description": "incorrect parent schema", 1002 "data": { 1003 "a": true 1004 }, 1005 "valid": false, 1006 "skip": { 1007 "v2": "could not compile schema", 1008 "v3": "could not compile schema" 1009 } 1010 }, 1011 { 1012 "description": "incorrect extended schema", 1013 "data": { 1014 "elements": [ 1015 { 1016 "b": 1 1017 } 1018 ] 1019 }, 1020 "valid": false, 1021 "skip": { 1022 "v2": "could not compile schema", 1023 "v3": "could not compile schema" 1024 } 1025 }, 1026 { 1027 "description": "correct extended schema", 1028 "data": { 1029 "elements": [ 1030 { 1031 "a": 1 1032 } 1033 ] 1034 }, 1035 "valid": true, 1036 "skip": { 1037 "v2": "could not compile schema", 1038 "v3": "could not compile schema" 1039 } 1040 } 1041 ] 1042 }, 1043 { 1044 "description": "$ref to $dynamicRef finds detached $dynamicAnchor", 1045 "schema": { 1046 "$ref": "http://localhost:1234/draft2020-12/detached-dynamicref.json#/$defs/foo" 1047 }, 1048 "skip": { 1049 "v2": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/draft2020-12/detached-dynamicref.json:schema\":\n generated.cue:1:8\n", 1050 "v3": "extract error: cannot compile resulting schema: invalid import path: \"localhost:1234/draft2020-12/detached-dynamicref.json:schema\":\n generated.cue:1:8\n" 1051 }, 1052 "tests": [ 1053 { 1054 "description": "number is valid", 1055 "data": 1, 1056 "valid": true, 1057 "skip": { 1058 "v2": "could not compile schema", 1059 "v3": "could not compile schema" 1060 } 1061 }, 1062 { 1063 "description": "non-number is invalid", 1064 "data": "a", 1065 "valid": false, 1066 "skip": { 1067 "v2": "could not compile schema", 1068 "v3": "could not compile schema" 1069 } 1070 } 1071 ] 1072 }, 1073 { 1074 "description": "$dynamicRef points to a boolean schema", 1075 "schema": { 1076 "$schema": "https://json-schema.org/draft/2020-12/schema", 1077 "$defs": { 1078 "true": true, 1079 "false": false 1080 }, 1081 "properties": { 1082 "true": { 1083 "$dynamicRef": "#/$defs/true" 1084 }, 1085 "false": { 1086 "$dynamicRef": "#/$defs/false" 1087 } 1088 } 1089 }, 1090 "skip": { 1091 "v2": "extract error: keyword \"$dynamicRef\" not yet implemented (and 3 more errors)", 1092 "v3": "extract error: keyword \"$dynamicRef\" not yet implemented (and 3 more errors)" 1093 }, 1094 "tests": [ 1095 { 1096 "description": "follow $dynamicRef to a true schema", 1097 "data": { 1098 "true": 1 1099 }, 1100 "valid": true, 1101 "skip": { 1102 "v2": "could not compile schema", 1103 "v3": "could not compile schema" 1104 } 1105 }, 1106 { 1107 "description": "follow $dynamicRef to a false schema", 1108 "data": { 1109 "false": 1 1110 }, 1111 "valid": false, 1112 "skip": { 1113 "v2": "could not compile schema", 1114 "v3": "could not compile schema" 1115 } 1116 } 1117 ] 1118 }, 1119 { 1120 "description": "$dynamicRef skips over intermediate resources - direct reference", 1121 "schema": { 1122 "$schema": "https://json-schema.org/draft/2020-12/schema", 1123 "$id": "https://test.json-schema.org/dynamic-ref-skips-intermediate-resource/main", 1124 "type": "object", 1125 "properties": { 1126 "bar-item": { 1127 "$ref": "item" 1128 } 1129 }, 1130 "$defs": { 1131 "bar": { 1132 "$id": "bar", 1133 "type": "array", 1134 "items": { 1135 "$ref": "item" 1136 }, 1137 "$defs": { 1138 "item": { 1139 "$id": "item", 1140 "type": "object", 1141 "properties": { 1142 "content": { 1143 "$dynamicRef": "#content" 1144 } 1145 }, 1146 "$defs": { 1147 "defaultContent": { 1148 "$dynamicAnchor": "content", 1149 "type": "integer" 1150 } 1151 } 1152 }, 1153 "content": { 1154 "$dynamicAnchor": "content", 1155 "type": "string" 1156 } 1157 } 1158 } 1159 } 1160 }, 1161 "skip": { 1162 "v2": "extract error: keyword \"$dynamicRef\" not yet implemented (and 5 more errors)", 1163 "v3": "extract error: keyword \"$dynamicRef\" not yet implemented (and 5 more errors)" 1164 }, 1165 "tests": [ 1166 { 1167 "description": "integer property passes", 1168 "data": { 1169 "bar-item": { 1170 "content": 42 1171 } 1172 }, 1173 "valid": true, 1174 "skip": { 1175 "v2": "could not compile schema", 1176 "v3": "could not compile schema" 1177 } 1178 }, 1179 { 1180 "description": "string property fails", 1181 "data": { 1182 "bar-item": { 1183 "content": "value" 1184 } 1185 }, 1186 "valid": false, 1187 "skip": { 1188 "v2": "could not compile schema", 1189 "v3": "could not compile schema" 1190 } 1191 } 1192 ] 1193 } 1194 ]