Skip to content

Commit f13fb46

Browse files
committed
Add tests for unevaluated with dynamic reference
1 parent cda4281 commit f13fb46

File tree

4 files changed

+203
-0
lines changed

4 files changed

+203
-0
lines changed

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

+44
Original file line numberDiff line numberDiff line change
@@ -480,6 +480,50 @@
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+
"prefixItems": [
493+
true,
494+
true,
495+
{ "type": "string" }
496+
],
497+
498+
"$defs": {
499+
"tree": {
500+
"$id": "/tree",
501+
"$recursiveAnchor": true,
502+
503+
"type": "array",
504+
"prefixItems": [
505+
{ "type": "number" },
506+
{
507+
"$recursiveRef": "#",
508+
"unevaluatedItems": false
509+
}
510+
]
511+
}
512+
}
513+
},
514+
"tests": [
515+
{
516+
"description": "with no unevaluated items",
517+
"data": [1, [2, [], "b"], "a"],
518+
"valid": true
519+
},
520+
{
521+
"description": "with unevaluated items",
522+
"data": [1, [2, [], "b", "too many"], "a"],
523+
"valid": false
524+
}
525+
]
526+
},
483527
{
484528
"description": "unevaluatedItems can't see inside cousins",
485529
"schema": {

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

+57
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,63 @@
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+
"$recursiveRef": "#",
741+
"unevaluatedProperties": false
742+
}
743+
},
744+
"required": ["node"]
745+
}
746+
}
747+
},
748+
"tests": [
749+
{
750+
"description": "with no unevaluated properties",
751+
"data": {
752+
"name": "a",
753+
"node": 1,
754+
"branches": {
755+
"name": "b",
756+
"node": 2
757+
}
758+
},
759+
"valid": true
760+
},
761+
{
762+
"description": "with unevaluated properties",
763+
"data": {
764+
"name": "a",
765+
"node": 1,
766+
"branches": {
767+
"foo": "b",
768+
"node": 2
769+
}
770+
},
771+
"valid": false
772+
}
773+
]
774+
},
718775
{
719776
"description": "unevaluatedProperties can't see inside cousins",
720777
"schema": {

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

+48
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,54 @@
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+
"type": "array",
484+
"prefixItems": [
485+
{ "type": "string" }
486+
],
487+
"$dynamicRef": "#addons",
488+
"unevaluatedItems": false,
489+
490+
"$defs": {
491+
"defaultAddons": {
492+
"$comment": "Needed to satisfy the bookending requirement",
493+
"$dynamicAnchor": "addons"
494+
}
495+
}
496+
}
497+
}
498+
},
499+
"tests": [
500+
{
501+
"description": "with no unevaluated items",
502+
"data": ["foo", "bar"],
503+
"valid": true
504+
},
505+
{
506+
"description": "with unevaluated items",
507+
"data": ["foo", "bar", "baz"],
508+
"valid": false
509+
}
510+
]
511+
},
464512
{
465513
"description": "unevaluatedItems can't see inside cousins",
466514
"schema": {

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

+54
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,60 @@
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+
"type": "object",
737+
"properties": {
738+
"foo": { "type": "string" }
739+
},
740+
"$dynamicRef": "#addons",
741+
"unevaluatedProperties": false,
742+
743+
"$defs": {
744+
"defaultAddons": {
745+
"$comment": "Needed to satisfy the bookending requirement",
746+
"$dynamicAnchor": "addons"
747+
}
748+
}
749+
}
750+
}
751+
},
752+
"tests": [
753+
{
754+
"description": "with no unevaluated properties",
755+
"data": {
756+
"foo": "foo",
757+
"bar": "bar"
758+
},
759+
"valid": true
760+
},
761+
{
762+
"description": "with unevaluated properties",
763+
"data": {
764+
"foo": "foo",
765+
"bar": "bar",
766+
"baz": "baz"
767+
},
768+
"valid": false
769+
}
770+
]
771+
},
718772
{
719773
"description": "unevaluatedProperties can't see inside cousins",
720774
"schema": {

0 commit comments

Comments
 (0)