Skip to content

Commit d2b64f2

Browse files
committed
unevaluatedProperties: deep dynamic + refs
This adds more tests to cover deep dynamic tracing of unevaluated properties inside references. Also a separate test for cyclic refs.
1 parent dee8ef7 commit d2b64f2

File tree

1 file changed

+211
-0
lines changed

1 file changed

+211
-0
lines changed

tests/draft2019-09/unevaluatedProperties.json

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -809,5 +809,216 @@
809809
"valid": false
810810
}
811811
]
812+
},
813+
{
814+
"description": "unevaluatedProperties + single cyclic ref",
815+
"schema": {
816+
"type": "object",
817+
"properties": {
818+
"x": { "$ref": "#" }
819+
},
820+
"unevaluatedProperties": false
821+
},
822+
"tests": [{
823+
"description": "Empty is valid",
824+
"data": {},
825+
"valid": true
826+
}, {
827+
"description": "Single is valid",
828+
"data": { "x": {} },
829+
"valid": true
830+
}, {
831+
"description": "Unevaluated on 1st level is invalid",
832+
"data": { "x": {}, "y": {} },
833+
"valid": false
834+
}, {
835+
"description": "Nested is valid",
836+
"data": { "x": { "x": {} } },
837+
"valid": true
838+
}, {
839+
"description": "Unevaluated on 2nd level is invalid",
840+
"data": { "x": { "x": {}, "y": {} } },
841+
"valid": false
842+
}, {
843+
"description": "Deep nested is valid",
844+
"data": { "x": { "x": { "x": {} } } },
845+
"valid": true
846+
}, {
847+
"description": "Unevaluated on 3rd level is invalid",
848+
"data": { "x": { "x": { "x": {}, "y": {} } } },
849+
"valid": false
850+
}]
851+
},
852+
{
853+
"description": "unevaluatedProperties + ref inside allOf / oneOf",
854+
"schema": {
855+
"$defs": {
856+
"one": {
857+
"properties": { "a": true }
858+
},
859+
"two": {
860+
"required": ["x"],
861+
"properties": { "x": true }
862+
}
863+
},
864+
"allOf": [
865+
{ "$ref": "#/$defs/one" },
866+
{ "properties": { "b": true } },
867+
{
868+
"oneOf": [
869+
{ "$ref": "#/$defs/two" },
870+
{
871+
"required": ["y"],
872+
"properties": { "y": true }
873+
}
874+
]
875+
}
876+
],
877+
"unevaluatedProperties": false
878+
},
879+
"tests": [{
880+
"description": "Empty is invalid (no x or y)",
881+
"data": {},
882+
"valid": false
883+
}, {
884+
"description": "a and b are invalid (no x or y)",
885+
"data": { "a": 1, "b": 1 },
886+
"valid": false
887+
}, {
888+
"description": "x and y are invalid",
889+
"data": { "x": 1, "y": 1 },
890+
"valid": false
891+
}, {
892+
"description": "a and x are valid",
893+
"data": { "a": 1, "x": 1 },
894+
"valid": true
895+
}, {
896+
"description": "a and y are valid",
897+
"data": { "a": 1, "y": 1 },
898+
"valid": true
899+
}, {
900+
"description": "a and b and x are valid",
901+
"data": { "a": 1, "b": 1, "x": 1 },
902+
"valid": true
903+
}, {
904+
"description": "a and b and y are valid",
905+
"data": { "a": 1, "b": 1, "y": 1 },
906+
"valid": true
907+
}, {
908+
"description": "a and b and x and y are invalid",
909+
"data": { "a": 1, "b": 1, "x": 1, "y": 1 },
910+
"valid": false
911+
}]
912+
},
913+
{
914+
"description": "dynamic evalation inside nested refs",
915+
"schema": {
916+
"$defs": {
917+
"one": {
918+
"oneOf": [
919+
{ "$ref": "#/$defs/two" },
920+
{ "required": ["b"], "properties": { "b": true } },
921+
{ "required": ["xx"], "patternProperties": { "x": true } },
922+
{ "required": ["all"], "unevaluatedProperties": true }
923+
]
924+
},
925+
"two": {
926+
"oneOf": [
927+
{ "required": ["c"], "properties": { "c": true } },
928+
{ "required": ["d"], "properties": { "d": true } }
929+
]
930+
}
931+
},
932+
"oneOf": [
933+
{ "$ref": "#/$defs/one" },
934+
{ "required": ["a"], "properties": { "a": true } }
935+
],
936+
"unevaluatedProperties": false
937+
},
938+
"tests": [{
939+
"description": "Empty is invalid",
940+
"data": {},
941+
"valid": false
942+
}, {
943+
"description": "a is valid",
944+
"data": { "a": 1 },
945+
"valid": true
946+
}, {
947+
"description": "b is valid",
948+
"data": { "b": 1 },
949+
"valid": true
950+
}, {
951+
"description": "c is valid",
952+
"data": { "c": 1 },
953+
"valid": true
954+
}, {
955+
"description": "d is valid",
956+
"data": { "d": 1 },
957+
"valid": true
958+
}, {
959+
"description": "a + b is invalid",
960+
"data": { "a": 1, "b": 1 },
961+
"valid": false
962+
}, {
963+
"description": "a + c is invalid",
964+
"data": { "a": 1, "c": 1 },
965+
"valid": false
966+
}, {
967+
"description": "a + d is invalid",
968+
"data": { "a": 1, "d": 1 },
969+
"valid": false
970+
}, {
971+
"description": "b + c is invalid",
972+
"data": { "b": 1, "c": 1 },
973+
"valid": false
974+
}, {
975+
"description": "b + d is invalid",
976+
"data": { "b": 1, "d": 1 },
977+
"valid": false
978+
}, {
979+
"description": "c + d is invalid",
980+
"data": { "c": 1, "d": 1 },
981+
"valid": false
982+
}, {
983+
"description": "xx is valid",
984+
"data": { "xx": 1 },
985+
"valid": true
986+
}, {
987+
"description": "xx + foox is valid",
988+
"data": { "xx": 1, "foox": 1 },
989+
"valid": true
990+
}, {
991+
"description": "xx + foo is invalid",
992+
"data": { "xx": 1, "foo": 1 },
993+
"valid": false
994+
}, {
995+
"description": "xx + a is invalid",
996+
"data": { "xx": 1, "a": 1 },
997+
"valid": false
998+
}, {
999+
"description": "xx + b is invalid",
1000+
"data": { "xx": 1, "b": 1 },
1001+
"valid": false
1002+
}, {
1003+
"description": "xx + c is invalid",
1004+
"data": { "xx": 1, "c": 1 },
1005+
"valid": false
1006+
}, {
1007+
"description": "xx + d is invalid",
1008+
"data": { "xx": 1, "d": 1 },
1009+
"valid": false
1010+
}, {
1011+
"description": "all is valid",
1012+
"data": { "all": 1 },
1013+
"valid": true
1014+
}, {
1015+
"description": "all + foo is valid",
1016+
"data": { "all": 1, "foo": 1 },
1017+
"valid": true
1018+
}, {
1019+
"description": "all + a is invalid",
1020+
"data": { "all": 1, "a": 1 },
1021+
"valid": false
1022+
}]
8121023
}
8131024
]

0 commit comments

Comments
 (0)