-
-
Notifications
You must be signed in to change notification settings - Fork 184
Closed
Description
I tried to validate json schema, which itself is invalid due to not allowed type, but library compiles it without any exceptions.
I except library would issue an exception on not allowed types or typing errors in schema file.
Here is short validation example and used schemafile.
#include <jsoncons_ext/jsonschema/jsonschema.hpp>
#include <jsoncons/json.hpp>
#include <iostream>
#include <fstream>
#include <string>
using jsoncons::ojson;
namespace jsonschema = jsoncons::jsonschema;
int main(int argc, char **argv)
{
const char *schema_file_name = argv[1];
try
{
std::ifstream schema_str(schema_file_name);
ojson schema = ojson::parse(schema_str);
jsonschema::json_schema<ojson> compiled = jsonschema::make_json_schema(std::move(schema));
std::cout << "schema is valid" << std::endl;
}
catch (const std::exception& e)
{
std::cout << e.what() << "\n";
}
return 0;
}
- Schemafile, which contain typing error for "type", where "object" and "string" are not written fully.
{
"type": "objec",
"properties": {
"name": {
"type": "strin"
}
}
}
- Compiler: gcc
$ gcc --version
gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
- Architecture : x86_64
- Operating system: Ubuntu
- jsoncons version : Latest release 1.2.0