Skip to content

Commit

Permalink
fix-311: add a comment and a detailed test-case
Browse files Browse the repository at this point in the history
  • Loading branch information
pboettch committed Feb 5, 2024
1 parent 396ffbb commit e2f3586
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/json-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ class root_schema
// for each token create an object, if not already existing
auto unk_kw = &file.unknown_keywords;
for (auto &rt : ref_tokens) {
// create a json_pointer from rt as rt can be an stringified integer doing find on an array won't work
json::json_pointer rt_ptr{"/" + rt};
if (unk_kw->contains(rt_ptr) == false)
(*unk_kw)[rt] = json::object();
Expand Down
3 changes: 2 additions & 1 deletion test/issue-311/instance.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"element": [1]
"element": [1],
"element2": "test"
}
9 changes: 8 additions & 1 deletion test/issue-311/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@
"properties": {
"element": {
"$ref": "#/$defs/element"
},
"element2": {
"$ref": "#/$defs/element/items/0/$defs/element2"
}
},
"$defs": {
"element": {
"type": "array",
"items": [
{
"$comment": "the comment should not lead to fail of loading schema",
"$defs": {
"element2": {
"type": "string"
}
},
"type": "number"
}
]
Expand Down

0 comments on commit e2f3586

Please sign in to comment.