From e36bfc0bd3f53fbcff8e245cd1c2eb947418469d Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 12 Feb 2025 15:19:28 -0400 Subject: [PATCH] [WIP] Extend schema walker to account for conditional instance locations Signed-off-by: Juan Cruz Viotti --- src/core/jsonschema/frame.cc | 2 +- .../sourcemeta/core/jsonschema_types.h | 10 ++- src/core/jsonschema/official_walker.cc | 65 ++++++++++--------- src/core/jsonschema/walker.cc | 31 +++++++-- ...jsonschema_official_walker_2019_09_test.cc | 8 ++- ...jsonschema_official_walker_2020_12_test.cc | 11 ++-- .../jsonschema_official_walker_draft0_test.cc | 8 ++- .../jsonschema_official_walker_draft1_test.cc | 8 ++- .../jsonschema_official_walker_draft2_test.cc | 8 ++- .../jsonschema_official_walker_draft3_test.cc | 13 ++-- .../jsonschema_official_walker_draft4_test.cc | 5 +- .../jsonschema_official_walker_draft6_test.cc | 5 +- .../jsonschema_official_walker_draft7_test.cc | 5 +- test/jsonschema/jsonschema_walker_test.cc | 4 +- 14 files changed, 113 insertions(+), 70 deletions(-) diff --git a/src/core/jsonschema/frame.cc b/src/core/jsonschema/frame.cc index cd307ec6d..ea212d100 100644 --- a/src/core/jsonschema/frame.cc +++ b/src/core/jsonschema/frame.cc @@ -1084,7 +1084,7 @@ auto find_adjacent_dependencies( } break; - case SchemaKeywordType::ApplicatorMembersInPlace: + case SchemaKeywordType::ApplicatorMembersInPlaceSome: if (property.second.is_object()) { for (const auto &pair : property.second.as_object()) { find_adjacent_dependencies( diff --git a/src/core/jsonschema/include/sourcemeta/core/jsonschema_types.h b/src/core/jsonschema/include/sourcemeta/core/jsonschema_types.h index 1b29e0360..aa49eca5d 100644 --- a/src/core/jsonschema/include/sourcemeta/core/jsonschema_types.h +++ b/src/core/jsonschema/include/sourcemeta/core/jsonschema_types.h @@ -87,8 +87,8 @@ enum class SchemaKeywordType : std::uint8_t { ApplicatorMembersTraversePropertyRegex, /// The JSON Schema keyword is an applicator that potentially /// takes a JSON Schema definition as an argument - /// The instance traverses to any property - ApplicatorValueTraverseAnyProperty, + /// The instance traverses to some of the properties + ApplicatorValueTraverseSomeProperty, /// The JSON Schema keyword is an applicator that potentially /// takes a JSON Schema definition as an argument /// The instance traverses to any property key @@ -99,6 +99,10 @@ enum class SchemaKeywordType : std::uint8_t { ApplicatorValueTraverseAnyItem, /// The JSON Schema keyword is an applicator that potentially /// takes a JSON Schema definition as an argument + /// The instance traverses to some of the items + ApplicatorValueTraverseSomeItem, + /// The JSON Schema keyword is an applicator that potentially + /// takes a JSON Schema definition as an argument /// The instance traverses back to the parent ApplicatorValueTraverseParent, /// The JSON Schema keyword is an applicator that potentially @@ -120,7 +124,7 @@ enum class SchemaKeywordType : std::uint8_t { /// takes an object as argument, whose values are potentially /// JSON Schema definitions without affecting the instance location. /// The instance does not traverse - ApplicatorMembersInPlace, + ApplicatorMembersInPlaceSome, /// The JSON Schema keyword is an applicator that potentially /// takes an array of potentially JSON Schema definitions /// as an argument without affecting the instance location diff --git a/src/core/jsonschema/official_walker.cc b/src/core/jsonschema/official_walker.cc index 556476601..ff7d2e5b2 100644 --- a/src/core/jsonschema/official_walker.cc +++ b/src/core/jsonschema/official_walker.cc @@ -53,19 +53,19 @@ auto sourcemeta::core::schema_official_walker( ApplicatorMembersTraversePropertyStatic, HTTPS_BASE "2020-12/vocab/validation", "required") WALK(HTTPS_BASE "2020-12/vocab/applicator", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties", "patternProperties") + ApplicatorValueTraverseSomeProperty, "properties", "patternProperties") WALK(HTTPS_BASE "2020-12/vocab/applicator", "patternProperties", ApplicatorMembersTraversePropertyRegex) WALK(HTTPS_BASE "2020-12/vocab/applicator", "propertyNames", ApplicatorValueTraverseAnyPropertyKey) WALK(HTTPS_BASE "2020-12/vocab/applicator", "dependentSchemas", - ApplicatorMembersInPlace) + ApplicatorMembersInPlaceSome) WALK_MAYBE_DEPENDENT(HTTPS_BASE "2020-12/vocab/applicator", "contains", ApplicatorValueTraverseAnyItem, HTTPS_BASE "2020-12/vocab/validation", "minContains", "maxContains") WALK(HTTPS_BASE "2020-12/vocab/applicator", "items", - ApplicatorValueTraverseAnyItem, "prefixItems") + ApplicatorValueTraverseSomeItem, "prefixItems") WALK(HTTPS_BASE "2020-12/vocab/applicator", "prefixItems", ApplicatorElementsTraverseItem) // For the purpose of compiler optimizations @@ -98,12 +98,13 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTPS_BASE "2020-12/vocab/meta-data", "default", Annotation) WALK(HTTPS_BASE "2020-12/vocab/meta-data", "deprecated", Annotation) WALK(HTTPS_BASE "2020-12/vocab/format-annotation", "format", Annotation) - WALK_MAYBE_DEPENDENT( - HTTPS_BASE "2020-12/vocab/unevaluated", "unevaluatedProperties", - ApplicatorValueTraverseAnyProperty, HTTPS_BASE "2020-12/vocab/applicator", - "properties", "patternProperties", "additionalProperties") WALK_MAYBE_DEPENDENT(HTTPS_BASE "2020-12/vocab/unevaluated", - "unevaluatedItems", ApplicatorValueTraverseAnyItem, + "unevaluatedProperties", + ApplicatorValueTraverseSomeProperty, + HTTPS_BASE "2020-12/vocab/applicator", "properties", + "patternProperties", "additionalProperties") + WALK_MAYBE_DEPENDENT(HTTPS_BASE "2020-12/vocab/unevaluated", + "unevaluatedItems", ApplicatorValueTraverseSomeItem, HTTPS_BASE "2020-12/vocab/applicator", "prefixItems", "items", "contains") WALK(HTTPS_BASE "2020-12/vocab/content", "contentSchema", @@ -145,16 +146,16 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTPS_BASE "2019-09/vocab/applicator", "patternProperties", ApplicatorMembersTraversePropertyRegex) WALK(HTTPS_BASE "2019-09/vocab/applicator", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties", "patternProperties") + ApplicatorValueTraverseSomeProperty, "properties", "patternProperties") WALK(HTTPS_BASE "2019-09/vocab/applicator", "propertyNames", ApplicatorValueTraverseAnyPropertyKey) WALK(HTTPS_BASE "2019-09/vocab/applicator", "dependentSchemas", - ApplicatorMembersInPlace) + ApplicatorMembersInPlaceSome) WALK(HTTPS_BASE "2019-09/vocab/applicator", "unevaluatedProperties", - ApplicatorValueTraverseAnyProperty, "properties", "patternProperties", + ApplicatorValueTraverseSomeProperty, "properties", "patternProperties", "additionalProperties") WALK(HTTPS_BASE "2019-09/vocab/applicator", "unevaluatedItems", - ApplicatorValueTraverseAnyItem, "items", "additionalItems") + ApplicatorValueTraverseSomeItem, "items", "additionalItems") WALK(HTTPS_BASE "2019-09/vocab/applicator", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem) WALK_MAYBE_DEPENDENT(HTTPS_BASE "2019-09/vocab/applicator", "contains", @@ -162,7 +163,7 @@ auto sourcemeta::core::schema_official_walker( HTTPS_BASE "2019-09/vocab/validation", "minContains", "maxContains") WALK(HTTPS_BASE "2019-09/vocab/applicator", "additionalItems", - ApplicatorValueTraverseAnyItem, "items") + ApplicatorValueTraverseSomeItem, "items") // For the purpose of compiler optimizations WALK_MAYBE_DEPENDENT(HTTPS_BASE "2019-09/vocab/validation", "type", Assertion, HTTPS_BASE "2019-09/vocab/applicator", "properties") @@ -244,7 +245,7 @@ auto sourcemeta::core::schema_official_walker( WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "additionalItems", ApplicatorValueTraverseAnyItem, "items") + "additionalItems", ApplicatorValueTraverseSomeItem, "items") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", "maxItems", Assertion, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", @@ -266,10 +267,10 @@ auto sourcemeta::core::schema_official_walker( WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", "patternProperties", ApplicatorMembersTraversePropertyRegex, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "additionalProperties", ApplicatorValueTraverseAnyProperty, + "additionalProperties", ApplicatorValueTraverseSomeProperty, "properties", "patternProperties") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "dependencies", ApplicatorMembersInPlace, "$ref") + "dependencies", ApplicatorMembersInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", "propertyNames", ApplicatorValueTraverseAnyPropertyKey, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", @@ -362,7 +363,7 @@ auto sourcemeta::core::schema_official_walker( WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", - "additionalItems", ApplicatorValueTraverseAnyItem, "items") + "additionalItems", ApplicatorValueTraverseSomeItem, "items") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", "maxItems", Assertion, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", @@ -384,10 +385,10 @@ auto sourcemeta::core::schema_official_walker( WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", "patternProperties", ApplicatorMembersTraversePropertyRegex, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", - "additionalProperties", ApplicatorValueTraverseAnyProperty, + "additionalProperties", ApplicatorValueTraverseSomeProperty, "properties", "patternProperties") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", - "dependencies", ApplicatorMembersInPlace, "$ref") + "dependencies", ApplicatorMembersInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", "propertyNames", ApplicatorValueTraverseAnyPropertyKey, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", @@ -467,7 +468,7 @@ auto sourcemeta::core::schema_official_walker( WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", - "additionalItems", ApplicatorValueTraverseAnyItem, "items") + "additionalItems", ApplicatorValueTraverseSomeItem, "items") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", "maxItems", Assertion, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", @@ -487,10 +488,10 @@ auto sourcemeta::core::schema_official_walker( WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", "patternProperties", ApplicatorMembersTraversePropertyRegex, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", - "additionalProperties", ApplicatorValueTraverseAnyProperty, + "additionalProperties", ApplicatorValueTraverseSomeProperty, "properties", "patternProperties") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", - "dependencies", ApplicatorMembersInPlace, "$ref") + "dependencies", ApplicatorMembersInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", "allOf", ApplicatorElementsInPlaceInline, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", @@ -538,17 +539,17 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-03/schema#", "patternProperties", ApplicatorMembersTraversePropertyRegex, "$ref") WALK(HTTP_BASE "draft-03/schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties", "patternProperties") + ApplicatorValueTraverseSomeProperty, "properties", "patternProperties") WALK(HTTP_BASE "draft-03/schema#", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem, "$ref") WALK(HTTP_BASE "draft-03/schema#", "additionalItems", - ApplicatorValueTraverseAnyItem, "items") + ApplicatorValueTraverseSomeItem, "items") WALK(HTTP_BASE "draft-03/schema#", "minItems", Assertion, "$ref") WALK(HTTP_BASE "draft-03/schema#", "maxItems", Assertion, "$ref") WALK(HTTP_BASE "draft-03/schema#", "uniqueItems", Assertion, "$ref") WALK(HTTP_BASE "draft-03/schema#", "required", Assertion, "$ref") - WALK(HTTP_BASE "draft-03/schema#", "dependencies", ApplicatorMembersInPlace, - "$ref") + WALK(HTTP_BASE "draft-03/schema#", "dependencies", + ApplicatorMembersInPlaceSome, "$ref") WALK(HTTP_BASE "draft-03/schema#", "enum", Assertion, "$ref") WALK(HTTP_BASE "draft-03/schema#", "pattern", Assertion, "$ref") WALK(HTTP_BASE "draft-03/schema#", "minLength", Assertion, "$ref") @@ -582,7 +583,7 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-02/schema#", "properties", ApplicatorMembersTraversePropertyStatic) WALK(HTTP_BASE "draft-02/schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") + ApplicatorValueTraverseSomeProperty, "properties") WALK(HTTP_BASE "draft-02/schema#", "type", ApplicatorElementsInPlace) WALK(HTTP_BASE "draft-02/schema#", "enum", Assertion) WALK(HTTP_BASE "draft-02/schema#", "maximum", Assertion) @@ -617,7 +618,7 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-02/hyper-schema#", "extends", ApplicatorValueOrElementsInPlace) WALK(HTTP_BASE "draft-02/hyper-schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") + ApplicatorValueTraverseSomeProperty, "properties") // Draft1 WALK(HTTP_BASE "draft-01/schema#", "$schema", Other) @@ -628,7 +629,7 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-01/schema#", "properties", ApplicatorMembersTraversePropertyStatic) WALK(HTTP_BASE "draft-01/schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") + ApplicatorValueTraverseSomeProperty, "properties") WALK(HTTP_BASE "draft-01/schema#", "type", ApplicatorElementsInPlace) WALK(HTTP_BASE "draft-01/schema#", "enum", Assertion) WALK(HTTP_BASE "draft-01/schema#", "maximum", Assertion) @@ -661,7 +662,7 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-01/hyper-schema#", "requires", ApplicatorValueTraverseParent) WALK(HTTP_BASE "draft-01/hyper-schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") + ApplicatorValueTraverseSomeProperty, "properties") // Draft0 WALK(HTTP_BASE "draft-00/schema#", "$schema", Other) @@ -672,7 +673,7 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-00/schema#", "properties", ApplicatorMembersTraversePropertyStatic) WALK(HTTP_BASE "draft-00/schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") + ApplicatorValueTraverseSomeProperty, "properties") WALK(HTTP_BASE "draft-00/schema#", "type", ApplicatorElementsInPlace) WALK(HTTP_BASE "draft-00/schema#", "enum", Assertion) WALK(HTTP_BASE "draft-00/schema#", "maximum", Assertion) @@ -705,7 +706,7 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-00/hyper-schema#", "requires", ApplicatorValueTraverseParent) WALK(HTTP_BASE "draft-00/hyper-schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") + ApplicatorValueTraverseSomeProperty, "properties") #undef HTTP_BASE #undef WALK #undef WALK_ANY diff --git a/src/core/jsonschema/walker.cc b/src/core/jsonschema/walker.cc index 160d4f0af..5bb1e575c 100644 --- a/src/core/jsonschema/walker.cc +++ b/src/core/jsonschema/walker.cc @@ -52,14 +52,17 @@ auto walk(const std::optional &parent, for (auto &pair : subschema.as_object()) { switch (walker(pair.first, vocabularies).type) { case sourcemeta::core::SchemaKeywordType:: - ApplicatorValueTraverseAnyProperty: { + ApplicatorValueTraverseSomeProperty: { sourcemeta::core::Pointer new_pointer{pointer}; new_pointer.emplace_back(pair.first); auto new_instance_location{instance_location}; + new_instance_location.emplace_back( + sourcemeta::core::PointerTemplate::Conditional{}); new_instance_location.emplace_back( sourcemeta::core::PointerTemplate::Wildcard::Property); walk(pointer, new_pointer, new_instance_location, - {sourcemeta::core::PointerTemplate::Wildcard::Property}, + {sourcemeta::core::PointerTemplate::Conditional{}, + sourcemeta::core::PointerTemplate::Wildcard::Property}, subschemas, pair.second, walker, resolver, new_dialect, type, level + 1, orphan); } break; @@ -90,6 +93,22 @@ auto walk(const std::optional &parent, orphan); } break; + case sourcemeta::core::SchemaKeywordType:: + ApplicatorValueTraverseSomeItem: { + sourcemeta::core::Pointer new_pointer{pointer}; + new_pointer.emplace_back(pair.first); + auto new_instance_location{instance_location}; + new_instance_location.emplace_back( + sourcemeta::core::PointerTemplate::Conditional{}); + new_instance_location.emplace_back( + sourcemeta::core::PointerTemplate::Wildcard::Item); + walk(pointer, new_pointer, new_instance_location, + {sourcemeta::core::PointerTemplate::Conditional{}, + sourcemeta::core::PointerTemplate::Wildcard::Item}, + subschemas, pair.second, walker, resolver, new_dialect, type, + level + 1, orphan); + } break; + case sourcemeta::core::SchemaKeywordType::ApplicatorValueTraverseParent: { sourcemeta::core::Pointer new_pointer{pointer}; new_pointer.emplace_back(pair.first); @@ -176,13 +195,17 @@ auto walk(const std::optional &parent, break; - case sourcemeta::core::SchemaKeywordType::ApplicatorMembersInPlace: + case sourcemeta::core::SchemaKeywordType::ApplicatorMembersInPlaceSome: if (pair.second.is_object()) { for (auto &subpair : pair.second.as_object()) { sourcemeta::core::Pointer new_pointer{pointer}; new_pointer.emplace_back(pair.first); new_pointer.emplace_back(subpair.first); - walk(pointer, new_pointer, instance_location, {}, subschemas, + auto new_instance_location{instance_location}; + new_instance_location.emplace_back( + sourcemeta::core::PointerTemplate::Conditional{}); + walk(pointer, new_pointer, new_instance_location, + {sourcemeta::core::PointerTemplate::Conditional{}}, subschemas, subpair.second, walker, resolver, new_dialect, type, level + 1, orphan); } diff --git a/test/jsonschema/jsonschema_official_walker_2019_09_test.cc b/test/jsonschema/jsonschema_official_walker_2019_09_test.cc index c4bcdf742..c2afcf098 100644 --- a/test/jsonschema/jsonschema_official_walker_2019_09_test.cc +++ b/test/jsonschema/jsonschema_official_walker_2019_09_test.cc @@ -211,7 +211,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_dependentSchemas) { using namespace sourcemeta::core; const auto result{schema_official_walker("dependentSchemas", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -299,7 +299,8 @@ TEST(JSONSchema_official_walker_2019_09, applicator_additionalProperties) { using namespace sourcemeta::core; const auto result{schema_official_walker("additionalProperties", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -335,7 +336,8 @@ TEST(JSONSchema_official_walker_2019_09, applicator_unevaluatedProperties) { using namespace sourcemeta::core; const auto result{schema_official_walker("unevaluatedProperties", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); diff --git a/test/jsonschema/jsonschema_official_walker_2020_12_test.cc b/test/jsonschema/jsonschema_official_walker_2020_12_test.cc index 3b77905db..35a687b89 100644 --- a/test/jsonschema/jsonschema_official_walker_2020_12_test.cc +++ b/test/jsonschema/jsonschema_official_walker_2020_12_test.cc @@ -219,7 +219,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_dependentSchemas) { using namespace sourcemeta::core; const auto result{schema_official_walker("dependentSchemas", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -306,7 +306,8 @@ TEST(JSONSchema_official_walker_2020_12, applicator_additionalProperties) { using namespace sourcemeta::core; const auto result{schema_official_walker("additionalProperties", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -361,7 +362,8 @@ TEST(JSONSchema_official_walker_2020_12, using namespace sourcemeta::core; const auto result{schema_official_walker("unevaluatedProperties", VOCABULARIES_2020_12_UNEVALUATED)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/unevaluated"); @@ -380,7 +382,8 @@ TEST(JSONSchema_official_walker_2020_12, std::inserter(vocabularies, vocabularies.end())); const auto result{ schema_official_walker("unevaluatedProperties", vocabularies)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/unevaluated"); diff --git a/test/jsonschema/jsonschema_official_walker_draft0_test.cc b/test/jsonschema/jsonschema_official_walker_draft0_test.cc index 3e54993ff..a8d8c6032 100644 --- a/test/jsonschema/jsonschema_official_walker_draft0_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft0_test.cc @@ -65,7 +65,8 @@ TEST(JSONSchema_official_walker_draft0, additionalProperties) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalProperties", VOCABULARIES_DRAFT0)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-00/schema#"); @@ -440,7 +441,8 @@ TEST(JSONSchema_official_walker_draft0, hyperschema_additionalProperties) { using namespace sourcemeta::core; const auto result{schema_official_walker("additionalProperties", VOCABULARIES_DRAFT0_HYPERSCHEMA)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-00/hyper-schema#"); @@ -792,7 +794,7 @@ TEST(JSONSchema_official_walker_draft0, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 3, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 4, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); // Applicators (array) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 5, "/items", "", "/~I~", "/~I~"); diff --git a/test/jsonschema/jsonschema_official_walker_draft1_test.cc b/test/jsonschema/jsonschema_official_walker_draft1_test.cc index 121ae8bd8..ce9f4ae4b 100644 --- a/test/jsonschema/jsonschema_official_walker_draft1_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft1_test.cc @@ -65,7 +65,8 @@ TEST(JSONSchema_official_walker_draft1, additionalProperties) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalProperties", VOCABULARIES_DRAFT1)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-01/schema#"); @@ -440,7 +441,8 @@ TEST(JSONSchema_official_walker_draft1, hyperschema_additionalProperties) { using namespace sourcemeta::core; const auto result{schema_official_walker("additionalProperties", VOCABULARIES_DRAFT1_HYPERSCHEMA)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-01/hyper-schema#"); @@ -792,7 +794,7 @@ TEST(JSONSchema_official_walker_draft1, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 3, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 4, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); // Applicators (array) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 5, "/items", "", "/~I~", "/~I~"); diff --git a/test/jsonschema/jsonschema_official_walker_draft2_test.cc b/test/jsonschema/jsonschema_official_walker_draft2_test.cc index 0c18845b3..3f6276cb1 100644 --- a/test/jsonschema/jsonschema_official_walker_draft2_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft2_test.cc @@ -65,7 +65,8 @@ TEST(JSONSchema_official_walker_draft2, additionalProperties) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalProperties", VOCABULARIES_DRAFT2)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-02/schema#"); @@ -459,7 +460,8 @@ TEST(JSONSchema_official_walker_draft2, hyperschema_additionalProperties) { using namespace sourcemeta::core; const auto result{schema_official_walker("additionalProperties", VOCABULARIES_DRAFT2_HYPERSCHEMA)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-02/hyper-schema#"); @@ -813,7 +815,7 @@ TEST(JSONSchema_official_walker_draft2, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 3, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 4, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); // Applicators (array) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 5, "/items", "", "/~I~", "/~I~"); diff --git a/test/jsonschema/jsonschema_official_walker_draft3_test.cc b/test/jsonschema/jsonschema_official_walker_draft3_test.cc index e2504bb71..3263e26f1 100644 --- a/test/jsonschema/jsonschema_official_walker_draft3_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft3_test.cc @@ -94,7 +94,7 @@ TEST(JSONSchema_official_walker_draft3, dependencies) { using namespace sourcemeta::core; const auto result{ schema_official_walker("dependencies", VOCABULARIES_DRAFT3)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-03/schema#"); @@ -106,7 +106,8 @@ TEST(JSONSchema_official_walker_draft3, additionalProperties) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalProperties", VOCABULARIES_DRAFT3)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-03/schema#"); @@ -653,17 +654,17 @@ TEST(JSONSchema_official_walker_draft3, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 2, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 3, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 4, "/patternProperties/^f", "", "/~R^f~", "/~R^f~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 5, "/patternProperties/x$", "", "/~Rx$~", "/~Rx$~"); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 6, "/dependencies/baz", "", "", - ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 6, "/dependencies/baz", "", + "/~?~", "/~?~"); // Applicators (array) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 7, "/additionalItems", "", - "/~I~", "/~I~"); + "/~?~/~I~", "/~?~/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 8, "/items", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 9, "/items/items/0", "/items", "/~I~/0", "/0"); diff --git a/test/jsonschema/jsonschema_official_walker_draft4_test.cc b/test/jsonschema/jsonschema_official_walker_draft4_test.cc index 36e9bbb15..be66ab002 100644 --- a/test/jsonschema/jsonschema_official_walker_draft4_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft4_test.cc @@ -149,7 +149,7 @@ TEST(JSONSchema_official_walker_draft4, dependencies) { using namespace sourcemeta::core; const auto result{ schema_official_walker("dependencies", VOCABULARIES_DRAFT4)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-04/schema#"); @@ -161,7 +161,8 @@ TEST(JSONSchema_official_walker_draft4, additionalProperties) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalProperties", VOCABULARIES_DRAFT4)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-04/schema#"); diff --git a/test/jsonschema/jsonschema_official_walker_draft6_test.cc b/test/jsonschema/jsonschema_official_walker_draft6_test.cc index 6f9bf9a71..fb366534a 100644 --- a/test/jsonschema/jsonschema_official_walker_draft6_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft6_test.cc @@ -160,7 +160,7 @@ TEST(JSONSchema_official_walker_draft6, dependencies) { using namespace sourcemeta::core; const auto result{ schema_official_walker("dependencies", VOCABULARIES_DRAFT6)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-06/schema#"); @@ -172,7 +172,8 @@ TEST(JSONSchema_official_walker_draft6, additionalProperties) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalProperties", VOCABULARIES_DRAFT6)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-06/schema#"); diff --git a/test/jsonschema/jsonschema_official_walker_draft7_test.cc b/test/jsonschema/jsonschema_official_walker_draft7_test.cc index e19362681..4372575aa 100644 --- a/test/jsonschema/jsonschema_official_walker_draft7_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft7_test.cc @@ -204,7 +204,7 @@ TEST(JSONSchema_official_walker_draft7, dependencies) { using namespace sourcemeta::core; const auto result{ schema_official_walker("dependencies", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorMembersInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -216,7 +216,8 @@ TEST(JSONSchema_official_walker_draft7, additionalProperties) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalProperties", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyProperty); + EXPECT_EQ(result.type, + SchemaKeywordType::ApplicatorValueTraverseSomeProperty); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); diff --git a/test/jsonschema/jsonschema_walker_test.cc b/test/jsonschema/jsonschema_walker_test.cc index f88f6a394..49f00b121 100644 --- a/test/jsonschema/jsonschema_walker_test.cc +++ b/test/jsonschema/jsonschema_walker_test.cc @@ -38,7 +38,7 @@ static auto test_walker(std::string_view keyword, vocabularies.end()) { if (keyword == "schema") { return {sourcemeta::core::SchemaKeywordType:: - ApplicatorValueTraverseAnyProperty, + ApplicatorValueTraverseSomeProperty, "https://sourcemeta.com/vocab/test-1", {}}; } @@ -69,7 +69,7 @@ static auto test_walker(std::string_view keyword, vocabularies.end()) { if (keyword == "custom") { return {sourcemeta::core::SchemaKeywordType:: - ApplicatorValueTraverseAnyProperty, + ApplicatorValueTraverseSomeProperty, "https://sourcemeta.com/vocab/test-2", {}}; }