Skip to content
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

fix issue-311 #312

Closed
Closed
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/json-validator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ class root_schema
// for each token create an object, if not already existing
auto unk_kw = &file.unknown_keywords;
for (auto &rt : ref_tokens) {
auto existing_object = unk_kw->find(rt);
if (existing_object == unk_kw->end())
json::json_pointer rt_ptr{"/" + rt};
if (unk_kw->contains(rt_ptr) == false)
(*unk_kw)[rt] = json::object();
unk_kw = &(*unk_kw)[rt];
unk_kw = &(*unk_kw)[rt_ptr];
}
(*unk_kw)[key] = value;
}
Expand Down
3 changes: 3 additions & 0 deletions test/issue-311/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
add_test_simple_schema(Issue::311
${CMAKE_CURRENT_SOURCE_DIR}/schema.json
${CMAKE_CURRENT_SOURCE_DIR}/instance.json)
3 changes: 3 additions & 0 deletions test/issue-311/instance.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"element": [1]
}
19 changes: 19 additions & 0 deletions test/issue-311/schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"type": "object",
"properties": {
"element": {
"$ref": "#/$defs/element"
}
},
"$defs": {
"element": {
"type": "array",
"items": [
{
"$comment": "the comment should not lead to fail of loading schema",
"type": "number"
}
]
}
}
}
Loading