Skip to content

Commit 13bc188

Browse files
committed
Squashed 'json/' changes from 95fe6ca2..d38ddd54
d38ddd54 Merge pull request #696 from jdesrosiers/unevaluated-dynamicref 5d0c05fa Fix copy/paste error 49222046 Add unevaluted with dynamic ref tests to draft-next 8ba1c90d Update unevaluted with dynamic ref to be more likely to catch errors 2834c630 Add tests for unevaluated with dynamic reference git-subtree-dir: json git-subtree-split: d38ddd543ebc81e5c23ab03d6598c06563c38a17
1 parent 2ed7ad6 commit 13bc188

File tree

6 files changed

+297
-0
lines changed

6 files changed

+297
-0
lines changed

Diff for: json/tests/draft-next/unevaluatedItems.json

+42
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,48 @@
461461
}
462462
]
463463
},
464+
{
465+
"description": "unevaluatedItems with $dynamicRef",
466+
"schema": {
467+
"$schema": "https://json-schema.org/draft/next/schema",
468+
"$id": "https://example.com/derived",
469+
470+
"$ref": "/baseSchema",
471+
472+
"$defs": {
473+
"derived": {
474+
"$dynamicAnchor": "addons",
475+
"prefixItems": [
476+
true,
477+
{ "type": "string" }
478+
]
479+
},
480+
"baseSchema": {
481+
"$id": "/baseSchema",
482+
483+
"$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
484+
"unevaluatedItems": false,
485+
"type": "array",
486+
"prefixItems": [
487+
{ "type": "string" }
488+
],
489+
"$dynamicRef": "#addons"
490+
}
491+
}
492+
},
493+
"tests": [
494+
{
495+
"description": "with no unevaluated items",
496+
"data": ["foo", "bar"],
497+
"valid": true
498+
},
499+
{
500+
"description": "with unevaluated items",
501+
"data": ["foo", "bar", "baz"],
502+
"valid": false
503+
}
504+
]
505+
},
464506
{
465507
"description": "unevaluatedItems can't see inside cousins",
466508
"schema": {

Diff for: json/tests/draft-next/unevaluatedProperties.json

+48
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,54 @@
715715
}
716716
]
717717
},
718+
{
719+
"description": "unevaluatedProperties with $dynamicRef",
720+
"schema": {
721+
"$schema": "https://json-schema.org/draft/next/schema",
722+
"$id": "https://example.com/derived",
723+
724+
"$ref": "/baseSchema",
725+
726+
"$defs": {
727+
"derived": {
728+
"$dynamicAnchor": "addons",
729+
"properties": {
730+
"bar": { "type": "string" }
731+
}
732+
},
733+
"baseSchema": {
734+
"$id": "/baseSchema",
735+
736+
"$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
737+
"unevaluatedProperties": false,
738+
"type": "object",
739+
"properties": {
740+
"foo": { "type": "string" }
741+
},
742+
"$dynamicRef": "#addons"
743+
}
744+
}
745+
},
746+
"tests": [
747+
{
748+
"description": "with no unevaluated properties",
749+
"data": {
750+
"foo": "foo",
751+
"bar": "bar"
752+
},
753+
"valid": true
754+
},
755+
{
756+
"description": "with unevaluated properties",
757+
"data": {
758+
"foo": "foo",
759+
"bar": "bar",
760+
"baz": "baz"
761+
},
762+
"valid": false
763+
}
764+
]
765+
},
718766
{
719767
"description": "unevaluatedProperties can't see inside cousins",
720768
"schema": {

Diff for: json/tests/draft2019-09/unevaluatedItems.json

+45
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,51 @@
480480
}
481481
]
482482
},
483+
{
484+
"description": "unevaluatedItems with $recursiveRef",
485+
"schema": {
486+
"$schema": "https://json-schema.org/draft/2019-09/schema",
487+
"$id": "https://example.com/extended-tree",
488+
489+
"$recursiveAnchor": true,
490+
491+
"$ref": "/tree",
492+
"items": [
493+
true,
494+
true,
495+
{ "type": "string" }
496+
],
497+
498+
"$defs": {
499+
"tree": {
500+
"$id": "/tree",
501+
"$recursiveAnchor": true,
502+
503+
"type": "array",
504+
"items": [
505+
{ "type": "number" },
506+
{
507+
"$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
508+
"unevaluatedItems": false,
509+
"$recursiveRef": "#"
510+
}
511+
]
512+
}
513+
}
514+
},
515+
"tests": [
516+
{
517+
"description": "with no unevaluated items",
518+
"data": [1, [2, [], "b"], "a"],
519+
"valid": true
520+
},
521+
{
522+
"description": "with unevaluated items",
523+
"data": [1, [2, [], "b", "too many"], "a"],
524+
"valid": false
525+
}
526+
]
527+
},
483528
{
484529
"description": "unevaluatedItems can't see inside cousins",
485530
"schema": {

Diff for: json/tests/draft2019-09/unevaluatedProperties.json

+58
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,64 @@
715715
}
716716
]
717717
},
718+
{
719+
"description": "unevaluatedProperties with $recursiveRef",
720+
"schema": {
721+
"$schema": "https://json-schema.org/draft/2019-09/schema",
722+
"$id": "https://example.com/extended-tree",
723+
724+
"$recursiveAnchor": true,
725+
726+
"$ref": "/tree",
727+
"properties": {
728+
"name": { "type": "string" }
729+
},
730+
731+
"$defs": {
732+
"tree": {
733+
"$id": "/tree",
734+
"$recursiveAnchor": true,
735+
736+
"type": "object",
737+
"properties": {
738+
"node": true,
739+
"branches": {
740+
"$comment": "unevaluatedProperties comes first so it's more likely to bugs errors with implementations that are sensitive to keyword ordering",
741+
"unevaluatedProperties": false,
742+
"$recursiveRef": "#"
743+
}
744+
},
745+
"required": ["node"]
746+
}
747+
}
748+
},
749+
"tests": [
750+
{
751+
"description": "with no unevaluated properties",
752+
"data": {
753+
"name": "a",
754+
"node": 1,
755+
"branches": {
756+
"name": "b",
757+
"node": 2
758+
}
759+
},
760+
"valid": true
761+
},
762+
{
763+
"description": "with unevaluated properties",
764+
"data": {
765+
"name": "a",
766+
"node": 1,
767+
"branches": {
768+
"foo": "b",
769+
"node": 2
770+
}
771+
},
772+
"valid": false
773+
}
774+
]
775+
},
718776
{
719777
"description": "unevaluatedProperties can't see inside cousins",
720778
"schema": {

Diff for: json/tests/draft2020-12/unevaluatedItems.json

+49
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,55 @@
461461
}
462462
]
463463
},
464+
{
465+
"description": "unevaluatedItems with $dynamicRef",
466+
"schema": {
467+
"$schema": "https://json-schema.org/draft/2020-12/schema",
468+
"$id": "https://example.com/derived",
469+
470+
"$ref": "/baseSchema",
471+
472+
"$defs": {
473+
"derived": {
474+
"$dynamicAnchor": "addons",
475+
"prefixItems": [
476+
true,
477+
{ "type": "string" }
478+
]
479+
},
480+
"baseSchema": {
481+
"$id": "/baseSchema",
482+
483+
"$comment": "unevaluatedItems comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
484+
"unevaluatedItems": false,
485+
"type": "array",
486+
"prefixItems": [
487+
{ "type": "string" }
488+
],
489+
"$dynamicRef": "#addons",
490+
491+
"$defs": {
492+
"defaultAddons": {
493+
"$comment": "Needed to satisfy the bookending requirement",
494+
"$dynamicAnchor": "addons"
495+
}
496+
}
497+
}
498+
}
499+
},
500+
"tests": [
501+
{
502+
"description": "with no unevaluated items",
503+
"data": ["foo", "bar"],
504+
"valid": true
505+
},
506+
{
507+
"description": "with unevaluated items",
508+
"data": ["foo", "bar", "baz"],
509+
"valid": false
510+
}
511+
]
512+
},
464513
{
465514
"description": "unevaluatedItems can't see inside cousins",
466515
"schema": {

Diff for: json/tests/draft2020-12/unevaluatedProperties.json

+55
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,61 @@
715715
}
716716
]
717717
},
718+
{
719+
"description": "unevaluatedProperties with $dynamicRef",
720+
"schema": {
721+
"$schema": "https://json-schema.org/draft/2020-12/schema",
722+
"$id": "https://example.com/derived",
723+
724+
"$ref": "/baseSchema",
725+
726+
"$defs": {
727+
"derived": {
728+
"$dynamicAnchor": "addons",
729+
"properties": {
730+
"bar": { "type": "string" }
731+
}
732+
},
733+
"baseSchema": {
734+
"$id": "/baseSchema",
735+
736+
"$comment": "unevaluatedProperties comes first so it's more likely to catch bugs with implementations that are sensitive to keyword ordering",
737+
"unevaluatedProperties": false,
738+
"type": "object",
739+
"properties": {
740+
"foo": { "type": "string" }
741+
},
742+
"$dynamicRef": "#addons",
743+
744+
"$defs": {
745+
"defaultAddons": {
746+
"$comment": "Needed to satisfy the bookending requirement",
747+
"$dynamicAnchor": "addons"
748+
}
749+
}
750+
}
751+
}
752+
},
753+
"tests": [
754+
{
755+
"description": "with no unevaluated properties",
756+
"data": {
757+
"foo": "foo",
758+
"bar": "bar"
759+
},
760+
"valid": true
761+
},
762+
{
763+
"description": "with unevaluated properties",
764+
"data": {
765+
"foo": "foo",
766+
"bar": "bar",
767+
"baz": "baz"
768+
},
769+
"valid": false
770+
}
771+
]
772+
},
718773
{
719774
"description": "unevaluatedProperties can't see inside cousins",
720775
"schema": {

0 commit comments

Comments
 (0)