schema-URIs with plain name identifiers cannot have derived sub-schema-URIs

fix #96
This commit is contained in:
Patrick Boettcher 2020-04-02 15:55:50 +02:00
parent b28c15adea
commit 2cc7e9aaa5
4 changed files with 37 additions and 0 deletions

View File

@ -1118,6 +1118,13 @@ std::shared_ptr<schema> schema::make(json &schema,
const std::vector<std::string> &keys,
std::vector<nlohmann::json_uri> uris)
{
// remove URIs which contain plain name identifiers, as sub-schemas cannot be referenced
for (auto uri = uris.begin(); uri != uris.end();)
if (uri->identifier() != "")
uri = uris.erase(uri);
else
uri++;
// append to all URIs the keys for this sub-schema
for (auto &key : keys)
for (auto &uri : uris)

View File

@ -0,0 +1,6 @@
add_test_simple_schema(Issue::96
${CMAKE_CURRENT_SOURCE_DIR}/schema.json
${CMAKE_CURRENT_SOURCE_DIR}/instance.json)
set_tests_properties(Issue::96
PROPERTIES
WILL_FAIL 1)

View File

@ -0,0 +1 @@
{"top": {"value": 101}}

23
test/issue-96/schema.json Normal file
View File

@ -0,0 +1,23 @@
{
"$id": "http://xxx.local/schemas/mySchema.json",
"$schema": "http://json-schema.org/draft-07/schema#",
"definitions": {
"topDef": {
"$id": "#topDef_ref",
"type": "object",
"properties": {
"value": {
"type": "integer",
"maximum": 100
}
}
}
},
"type": "object",
"properties": {
"top": {
"$ref": "#/definitions/topDef"
}
}
}