Skip to content

Commit 4f8c6d7

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 9103f3b commit 4f8c6d7

File tree

3 files changed

+750
-0
lines changed

3 files changed

+750
-0
lines changed

tests/draft-future/unevaluatedProperties.json

Lines changed: 250 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,6 +1058,256 @@
10581058
}
10591059
]
10601060
},
1061+
{
1062+
"description": "unevaluatedProperties + single cyclic ref",
1063+
"schema": {
1064+
"type": "object",
1065+
"properties": {
1066+
"x": { "$ref": "#" }
1067+
},
1068+
"unevaluatedProperties": false
1069+
},
1070+
"tests": [
1071+
{
1072+
"description": "Empty is valid",
1073+
"data": {},
1074+
"valid": true
1075+
},
1076+
{
1077+
"description": "Single is valid",
1078+
"data": { "x": {} },
1079+
"valid": true
1080+
},
1081+
{
1082+
"description": "Unevaluated on 1st level is invalid",
1083+
"data": { "x": {}, "y": {} },
1084+
"valid": false
1085+
},
1086+
{
1087+
"description": "Nested is valid",
1088+
"data": { "x": { "x": {} } },
1089+
"valid": true
1090+
},
1091+
{
1092+
"description": "Unevaluated on 2nd level is invalid",
1093+
"data": { "x": { "x": {}, "y": {} } },
1094+
"valid": false
1095+
},
1096+
{
1097+
"description": "Deep nested is valid",
1098+
"data": { "x": { "x": { "x": {} } } },
1099+
"valid": true
1100+
},
1101+
{
1102+
"description": "Unevaluated on 3rd level is invalid",
1103+
"data": { "x": { "x": { "x": {}, "y": {} } } },
1104+
"valid": false
1105+
}
1106+
]
1107+
},
1108+
{
1109+
"description": "unevaluatedProperties + ref inside allOf / oneOf",
1110+
"schema": {
1111+
"$defs": {
1112+
"one": {
1113+
"properties": { "a": true }
1114+
},
1115+
"two": {
1116+
"required": ["x"],
1117+
"properties": { "x": true }
1118+
}
1119+
},
1120+
"allOf": [
1121+
{ "$ref": "#/$defs/one" },
1122+
{ "properties": { "b": true } },
1123+
{
1124+
"oneOf": [
1125+
{ "$ref": "#/$defs/two" },
1126+
{
1127+
"required": ["y"],
1128+
"properties": { "y": true }
1129+
}
1130+
]
1131+
}
1132+
],
1133+
"unevaluatedProperties": false
1134+
},
1135+
"tests": [
1136+
{
1137+
"description": "Empty is invalid (no x or y)",
1138+
"data": {},
1139+
"valid": false
1140+
},
1141+
{
1142+
"description": "a and b are invalid (no x or y)",
1143+
"data": { "a": 1, "b": 1 },
1144+
"valid": false
1145+
},
1146+
{
1147+
"description": "x and y are invalid",
1148+
"data": { "x": 1, "y": 1 },
1149+
"valid": false
1150+
},
1151+
{
1152+
"description": "a and x are valid",
1153+
"data": { "a": 1, "x": 1 },
1154+
"valid": true
1155+
},
1156+
{
1157+
"description": "a and y are valid",
1158+
"data": { "a": 1, "y": 1 },
1159+
"valid": true
1160+
},
1161+
{
1162+
"description": "a and b and x are valid",
1163+
"data": { "a": 1, "b": 1, "x": 1 },
1164+
"valid": true
1165+
},
1166+
{
1167+
"description": "a and b and y are valid",
1168+
"data": { "a": 1, "b": 1, "y": 1 },
1169+
"valid": true
1170+
},
1171+
{
1172+
"description": "a and b and x and y are invalid",
1173+
"data": { "a": 1, "b": 1, "x": 1, "y": 1 },
1174+
"valid": false
1175+
}
1176+
]
1177+
},
1178+
{
1179+
"description": "dynamic evalation inside nested refs",
1180+
"schema": {
1181+
"$defs": {
1182+
"one": {
1183+
"oneOf": [
1184+
{ "$ref": "#/$defs/two" },
1185+
{ "required": ["b"], "properties": { "b": true } },
1186+
{ "required": ["xx"], "patternProperties": { "x": true } },
1187+
{ "required": ["all"], "unevaluatedProperties": true }
1188+
]
1189+
},
1190+
"two": {
1191+
"oneOf": [
1192+
{ "required": ["c"], "properties": { "c": true } },
1193+
{ "required": ["d"], "properties": { "d": true } }
1194+
]
1195+
}
1196+
},
1197+
"oneOf": [
1198+
{ "$ref": "#/$defs/one" },
1199+
{ "required": ["a"], "properties": { "a": true } }
1200+
],
1201+
"unevaluatedProperties": false
1202+
},
1203+
"tests": [
1204+
{
1205+
"description": "Empty is invalid",
1206+
"data": {},
1207+
"valid": false
1208+
},
1209+
{
1210+
"description": "a is valid",
1211+
"data": { "a": 1 },
1212+
"valid": true
1213+
},
1214+
{
1215+
"description": "b is valid",
1216+
"data": { "b": 1 },
1217+
"valid": true
1218+
},
1219+
{
1220+
"description": "c is valid",
1221+
"data": { "c": 1 },
1222+
"valid": true
1223+
},
1224+
{
1225+
"description": "d is valid",
1226+
"data": { "d": 1 },
1227+
"valid": true
1228+
},
1229+
{
1230+
"description": "a + b is invalid",
1231+
"data": { "a": 1, "b": 1 },
1232+
"valid": false
1233+
},
1234+
{
1235+
"description": "a + c is invalid",
1236+
"data": { "a": 1, "c": 1 },
1237+
"valid": false
1238+
},
1239+
{
1240+
"description": "a + d is invalid",
1241+
"data": { "a": 1, "d": 1 },
1242+
"valid": false
1243+
},
1244+
{
1245+
"description": "b + c is invalid",
1246+
"data": { "b": 1, "c": 1 },
1247+
"valid": false
1248+
},
1249+
{
1250+
"description": "b + d is invalid",
1251+
"data": { "b": 1, "d": 1 },
1252+
"valid": false
1253+
},
1254+
{
1255+
"description": "c + d is invalid",
1256+
"data": { "c": 1, "d": 1 },
1257+
"valid": false
1258+
},
1259+
{
1260+
"description": "xx is valid",
1261+
"data": { "xx": 1 },
1262+
"valid": true
1263+
},
1264+
{
1265+
"description": "xx + foox is valid",
1266+
"data": { "xx": 1, "foox": 1 },
1267+
"valid": true
1268+
},
1269+
{
1270+
"description": "xx + foo is invalid",
1271+
"data": { "xx": 1, "foo": 1 },
1272+
"valid": false
1273+
},
1274+
{
1275+
"description": "xx + a is invalid",
1276+
"data": { "xx": 1, "a": 1 },
1277+
"valid": false
1278+
},
1279+
{
1280+
"description": "xx + b is invalid",
1281+
"data": { "xx": 1, "b": 1 },
1282+
"valid": false
1283+
},
1284+
{
1285+
"description": "xx + c is invalid",
1286+
"data": { "xx": 1, "c": 1 },
1287+
"valid": false
1288+
},
1289+
{
1290+
"description": "xx + d is invalid",
1291+
"data": { "xx": 1, "d": 1 },
1292+
"valid": false
1293+
},
1294+
{
1295+
"description": "all is valid",
1296+
"data": { "all": 1 },
1297+
"valid": true
1298+
},
1299+
{
1300+
"description": "all + foo is valid",
1301+
"data": { "all": 1, "foo": 1 },
1302+
"valid": true
1303+
},
1304+
{
1305+
"description": "all + a is invalid",
1306+
"data": { "all": 1, "a": 1 },
1307+
"valid": false
1308+
}
1309+
]
1310+
},
10611311
{
10621312
"description": "unevaluatedProperties depends on adjacent contains",
10631313
"schema": {

0 commit comments

Comments
 (0)