fix #100: only look for "unknown keyword" if the uri contains a pointer.
This commit is contained in:
parent
81eba4928d
commit
03af1b5e1e
@ -177,6 +177,10 @@ public:
|
|||||||
return schema->second;
|
return schema->second;
|
||||||
|
|
||||||
// referencing an unknown keyword, turn it into schema
|
// referencing an unknown keyword, turn it into schema
|
||||||
|
//
|
||||||
|
// an unknown keyword can only be referenced by a json-pointer,
|
||||||
|
// not by a plain name fragment
|
||||||
|
if (uri.pointer() != "") {
|
||||||
try {
|
try {
|
||||||
auto &subschema = file.unknown_keywords.at(uri.pointer()); // null is returned if not existing
|
auto &subschema = file.unknown_keywords.at(uri.pointer()); // null is returned if not existing
|
||||||
auto s = schema::make(subschema, this, {}, {{uri}}); // A JSON Schema MUST be an object or a boolean.
|
auto s = schema::make(subschema, this, {}, {{uri}}); // A JSON Schema MUST be an object or a boolean.
|
||||||
@ -186,6 +190,7 @@ public:
|
|||||||
}
|
}
|
||||||
} catch (nlohmann::detail::out_of_range &) { // at() did not find it
|
} catch (nlohmann::detail::out_of_range &) { // at() did not find it
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// get or create a schema_ref
|
// get or create a schema_ref
|
||||||
auto r = file.unresolved.lower_bound(uri.fragment());
|
auto r = file.unresolved.lower_bound(uri.fragment());
|
||||||
|
|||||||
6
test/issue-100/CMakeLists.txt
Normal file
6
test/issue-100/CMakeLists.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
add_test_simple_schema(Issue::100
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/schema.json
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/instance.json)
|
||||||
|
set_tests_properties(Issue::100
|
||||||
|
PROPERTIES
|
||||||
|
WILL_FAIL 1)
|
||||||
4
test/issue-100/instance.json
Normal file
4
test/issue-100/instance.json
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
{
|
||||||
|
"Prop1": 1,
|
||||||
|
"Prop2": []
|
||||||
|
}
|
||||||
15
test/issue-100/schema.json
Normal file
15
test/issue-100/schema.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"$id": "http://xxx.local/schemas/mySchema.json",
|
||||||
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
|
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"Prop1": {
|
||||||
|
"type": "integer",
|
||||||
|
"$comment": "Just a comment"
|
||||||
|
},
|
||||||
|
"Prop2": {
|
||||||
|
"$ref": "#random_ref"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user