Skip to content

Commit

Permalink
default_base_uri
Browse files Browse the repository at this point in the history
  • Loading branch information
danielaparker committed Dec 5, 2024
1 parent eb256c1 commit b6ecc12
Show file tree
Hide file tree
Showing 9 changed files with 16 additions and 25 deletions.
3 changes: 1 addition & 2 deletions include/jsoncons_ext/jsonschema/common/schema_builder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,7 @@ namespace jsonschema {

for (const auto& prop : sch.object_range())
{
std::string sub_keys[] =
{"properties", prop.key()};
std::string sub_keys[] = {"properties", prop.key()};
properties.emplace(std::make_pair(prop.key(),
this->make_cross_draft_schema_validator(context, prop.value(), sub_keys, anchor_dict)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,10 @@ namespace draft201909 {

for (const auto& prop : sch.object_range())
{
std::string sub_keys[] = {prop.key()};
pattern_properties.emplace_back(
std::make_pair(
std::regex(prop.key(), std::regex::ECMAScript),
make_schema_validator(context, prop.value(), sub_keys, anchor_dict)));
make_schema_validator(context, prop.value(), {}, anchor_dict)));
}

return jsoncons::make_unique<pattern_properties_validator<Json>>(parent, std::move(schema_location),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,11 +512,10 @@ namespace draft202012 {

for (const auto& prop : sch.object_range())
{
std::string sub_keys[] = {prop.key()};
pattern_properties.emplace_back(
std::make_pair(
std::regex(prop.key(), std::regex::ECMAScript),
this->make_cross_draft_schema_validator(context, prop.value(), sub_keys, anchor_dict)));
this->make_cross_draft_schema_validator(context, prop.value(), {}, anchor_dict)));
}

return jsoncons::make_unique<pattern_properties_validator<Json>>(parent, std::move(schema_location),
Expand Down
3 changes: 1 addition & 2 deletions include/jsoncons_ext/jsonschema/draft4/schema_builder_4.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,11 +285,10 @@ namespace draft4 {

for (const auto& prop : sch.object_range())
{
std::string sub_keys[] = {prop.key()};
pattern_properties.emplace_back(
std::make_pair(
std::regex(prop.key(), std::regex::ECMAScript),
make_schema_validator(context, prop.value(), sub_keys, anchor_dict)));
make_schema_validator(context, prop.value(), {}, anchor_dict)));
}

return jsoncons::make_unique<pattern_properties_validator<Json>>(parent, std::move(schema_location),
Expand Down
3 changes: 1 addition & 2 deletions include/jsoncons_ext/jsonschema/draft6/schema_builder_6.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,11 +297,10 @@ namespace draft6 {

for (const auto& prop : sch.object_range())
{
std::string sub_keys[] = {prop.key()};
pattern_properties.emplace_back(
std::make_pair(
std::regex(prop.key(), std::regex::ECMAScript),
make_schema_validator(context, prop.value(), sub_keys, anchor_dict)));
make_schema_validator(context, prop.value(), {}, anchor_dict)));
}

return jsoncons::make_unique<pattern_properties_validator<Json>>(parent, std::move(schema_location),
Expand Down
4 changes: 1 addition & 3 deletions include/jsoncons_ext/jsonschema/draft7/schema_builder_7.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ namespace draft7 {
anchor_uri_map_type& anchor_dict) override
{
auto new_context = make_compilation_context(context, sch, keys);
//std::cout << "make_schema_validator " << context.get_base_uri().string() << ", " << new_context.get_base_uri().string() << "\n\n";

schema_validator_type schema_validator_ptr;

Expand Down Expand Up @@ -330,11 +329,10 @@ namespace draft7 {

for (const auto& prop : sch.object_range())
{
std::string sub_keys[] = {prop.key()};
pattern_properties.emplace_back(
std::make_pair(
std::regex(prop.key(), std::regex::ECMAScript),
make_schema_validator(context, prop.value(), sub_keys, anchor_dict)));
make_schema_validator(context, prop.value(), {}, anchor_dict)));
}

return jsoncons::make_unique<pattern_properties_validator<Json>>(parent, std::move(schema_location),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[
/*{
{
"description":
"patternProperties validates properties matching a regex",
"schema": {
Expand Down Expand Up @@ -85,7 +85,7 @@
"valid": false
}
]
},*/
},
{
"description": "regexes are not anchored by default and are case sensitive",
"schema": {
Expand Down Expand Up @@ -116,7 +116,7 @@
"valid": false
}*/
]
}/*,
},
{
"description": "patternProperties with boolean schemas",
"schema": {
Expand Down Expand Up @@ -167,5 +167,5 @@
"valid": true
}
]
}*/
}
]
4 changes: 2 additions & 2 deletions test/jsonschema/JSON-Schema-Test-Suite/tests/draft7/ref.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
}
},
"tests": [
{
/*{
"description": "match",
"data": {"bar": 3},
"valid": true
Expand All @@ -48,7 +48,7 @@
"description": "mismatch",
"data": {"bar": true},
"valid": false
}
}*/
]
},
{
Expand Down
10 changes: 4 additions & 6 deletions test/jsonschema/src/jsonschema_draft7_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,11 @@ TEST_CASE("jsonschema draft7 tests")
{
SECTION("issues")
{
jsonschema_tests("./jsonschema/JSON-Schema-Test-Suite/tests/draft7/patternProperties.json");
//jsonschema_tests("./jsonschema/issues/draft7/issue-520.json",
// jsonschema::evaluation_options{}.default_version(jsonschema::schema_version::draft7()).
// require_format_validation(true));
jsonschema_tests("./jsonschema/issues/draft7/issue-520.json",
jsonschema::evaluation_options{}.default_version(jsonschema::schema_version::draft7()).
require_format_validation(true));
}
#if 0

SECTION("tests")
{
jsonschema_tests("./jsonschema/JSON-Schema-Test-Suite/tests/draft7/additionalItems.json");
Expand Down Expand Up @@ -241,5 +240,4 @@ TEST_CASE("jsonschema draft7 tests")

CHECK_FALSE(compiled.is_valid(instance));
}
#endif
}

0 comments on commit b6ecc12

Please sign in to comment.