diff --git a/src/json-validator.cpp b/src/json-validator.cpp index 54a94c7..8a1e834 100644 --- a/src/json-validator.cpp +++ b/src/json-validator.cpp @@ -1163,7 +1163,7 @@ std::shared_ptr schema::make(json &schema, schema.erase("title"); schema.erase("description"); } else { - return nullptr; // TODO error/throw? when schema is invalid + throw std::invalid_argument("invalid JSON-type for a schema for " + uris[0].to_string() + ", expected: boolean or object"); } for (auto &uri : uris) { // for all URIs this schema is referenced by diff --git a/test/issue-101/CMakeLists.txt b/test/issue-101/CMakeLists.txt new file mode 100644 index 0000000..41ad0c9 --- /dev/null +++ b/test/issue-101/CMakeLists.txt @@ -0,0 +1,6 @@ +add_test_simple_schema(Issue::101 + ${CMAKE_CURRENT_SOURCE_DIR}/schema.json + ${CMAKE_CURRENT_SOURCE_DIR}/instance.json) +set_tests_properties(Issue::101 + PROPERTIES + WILL_FAIL 1) diff --git a/test/issue-101/instance.json b/test/issue-101/instance.json new file mode 100644 index 0000000..fb5716b --- /dev/null +++ b/test/issue-101/instance.json @@ -0,0 +1 @@ +{"top": 1} diff --git a/test/issue-101/schema.json b/test/issue-101/schema.json new file mode 100644 index 0000000..19fad64 --- /dev/null +++ b/test/issue-101/schema.json @@ -0,0 +1,12 @@ +{ + "$id": "http://xxx.local/schemas/mySchema.json", + "$schema": "http://json-schema.org/draft-07/schema#", + + "type": "object", + "properties": { + "top": { + "type": "integer" + }, + "required": ["top"] + } +}