Skip to content

Commit e2f3586

Browse files
committed
fix-311: add a comment and a detailed test-case
1 parent 396ffbb commit e2f3586

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/json-validator.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ class root_schema
226226
// for each token create an object, if not already existing
227227
auto unk_kw = &file.unknown_keywords;
228228
for (auto &rt : ref_tokens) {
229+
// create a json_pointer from rt as rt can be an stringified integer doing find on an array won't work
229230
json::json_pointer rt_ptr{"/" + rt};
230231
if (unk_kw->contains(rt_ptr) == false)
231232
(*unk_kw)[rt] = json::object();

test/issue-311/instance.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"element": [1]
2+
"element": [1],
3+
"element2": "test"
34
}

test/issue-311/schema.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@
33
"properties": {
44
"element": {
55
"$ref": "#/$defs/element"
6+
},
7+
"element2": {
8+
"$ref": "#/$defs/element/items/0/$defs/element2"
69
}
710
},
811
"$defs": {
912
"element": {
1013
"type": "array",
1114
"items": [
1215
{
13-
"$comment": "the comment should not lead to fail of loading schema",
16+
"$defs": {
17+
"element2": {
18+
"type": "string"
19+
}
20+
},
1421
"type": "number"
1522
}
1623
]

0 commit comments

Comments
 (0)