Skip to content

Commit ed4cf5f

Browse files
more test cases for unevaluatedItems, unevaluatedProperties
Only annotations from sibling keywords (or children of sibling keywords) should be used by unevaluatedItems, unevaluatedProperties, rather than all annotations collected so far. see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations
1 parent d0d814d commit ed4cf5f

File tree

4 files changed

+388
-0
lines changed

4 files changed

+388
-0
lines changed

tests/draft2019-09/unevaluatedItems.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,5 +433,57 @@
433433
"valid": false
434434
}
435435
]
436+
},
437+
{
438+
"description": "item is evaluated in an uncle schema to unevaluatedItems",
439+
"schema": {
440+
"type": "object",
441+
"properties": {
442+
"foo": {
443+
"type": "array",
444+
"items": [
445+
{
446+
"type": "string"
447+
}
448+
],
449+
"unevaluatedItems": false
450+
}
451+
},
452+
"anyOf": [
453+
{
454+
"properties": {
455+
"foo": {
456+
"items": [
457+
true,
458+
{
459+
"type": "string"
460+
}
461+
]
462+
}
463+
}
464+
}
465+
]
466+
},
467+
"tests": [
468+
{
469+
"description": "no extra items",
470+
"data": {
471+
"foo": [
472+
"test"
473+
]
474+
},
475+
"valid": true
476+
},
477+
{
478+
"description": "uncle keyword evaluation is not significant",
479+
"data": {
480+
"foo": [
481+
"test",
482+
"test"
483+
]
484+
},
485+
"valid": false
486+
}
487+
]
436488
}
437489
]

tests/draft2019-09/unevaluatedProperties.json

Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,5 +809,147 @@
809809
"valid": false
810810
}
811811
]
812+
},
813+
{
814+
"description": "property is evaluated in an uncle schema to unevaluatedProperties",
815+
"comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations",
816+
"schema": {
817+
"type": "object",
818+
"properties": {
819+
"foo": {
820+
"type": "object",
821+
"properties": {
822+
"bar": {
823+
"type": "string"
824+
}
825+
},
826+
"unevaluatedProperties": false
827+
}
828+
},
829+
"anyOf": [
830+
{
831+
"properties": {
832+
"foo": {
833+
"properties": {
834+
"faz": {
835+
"type": "string"
836+
}
837+
}
838+
}
839+
}
840+
}
841+
]
842+
},
843+
"tests": [
844+
{
845+
"description": "no extra properties",
846+
"data": {
847+
"foo": {
848+
"bar": "test"
849+
}
850+
},
851+
"valid": true
852+
},
853+
{
854+
"description": "uncle keyword evaluation is not significant",
855+
"data": {
856+
"foo": {
857+
"bar": "test",
858+
"faz": "test"
859+
}
860+
},
861+
"valid": false
862+
}
863+
]
864+
},
865+
{
866+
"description": "in-place applicator siblings, allOf has unevaluated",
867+
"schema": {
868+
"type": "object",
869+
"allOf": [
870+
{
871+
"properties": {
872+
"foo": true
873+
},
874+
"unevaluatedProperties": false
875+
}
876+
],
877+
"anyOf": [
878+
{
879+
"properties": {
880+
"bar": true
881+
}
882+
}
883+
]
884+
},
885+
"tests": [
886+
{
887+
"description": "base case: both properties present",
888+
"data": {
889+
"foo": 1,
890+
"bar": 1
891+
},
892+
"valid": false
893+
},
894+
{
895+
"description": "in place applicator siblings, bar is missing",
896+
"data": {
897+
"foo": 1
898+
},
899+
"valid": true
900+
},
901+
{
902+
"description": "in place applicator siblings, foo is missing",
903+
"data": {
904+
"bar": 1
905+
},
906+
"valid": false
907+
}
908+
]
909+
},
910+
{
911+
"description": "in-place applicator siblings, anyOf has unevaluated",
912+
"schema": {
913+
"type": "object",
914+
"allOf": [
915+
{
916+
"properties": {
917+
"foo": true
918+
}
919+
}
920+
],
921+
"anyOf": [
922+
{
923+
"properties": {
924+
"bar": true
925+
},
926+
"unevaluatedProperties": false
927+
}
928+
]
929+
},
930+
"tests": [
931+
{
932+
"description": "base case: both properties present",
933+
"data": {
934+
"foo": 1,
935+
"bar": 1
936+
},
937+
"valid": false
938+
},
939+
{
940+
"description": "in place applicator siblings, bar is missing",
941+
"data": {
942+
"foo": 1
943+
},
944+
"valid": false
945+
},
946+
{
947+
"description": "in place applicator siblings, foo is missing",
948+
"data": {
949+
"bar": 1
950+
},
951+
"valid": true
952+
}
953+
]
812954
}
813955
]

tests/draft2020-12/unevaluatedItems.json

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,5 +433,57 @@
433433
"valid": false
434434
}
435435
]
436+
},
437+
{
438+
"description": "item is evaluated in an uncle schema to unevaluatedItems",
439+
"schema": {
440+
"type": "object",
441+
"properties": {
442+
"foo": {
443+
"type": "array",
444+
"prefixItems": [
445+
{
446+
"type": "string"
447+
}
448+
],
449+
"unevaluatedItems": false
450+
}
451+
},
452+
"anyOf": [
453+
{
454+
"properties": {
455+
"foo": {
456+
"prefixItems": [
457+
true,
458+
{
459+
"type": "string"
460+
}
461+
]
462+
}
463+
}
464+
}
465+
]
466+
},
467+
"tests": [
468+
{
469+
"description": "no extra items",
470+
"data": {
471+
"foo": [
472+
"test"
473+
]
474+
},
475+
"valid": true
476+
},
477+
{
478+
"description": "uncle keyword evaluation is not significant",
479+
"data": {
480+
"foo": [
481+
"test",
482+
"test"
483+
]
484+
},
485+
"valid": false
486+
}
487+
]
436488
}
437489
]

0 commit comments

Comments
 (0)