Skip to content

Commit cd99094

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 cd99094

File tree

4 files changed

+694
-0
lines changed

4 files changed

+694
-0
lines changed

tests/draft2019-09/unevaluatedItems.json

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,5 +433,134 @@
433433
"valid": false
434434
}
435435
]
436+
},
437+
{
438+
"description": "item is evaluated in a sibling schema to unevaluatedItems",
439+
"schema": {
440+
"type": "array",
441+
"items": [
442+
{
443+
"type": "string"
444+
}
445+
],
446+
"unevaluatedItems": false,
447+
"anyOf": [
448+
{
449+
"items": [
450+
{
451+
"type": "string"
452+
}
453+
]
454+
}
455+
]
456+
},
457+
"tests": [
458+
{
459+
"description": "no extra items",
460+
"data": [
461+
"test"
462+
],
463+
"valid": true
464+
},
465+
{
466+
"description": "uncle keyword evaluation is not significant",
467+
"data": [
468+
"test",
469+
"test"
470+
],
471+
"valid": false
472+
}
473+
]
474+
},
475+
{
476+
"description": "item is evaluated in an uncle schema to unevaluatedItems",
477+
"schema": {
478+
"type": "object",
479+
"properties": {
480+
"foo": {
481+
"type": "array",
482+
"items": [
483+
{
484+
"type": "string"
485+
}
486+
],
487+
"unevaluatedItems": false
488+
}
489+
},
490+
"anyOf": [
491+
{
492+
"properties": {
493+
"foo": {
494+
"items": [
495+
true,
496+
{
497+
"type": "string"
498+
}
499+
]
500+
}
501+
}
502+
}
503+
]
504+
},
505+
"tests": [
506+
{
507+
"description": "no extra items",
508+
"data": {
509+
"foo": [
510+
"test"
511+
]
512+
},
513+
"valid": true
514+
},
515+
{
516+
"description": "uncle keyword evaluation is not significant",
517+
"data": {
518+
"foo": [
519+
"test",
520+
"test"
521+
]
522+
},
523+
"valid": false
524+
}
525+
]
526+
},
527+
{
528+
"description": "item is evaluated in a nephew schema to unevaluatedItems",
529+
"schema": {
530+
"type": "array",
531+
"items": [
532+
{
533+
"type": "string"
534+
}
535+
],
536+
"unevaluatedItems": false,
537+
"anyOf": [
538+
{
539+
"items": [
540+
true,
541+
{
542+
"type": "string"
543+
}
544+
]
545+
}
546+
]
547+
},
548+
"tests": [
549+
{
550+
"description": "no extra items",
551+
"data": [
552+
"test"
553+
],
554+
"valid": true
555+
},
556+
{
557+
"description": "all in-place applicators are evaluated before unevaluatedItems",
558+
"data": [
559+
"test",
560+
"test"
561+
],
562+
"valid": true
563+
}
564+
]
436565
}
437566
]

tests/draft2019-09/unevaluatedProperties.json

