fix #101: throw an exception if JSON-type of schema is not one of the expected types
This commit is contained in:
parent
03af1b5e1e
commit
b28c15adea
@ -1163,7 +1163,7 @@ std::shared_ptr<schema> schema::make(json &schema,
|
|||||||
schema.erase("title");
|
schema.erase("title");
|
||||||
schema.erase("description");
|
schema.erase("description");
|
||||||
} else {
|
} 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
|
for (auto &uri : uris) { // for all URIs this schema is referenced by
|
||||||
|
|||||||
6
test/issue-101/CMakeLists.txt
Normal file
6
test/issue-101/CMakeLists.txt
Normal file
@ -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)
|
||||||
1
test/issue-101/instance.json
Normal file
1
test/issue-101/instance.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
{"top": 1}
|
||||||
12
test/issue-101/schema.json
Normal file
12
test/issue-101/schema.json
Normal file
@ -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"]
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user