diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 8a1e834..d4b6ad4 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -1118,6 +1118,13 @@ std::shared_ptr schema::make(json &schema, const std::vector &keys, std::vector 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) diff --git a/test/issue-96/CMakeLists.txt b/test/issue-96/CMakeLists.txt new file mode 100644 index 0000000..03582e6 --- /dev/null +++ b/test/issue-96/CMakeLists.txt @@ -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) diff --git a/test/issue-96/instance.json b/test/issue-96/instance.json new file mode 100644 index 0000000..0756430 --- /dev/null +++ b/test/issue-96/instance.json @@ -0,0 +1 @@ +{"top": {"value": 101}} diff --git a/test/issue-96/schema.json b/test/issue-96/schema.json new file mode 100644 index 0000000..c608adf --- /dev/null +++ b/test/issue-96/schema.json @@ -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" + } + } +}