Skip to content

Commit 8d78c51

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 8d78c51

File tree

3 files changed

+751
-0
lines changed

3 files changed

+751
-0
lines changed

tests/draft-future/unevaluatedProperties.json

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

0 commit comments

Comments
 (0)