Skip to content

$recursiveRef example demonstrating dynamic nature of the resolution scope #450

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 47 additions & 1 deletion tests/draft2019-09/recursiveRef.json
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@
},
"tests": [
{
"description": "leaf node does not match; no recursion",
"description": "leaf node does not match; no recursion",
"data": { "foo": true },
"valid": false
},
Expand All @@ -306,5 +306,51 @@
"valid": false
}
]
},
{
"description": "multiple dynamic paths to the $recursiveRef keyword",
"schema": {
"$id": "recursiveRef8_main.json",
"$defs": {
"inner": {
"$id": "recursiveRef8_inner.json",
"$recursiveAnchor": true,
"title": "inner",
"additionalProperties": {
"$recursiveRef": "#"
}
}
},
"if": {
"propertyNames": {
"pattern": "^[a-m]"
}
},
"then": {
"title": "any type of node",
"$id": "recursiveRef8_anyLeafNode.json",
"$recursiveAnchor": true,
"$ref": "recursiveRef8_main.json#/$defs/inner"
},
"else": {
"title": "integer node",
"$id": "recursiveRef8_integerNode.json",
"$recursiveAnchor": true,
"type": [ "object", "integer" ],
"$ref": "recursiveRef8_main.json#/$defs/inner"
}
},
"tests": [
{
"description": "recurse to anyLeafNode - floats are allowed",
"data": { "alpha": 1.1 },
"valid": true
},
{
"description": "recurse to integerNode - floats are not allowed",
"data": { "november": 1.1 },
"valid": false
}
]
}
]