Lines changed: 218 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,5 +809,223 @@
809809
"valid": false
810810
}
811811
]
812+
},
813+
{
814+
"description": "property is evaluated in a sibling schema to unevaluatedProperties",
815+
"schema": {
816+
"type": "object",
817+
"properties": {
818+
"foo": {
819+
"type": "string"
820+
}
821+
},
822+
"unevaluatedProperties": false,
823+
"anyOf": [
824+
{
825+
"properties": {
826+
"foo": {
827+
"type": "string"
828+
}
829+
}
830+
}
831+
]
832+
},
833+
"tests": [
834+
{
835+
"description": "no extra properties",
836+
"data": {
837+
"foo": "test"
838+
},
839+
"valid": true
840+
},
841+
{
842+
"description": "uncle keyword evaluation is not significant",
843+
"data": {
844+
"foo": "test",
845+
"bar": "test"
846+
},
847+
"valid": false
848+
}
849+
]
850+
},
851+
{
852+
"description": "property is evaluated in an uncle schema to unevaluatedProperties",
853+
"comment": "see https://stackoverflow.com/questions/66936884/deeply-nested-unevaluatedproperties-and-their-expectations",
854+
"schema": {
855+
"type": "object",
856+
"properties": {
857+
"foo": {
858+
"type": "object",
859+
"properties": {
860+
"bar": {
861+
"type": "string"
862+
}
863+
},
864+
"unevaluatedProperties": false
865+
}
866+
},
867+
"anyOf": [
868+
{
869+
"properties": {
870+
"foo": {
871+
"properties": {
872+
"faz": {
873+
"type": "string"
874+
}
875+
}
876+
}
877+
}
878+
}
879+
]
880+
},
881+
"tests": [
882+
{
883+
"description": "no extra properties",
884+
"data": {
885+
"foo": {
886+
"bar": "test"
887+
}
888+
},
889+
"valid": true
890+
},
891+
{
892+
"description": "uncle keyword evaluation is not significant",
893+
"data": {
894+
"foo": {
895+
"bar": "test",
896+
"faz": "test"
897+
}
898+
},
899+
"valid": false
900+
}
901+
]
902+
},
903+
{
904+
"description": "property is evaluated in a nephew schema to unevaluatedProperties",
905+
"schema": {
906+
"type": "object",
907+
"properties": {
908+
"bar": {
909+
"type": "string"
910+
}
911+
},
912+
"unevaluatedProperties": false,
913+
"anyOf": [
914+
{
915+
"properties": {
916+
"faz": {
917+
"type": "string"
918+
}
919+
}
920+
}
921+
]
922+
},
923+
"tests": [
924+
{
925+
"description": "no extra properties",
926+
"data": {
927+
"bar": "test"
928+
},
929+
"valid": true
930+
},
931+
{
932+
"description": "all in-place applicators are evaluated before unevaluatedProperties",
933+
"data": {
934+
"bar": "test",
935+
"faz": "test"
936+
},
937+
"valid": true
938+
}
939+
]
940+
},
941+
{
942+
"description": "in-place applicator siblings, allOf has unevaluated",
943+
"schema": {
944+
"type": "object",
945+
"allOf": [
946+
{
947+
"properties": {
948+
"foo": true
949+
},
950+
"unevaluatedProperties": false
951+
}
952+
],
953+
"anyOf": [
954+
{
955+
"properties": {
956+
"bar": true
957+
}
958+
}
959+
]
960+
},
961+
"tests": [
962+
{
963+
"description": "base case: both properties present",
964+
"data": {
965+
"foo": 1,
966+
"bar": 1
967+
},
968+
"valid": false
969+
},
970+
{
971+
"description": "in place applicator siblings, bar is missing",
972+
"data": {
973+
"foo": 1
974+
},
975+
"valid": true
976+
},
977+
{
978+
"description": "in place applicator siblings, foo is missing",
979+
"data": {
980+
"bar": 1
981+
},
982+
"valid": false
983+
}
984+
]
985+
},
986+
{
987+
"description": "in-place applicator siblings, anyOf has unevaluated",
988+
"schema": {
989+
"type": "object",
990+
"allOf": [
991+
{
992+
"properties": {
993+
"foo": true
994+
}
995+
}
996+
],
997+
"anyOf": [
998+
{
999+
"properties": {
1000+
"bar": true
1001+
},
1002+
"unevaluatedProperties": false
1003+
}
1004+
]
1005+
},
1006+
"tests": [
1007+
{
1008+
"description": "base case: both properties present",
1009+
"data": {
1010+
"foo": 1,
1011+
"bar": 1
1012+
},
1013+
"valid": false
1014+
},
1015+
{
1016+
"description": "in place applicator siblings, bar is missing",
1017+
"data": {
1018+
"foo": 1
1019+
},
1020+
"valid": false
1021+
},
1022+
{
1023+
"description": "in place applicator siblings, foo is missing",
1024+
"data": {
1025+
"bar": 1
1026+
},
1027+
"valid": true
1028+
}
1029+
]
8121030
}
8131031
]

0 commit comments

Comments
 (0)