Parse a 2019 schema with relative refs #627
-
I am using Release 1.3.2. I try to parse a 2019-09 schema with internal references (all "$ref" start with "#/").
I checked it with node.js and ajv, there it can be parsed. My problem is, when I call jsonschema::make_json_schema( schema ), I get the exception "Don't know how to load JSON Schema 'https://jsoncons.com'". I learned, that if there is an $id or external references, then I need a reference resolver. But I am using just internal references and they do exist, so i expect not to need a resolver. Is there anything that I miss? thank you |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I think the issue is that you're using the keyword definitions rather than $defs with a 2019 JSON Schema. jsoncons can recognize definitions, but only if you specify "compatibility mode", i.e., try
{
auto sch = jsoncons::json::parse(schema_str);
auto options = jsoncons::jsonschema::evaluation_options{}
.compatibility_mode(true);
auto schema = jsoncons::jsonschema::make_json_schema(sch, options);
}
catch (const std::exception& e)
{
std::cout << e.what() << "\n";
} Admittedly the diagnostic message could be better. |
Beta Was this translation helpful? Give feedback.
I think the issue is that you're using the keyword definitions rather than $defs with a 2019 JSON Schema. jsoncons can recognize definitions, but only if you specify "compatibility mode", i.e.,
Admittedly the diagnostic message could be better.