Skip to content

Commit 8999eae

Browse files
$recursiveRef example demonstrating dynamic nature of the resolution scope
..as discussed in json-schema-org/json-schema-spec#1041
1 parent f47003f commit 8999eae

File tree

1 file changed

+47
-1
lines changed

1 file changed

+47
-1
lines changed

tests/draft2019-09/recursiveRef.json

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@
291291
},
292292
"tests": [
293293
{
294-
"description": "leaf node does not match; no recursion",
294+
"description": "leaf node does not match; no recursion",
295295
"data": { "foo": true },
296296
"valid": false
297297
},
@@ -306,5 +306,51 @@
306306
"valid": false
307307
}
308308
]
309+
},
310+
{
311+
"description": "multiple dynamic paths to the $recursiveRef keyword",
312+
"schema": {
313+
"$id": "recursiveRef8_main.json",
314+
"$defs": {
315+
"inner": {
316+
"$id": "recursiveRef8_inner.json",
317+
"$recursiveAnchor": true,
318+
"title": "inner",
319+
"additionalProperties": {
320+
"$recursiveRef": "#"
321+
}
322+
}
323+
},
324+
"if": {
325+
"propertyNames": {
326+
"pattern": "^[a-m]"
327+
}
328+
},
329+
"then": {
330+
"title": "any type of node",
331+
"$id": "recursiveRef8_anyLeafNode.json",
332+
"$recursiveAnchor": true,
333+
"$ref": "recursiveRef8_main.json#/$defs/inner"
334+
},
335+
"else": {
336+
"title": "integer node",
337+
"$id": "recursiveRef8_integerNode.json",
338+
"$recursiveAnchor": true,
339+
"type": [ "object", "integer" ],
340+
"$ref": "recursiveRef8_main.json#/$defs/inner"
341+
}
342+
},
343+
"tests": [
344+
{
345+
"description": "recurse to anyLeafNode - floats are allowed",
346+
"data": { "alpha": 1.1 },
347+
"valid": true
348+
},
349+
{
350+
"description": "recurse to integerNode - floats are not allowed",
351+
"data": { "november": 1.1 },
352+
"valid": false
353+
}
354+
]
309355
}
310356
]

0 commit comments

Comments
 (0)