From 2f9a11e93f8d0e651cf98f475e448ec0b4bd4bc3 Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Wed, 12 Feb 2025 15:19:28 -0400 Subject: [PATCH] Extend schema walker to account for conditional instance locations Signed-off-by: Juan Cruz Viotti --- src/core/jsonschema/frame.cc | 8 +- .../sourcemeta/core/jsonschema_types.h | 28 ++-- src/core/jsonschema/official_walker.cc | 141 +++++++++--------- src/core/jsonschema/walker.cc | 67 +++++++-- .../jsonschema_frame_2019_09_test.cc | 79 +++++----- .../jsonschema_frame_2020_12_test.cc | 58 +++---- .../jsonschema_frame_draft0_test.cc | 4 +- .../jsonschema_frame_draft1_test.cc | 4 +- .../jsonschema_frame_draft2_test.cc | 4 +- .../jsonschema_frame_draft3_test.cc | 4 +- .../jsonschema_frame_draft4_test.cc | 4 +- .../jsonschema_frame_draft6_test.cc | 4 +- .../jsonschema_frame_draft7_test.cc | 4 +- test/jsonschema/jsonschema_frame_test.cc | 20 +-- ...jsonschema_official_walker_2019_09_test.cc | 50 ++++--- ...jsonschema_official_walker_2020_12_test.cc | 63 ++++---- .../jsonschema_official_walker_draft0_test.cc | 18 ++- .../jsonschema_official_walker_draft1_test.cc | 18 ++- .../jsonschema_official_walker_draft2_test.cc | 18 ++- .../jsonschema_official_walker_draft3_test.cc | 31 ++-- .../jsonschema_official_walker_draft4_test.cc | 29 ++-- .../jsonschema_official_walker_draft6_test.cc | 29 ++-- .../jsonschema_official_walker_draft7_test.cc | 41 ++--- test/jsonschema/jsonschema_walker_test.cc | 4 +- 24 files changed, 416 insertions(+), 314 deletions(-) diff --git a/src/core/jsonschema/frame.cc b/src/core/jsonschema/frame.cc index cd307ec6d..06a60d165 100644 --- a/src/core/jsonschema/frame.cc +++ b/src/core/jsonschema/frame.cc @@ -1037,7 +1037,7 @@ auto find_adjacent_dependencies( } // Static - case SchemaKeywordType::ApplicatorElementsInPlaceInline: + case SchemaKeywordType::ApplicatorElementsInPlace: for (std::size_t index = 0; index < property.second.size(); index++) { find_adjacent_dependencies( current, schema, frame, walker, resolver, keywords, root, @@ -1048,7 +1048,7 @@ auto find_adjacent_dependencies( break; // Dynamic - case SchemaKeywordType::ApplicatorElementsInPlace: + case SchemaKeywordType::ApplicatorElementsInPlaceSome: if (property.second.is_array()) { for (std::size_t index = 0; index < property.second.size(); index++) { find_adjacent_dependencies( @@ -1062,7 +1062,7 @@ auto find_adjacent_dependencies( [[fallthrough]]; case SchemaKeywordType::ApplicatorValueTraverseParent: [[fallthrough]]; - case SchemaKeywordType::ApplicatorValueInPlace: + case SchemaKeywordType::ApplicatorValueInPlaceMaybe: if (is_schema(property.second)) { find_adjacent_dependencies( current, schema, frame, walker, resolver, keywords, root, @@ -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..b2e7e43e8 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,23 +124,23 @@ 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 + /// as an argument without affecting the instance location. /// The instance does not traverse ApplicatorElementsInPlace, /// 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 + /// The instance does not traverse, and only some of the + /// elements apply. + ApplicatorElementsInPlaceSome, + /// The JSON Schema keyword is an applicator that potentially /// takes a JSON Schema definition as an argument without affecting the /// instance location. - /// The instance does not traverse - ApplicatorValueInPlace, - /// 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 and that can be - /// statically inlined. - /// The instance does not traverse - ApplicatorElementsInPlaceInline, + /// The instance does not traverse, and only applies some of the times. + ApplicatorValueInPlaceMaybe, /// The JSON Schema keyword is an applicator that potentially /// takes a JSON Schema definition as an argument but its evaluation follows /// special rules. diff --git a/src/core/jsonschema/official_walker.cc b/src/core/jsonschema/official_walker.cc index 556476601..d6469d7ec 100644 --- a/src/core/jsonschema/official_walker.cc +++ b/src/core/jsonschema/official_walker.cc @@ -36,16 +36,16 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTPS_BASE "2020-12/vocab/core", "$dynamicRef", Reference) WALK(HTTPS_BASE "2020-12/vocab/core", "$dynamicAnchor", Other) WALK(HTTPS_BASE "2020-12/vocab/applicator", "oneOf", - ApplicatorElementsInPlace) + ApplicatorElementsInPlaceSome) WALK(HTTPS_BASE "2020-12/vocab/applicator", "anyOf", - ApplicatorElementsInPlace) + ApplicatorElementsInPlaceSome) WALK(HTTPS_BASE "2020-12/vocab/applicator", "allOf", - ApplicatorElementsInPlaceInline) - WALK(HTTPS_BASE "2020-12/vocab/applicator", "if", ApplicatorValueInPlace) - WALK(HTTPS_BASE "2020-12/vocab/applicator", "then", ApplicatorValueInPlace, - "if") - WALK(HTTPS_BASE "2020-12/vocab/applicator", "else", ApplicatorValueInPlace, - "if") + ApplicatorElementsInPlace) + WALK(HTTPS_BASE "2020-12/vocab/applicator", "if", ApplicatorValueInPlaceMaybe) + WALK(HTTPS_BASE "2020-12/vocab/applicator", "then", + ApplicatorValueInPlaceMaybe, "if") + WALK(HTTPS_BASE "2020-12/vocab/applicator", "else", + ApplicatorValueInPlaceMaybe, "if") WALK(HTTPS_BASE "2020-12/vocab/applicator", "not", ApplicatorValueInPlaceOther) // For the purpose of compiler optimizations @@ -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", @@ -126,16 +127,16 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTPS_BASE "2019-09/vocab/core", "$recursiveRef", Reference) WALK(HTTPS_BASE "2019-09/vocab/core", "$recursiveAnchor", Other) WALK(HTTPS_BASE "2019-09/vocab/applicator", "allOf", - ApplicatorElementsInPlaceInline) - WALK(HTTPS_BASE "2019-09/vocab/applicator", "anyOf", ApplicatorElementsInPlace) + WALK(HTTPS_BASE "2019-09/vocab/applicator", "anyOf", + ApplicatorElementsInPlaceSome) WALK(HTTPS_BASE "2019-09/vocab/applicator", "oneOf", - ApplicatorElementsInPlace) - WALK(HTTPS_BASE "2019-09/vocab/applicator", "if", ApplicatorValueInPlace) - WALK(HTTPS_BASE "2019-09/vocab/applicator", "then", ApplicatorValueInPlace, - "if") - WALK(HTTPS_BASE "2019-09/vocab/applicator", "else", ApplicatorValueInPlace, - "if") + ApplicatorElementsInPlaceSome) + WALK(HTTPS_BASE "2019-09/vocab/applicator", "if", ApplicatorValueInPlaceMaybe) + WALK(HTTPS_BASE "2019-09/vocab/applicator", "then", + ApplicatorValueInPlaceMaybe, "if") + WALK(HTTPS_BASE "2019-09/vocab/applicator", "else", + ApplicatorValueInPlaceMaybe, "if") WALK(HTTPS_BASE "2019-09/vocab/applicator", "not", ApplicatorValueInPlaceOther) // For the purpose of compiler optimizations @@ -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,24 +267,24 @@ 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#", - "if", ApplicatorValueInPlace, "$ref") + "if", ApplicatorValueInPlaceMaybe, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "then", ApplicatorValueInPlace, "if") + "then", ApplicatorValueInPlaceMaybe, "if") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "else", ApplicatorValueInPlace, "if") + "else", ApplicatorValueInPlaceMaybe, "if") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "allOf", ApplicatorElementsInPlaceInline, "$ref") + "allOf", ApplicatorElementsInPlace, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "anyOf", ApplicatorElementsInPlace, "$ref") + "anyOf", ApplicatorElementsInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", - "oneOf", ApplicatorElementsInPlace, "$ref") + "oneOf", ApplicatorElementsInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-07/schema#", HTTP_BASE "draft-07/hyper-schema#", "not", ApplicatorValueInPlaceOther, "$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,18 +385,18 @@ 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#", - "allOf", ApplicatorElementsInPlaceInline, "$ref") + "allOf", ApplicatorElementsInPlace, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", - "anyOf", ApplicatorElementsInPlace, "$ref") + "anyOf", ApplicatorElementsInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", - "oneOf", ApplicatorElementsInPlace, "$ref") + "oneOf", ApplicatorElementsInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-06/schema#", HTTP_BASE "draft-06/hyper-schema#", "not", ApplicatorValueInPlaceOther, "$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,16 +488,16 @@ 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") + "allOf", ApplicatorElementsInPlace, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", - "anyOf", ApplicatorElementsInPlace, "$ref") + "anyOf", ApplicatorElementsInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", - "oneOf", ApplicatorElementsInPlace, "$ref") + "oneOf", ApplicatorElementsInPlaceSome, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", "not", ApplicatorValueInPlaceOther, "$ref") WALK_ANY(HTTP_BASE "draft-04/schema#", HTTP_BASE "draft-04/hyper-schema#", @@ -530,25 +531,26 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-03/schema#", "$ref", Reference) WALK(HTTP_BASE "draft-03/schema#", "extends", ApplicatorValueOrElementsInPlace, "$ref") - WALK(HTTP_BASE "draft-03/schema#", "type", ApplicatorElementsInPlace, "$ref") - WALK(HTTP_BASE "draft-03/schema#", "disallow", ApplicatorElementsInPlace, + WALK(HTTP_BASE "draft-03/schema#", "type", ApplicatorElementsInPlaceSome, + "$ref") + WALK(HTTP_BASE "draft-03/schema#", "disallow", ApplicatorElementsInPlaceSome, "$ref") WALK(HTTP_BASE "draft-03/schema#", "properties", ApplicatorMembersTraversePropertyStatic, "$ref") 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,8 +584,8 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-02/schema#", "properties", ApplicatorMembersTraversePropertyStatic) WALK(HTTP_BASE "draft-02/schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") - WALK(HTTP_BASE "draft-02/schema#", "type", ApplicatorElementsInPlace) + ApplicatorValueTraverseSomeProperty, "properties") + WALK(HTTP_BASE "draft-02/schema#", "type", ApplicatorElementsInPlaceSome) WALK(HTTP_BASE "draft-02/schema#", "enum", Assertion) WALK(HTTP_BASE "draft-02/schema#", "maximum", Assertion) WALK(HTTP_BASE "draft-02/schema#", "minimum", Assertion) @@ -609,7 +611,8 @@ auto sourcemeta::core::schema_official_walker( ApplicatorValueTraverseParent) WALK(HTTP_BASE "draft-02/hyper-schema#", "targetSchema", ApplicatorValueInPlaceOther) - WALK(HTTP_BASE "draft-02/hyper-schema#", "type", ApplicatorElementsInPlace) + WALK(HTTP_BASE "draft-02/hyper-schema#", "type", + ApplicatorElementsInPlaceSome) WALK(HTTP_BASE "draft-02/hyper-schema#", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem) WALK(HTTP_BASE "draft-02/hyper-schema#", "properties", @@ -617,7 +620,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,8 +631,8 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-01/schema#", "properties", ApplicatorMembersTraversePropertyStatic) WALK(HTTP_BASE "draft-01/schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") - WALK(HTTP_BASE "draft-01/schema#", "type", ApplicatorElementsInPlace) + ApplicatorValueTraverseSomeProperty, "properties") + WALK(HTTP_BASE "draft-01/schema#", "type", ApplicatorElementsInPlaceSome) WALK(HTTP_BASE "draft-01/schema#", "enum", Assertion) WALK(HTTP_BASE "draft-01/schema#", "maximum", Assertion) WALK(HTTP_BASE "draft-01/schema#", "minimum", Assertion) @@ -651,7 +654,8 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-01/schema#", "contentEncoding", Comment) WALK(HTTP_BASE "draft-01/schema#", "optional", Assertion) WALK(HTTP_BASE "draft-01/schema#", "maxDecimal", Assertion) - WALK(HTTP_BASE "draft-01/hyper-schema#", "type", ApplicatorElementsInPlace) + WALK(HTTP_BASE "draft-01/hyper-schema#", "type", + ApplicatorElementsInPlaceSome) WALK(HTTP_BASE "draft-01/hyper-schema#", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem) WALK(HTTP_BASE "draft-01/hyper-schema#", "properties", @@ -661,7 +665,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,8 +676,8 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-00/schema#", "properties", ApplicatorMembersTraversePropertyStatic) WALK(HTTP_BASE "draft-00/schema#", "additionalProperties", - ApplicatorValueTraverseAnyProperty, "properties") - WALK(HTTP_BASE "draft-00/schema#", "type", ApplicatorElementsInPlace) + ApplicatorValueTraverseSomeProperty, "properties") + WALK(HTTP_BASE "draft-00/schema#", "type", ApplicatorElementsInPlaceSome) WALK(HTTP_BASE "draft-00/schema#", "enum", Assertion) WALK(HTTP_BASE "draft-00/schema#", "maximum", Assertion) WALK(HTTP_BASE "draft-00/schema#", "minimum", Assertion) @@ -695,7 +699,8 @@ auto sourcemeta::core::schema_official_walker( WALK(HTTP_BASE "draft-00/schema#", "contentEncoding", Comment) WALK(HTTP_BASE "draft-00/schema#", "optional", Assertion) WALK(HTTP_BASE "draft-00/schema#", "maxDecimal", Assertion) - WALK(HTTP_BASE "draft-00/hyper-schema#", "type", ApplicatorElementsInPlace) + WALK(HTTP_BASE "draft-00/hyper-schema#", "type", + ApplicatorElementsInPlaceSome) WALK(HTTP_BASE "draft-00/hyper-schema#", "items", ApplicatorValueOrElementsTraverseAnyItemOrItem) WALK(HTTP_BASE "draft-00/hyper-schema#", "properties", @@ -705,7 +710,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..8f54c8d0c 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); @@ -100,9 +119,7 @@ auto walk(const std::optional &parent, orphan); } break; - case sourcemeta::core::SchemaKeywordType::ApplicatorValueInPlaceOther: - [[fallthrough]]; - case sourcemeta::core::SchemaKeywordType::ApplicatorValueInPlace: { + case sourcemeta::core::SchemaKeywordType::ApplicatorValueInPlaceOther: { sourcemeta::core::Pointer new_pointer{pointer}; new_pointer.emplace_back(pair.first); walk(pointer, new_pointer, instance_location, {}, subschemas, @@ -110,6 +127,18 @@ auto walk(const std::optional &parent, orphan); } break; + case sourcemeta::core::SchemaKeywordType::ApplicatorValueInPlaceMaybe: { + 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{}); + walk(pointer, new_pointer, new_instance_location, + {sourcemeta::core::PointerTemplate::Conditional{}}, subschemas, + pair.second, walker, resolver, new_dialect, type, level + 1, + orphan); + } break; + case sourcemeta::core::SchemaKeywordType::ApplicatorElementsTraverseItem: if (pair.second.is_array()) { for (std::size_t index = 0; index < pair.second.size(); index++) { @@ -126,8 +155,6 @@ auto walk(const std::optional &parent, break; - case sourcemeta::core::SchemaKeywordType::ApplicatorElementsInPlaceInline: - [[fallthrough]]; case sourcemeta::core::SchemaKeywordType::ApplicatorElementsInPlace: if (pair.second.is_array()) { for (std::size_t index = 0; index < pair.second.size(); index++) { @@ -142,6 +169,24 @@ auto walk(const std::optional &parent, break; + case sourcemeta::core::SchemaKeywordType::ApplicatorElementsInPlaceSome: + if (pair.second.is_array()) { + for (std::size_t index = 0; index < pair.second.size(); index++) { + sourcemeta::core::Pointer new_pointer{pointer}; + new_pointer.emplace_back(pair.first); + new_pointer.emplace_back(index); + 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, + pair.second.at(index), walker, resolver, new_dialect, type, + level + 1, orphan); + } + } + + break; + case sourcemeta::core::SchemaKeywordType:: ApplicatorMembersTraversePropertyStatic: if (pair.second.is_object()) { @@ -176,13 +221,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_frame_2019_09_test.cc b/test/jsonschema/jsonschema_frame_2019_09_test.cc index 464ecb324..4452a09a3 100644 --- a/test/jsonschema/jsonschema_frame_2019_09_test.cc +++ b/test/jsonschema/jsonschema_frame_2019_09_test.cc @@ -68,7 +68,7 @@ TEST(JSONSchema_frame_2019_09, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~P~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~P~"}, ""); // JSON Pointers @@ -87,7 +87,7 @@ TEST(JSONSchema_frame_2019_09, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~P~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/$id", "/additionalProperties/$id", "https://json-schema.org/draft/2019-09/schema", @@ -1105,7 +1105,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_no_recursive_anchor_anonymous) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "", "", "https://json-schema.org/draft/2019-09/schema", "https://json-schema.org/draft/2019-09/schema", - POINTER_TEMPLATES("", "/~I~"), std::nullopt); + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/$schema", "/$schema", "https://json-schema.org/draft/2019-09/schema", @@ -1113,7 +1113,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_no_recursive_anchor_anonymous) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalItems", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalItems/$recursiveRef", "/additionalItems/$recursiveRef", @@ -1150,8 +1150,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_no_recursive_anchor) { EXPECT_FRAME_STATIC_2019_09_RESOURCE( frame, "https://www.sourcemeta.com/schema", "https://www.sourcemeta.com/schema", "", - "https://www.sourcemeta.com/schema", "", POINTER_TEMPLATES("", "/~I~"), - std::nullopt); + "https://www.sourcemeta.com/schema", "", + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/$id", @@ -1164,7 +1164,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_no_recursive_anchor) { EXPECT_FRAME_STATIC_2019_09_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/additionalItems", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/schema", "/additionalItems", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/additionalItems", {"/~?~/~I~"}, + ""); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/additionalItems/$recursiveRef", "https://www.sourcemeta.com/schema", "/additionalItems/$recursiveRef", @@ -1202,7 +1203,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_false_anonymous) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "", "", "https://json-schema.org/draft/2019-09/schema", "https://json-schema.org/draft/2019-09/schema", - POINTER_TEMPLATES("", "/~I~"), std::nullopt); + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/$schema", "/$schema", "https://json-schema.org/draft/2019-09/schema", @@ -1214,7 +1215,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_false_anonymous) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalItems", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalItems/$recursiveRef", "/additionalItems/$recursiveRef", @@ -1252,8 +1253,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_false) { EXPECT_FRAME_STATIC_2019_09_RESOURCE( frame, "https://www.sourcemeta.com/schema", "https://www.sourcemeta.com/schema", "", - "https://www.sourcemeta.com/schema", "", POINTER_TEMPLATES("", "/~I~"), - std::nullopt); + "https://www.sourcemeta.com/schema", "", + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/$id", @@ -1270,7 +1271,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_false) { EXPECT_FRAME_STATIC_2019_09_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/additionalItems", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/schema", "/additionalItems", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/additionalItems", {"/~?~/~I~"}, + ""); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/additionalItems/$recursiveRef", "https://www.sourcemeta.com/schema", "/additionalItems/$recursiveRef", @@ -1308,7 +1310,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_true_anonymous) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "", "", "https://json-schema.org/draft/2019-09/schema", "https://json-schema.org/draft/2019-09/schema", - POINTER_TEMPLATES("", "/~I~"), std::nullopt); + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/$schema", "/$schema", "https://json-schema.org/draft/2019-09/schema", @@ -1320,7 +1322,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_true_anonymous) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalItems", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalItems/$recursiveRef", "/additionalItems/$recursiveRef", @@ -1332,7 +1334,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_true_anonymous) { EXPECT_ANONYMOUS_FRAME_DYNAMIC_ANCHOR( frame, "", "", "https://json-schema.org/draft/2019-09/schema", "https://json-schema.org/draft/2019-09/schema", - POINTER_TEMPLATES("", "/~I~"), std::nullopt); + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); // References @@ -1365,8 +1367,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_true) { EXPECT_FRAME_STATIC_2019_09_RESOURCE( frame, "https://www.sourcemeta.com/schema", "https://www.sourcemeta.com/schema", "", - "https://www.sourcemeta.com/schema", "", POINTER_TEMPLATES("", "/~I~"), - std::nullopt); + "https://www.sourcemeta.com/schema", "", + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/$id", @@ -1383,7 +1385,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_true) { EXPECT_FRAME_STATIC_2019_09_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/additionalItems", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/schema", "/additionalItems", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/additionalItems", {"/~?~/~I~"}, + ""); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/additionalItems/$recursiveRef", "https://www.sourcemeta.com/schema", "/additionalItems/$recursiveRef", @@ -1395,8 +1398,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_recursive_anchor_true) { EXPECT_FRAME_DYNAMIC_2019_09_ANCHOR( frame, "https://www.sourcemeta.com/schema", "https://www.sourcemeta.com/schema", "", - "https://www.sourcemeta.com/schema", "", POINTER_TEMPLATES("", "/~I~"), - std::nullopt); + "https://www.sourcemeta.com/schema", "", + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); // References @@ -1431,7 +1434,7 @@ TEST(JSONSchema_frame_2019_09, EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "", "", "https://json-schema.org/draft/2019-09/schema", @@ -1443,7 +1446,7 @@ TEST(JSONSchema_frame_2019_09, EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalItems", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalItems/$id", "/additionalItems/$id", "https://json-schema.org/draft/2019-09/schema", @@ -1507,7 +1510,7 @@ TEST(JSONSchema_frame_2019_09, EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "", "", "https://json-schema.org/draft/2019-09/schema", @@ -1519,7 +1522,7 @@ TEST(JSONSchema_frame_2019_09, EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalItems", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalItems/$id", "/additionalItems/$id", "https://json-schema.org/draft/2019-09/schema", @@ -1555,7 +1558,7 @@ TEST(JSONSchema_frame_2019_09, EXPECT_ANONYMOUS_FRAME_DYNAMIC_ANCHOR( frame, "https://example.com", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); // References @@ -1608,7 +1611,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_nested_recursive_anchor_true) { EXPECT_FRAME_STATIC_2019_09_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/additionalItems", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/schema", "/additionalItems", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/additionalItems", {"/~?~/~I~"}, + ""); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/additionalItems/$recursiveRef", "https://www.sourcemeta.com/schema", "/additionalItems/$recursiveRef", @@ -1620,7 +1624,8 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_nested_recursive_anchor_true) { EXPECT_FRAME_DYNAMIC_2019_09_ANCHOR( frame, "https://www.sourcemeta.com/schema", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/schema", "/additionalItems", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/additionalItems", {"/~?~/~I~"}, + ""); // References @@ -1656,12 +1661,12 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_multiple_recursive_anchor_true) { EXPECT_FRAME_STATIC_2019_09_RESOURCE( frame, "https://www.sourcemeta.com/schema", "https://www.sourcemeta.com/schema", "", - "https://www.sourcemeta.com/schema", "", POINTER_TEMPLATES("", "/~I~"), - std::nullopt); + "https://www.sourcemeta.com/schema", "", + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_FRAME_STATIC_2019_09_RESOURCE( frame, "https://www.sourcemeta.com/nested", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/nested", "", {"/~I~"}, ""); + "https://www.sourcemeta.com/nested", "", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/$id", @@ -1678,7 +1683,7 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_multiple_recursive_anchor_true) { EXPECT_FRAME_STATIC_2019_09_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/additionalItems", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/nested", "", {"/~I~"}, ""); + "https://www.sourcemeta.com/nested", "", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2019_09_POINTER( frame, "https://www.sourcemeta.com/schema#/additionalItems/$id", "https://www.sourcemeta.com/schema", "/additionalItems/$id", @@ -1715,12 +1720,12 @@ TEST(JSONSchema_frame_2019_09, recursive_ref_multiple_recursive_anchor_true) { EXPECT_FRAME_DYNAMIC_2019_09_ANCHOR( frame, "https://www.sourcemeta.com/schema", "https://www.sourcemeta.com/schema", "", - "https://www.sourcemeta.com/schema", "", POINTER_TEMPLATES("", "/~I~"), - std::nullopt); + "https://www.sourcemeta.com/schema", "", + POINTER_TEMPLATES("", "/~?~/~I~"), std::nullopt); EXPECT_FRAME_DYNAMIC_2019_09_ANCHOR( frame, "https://www.sourcemeta.com/nested", "https://www.sourcemeta.com/schema", "/additionalItems", - "https://www.sourcemeta.com/nested", "", {"/~I~"}, ""); + "https://www.sourcemeta.com/nested", "", {"/~?~/~I~"}, ""); // References @@ -1788,7 +1793,7 @@ TEST(JSONSchema_frame_2019_09, recursive_anchor_on_relative_id) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "middle", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); // JSON Pointers @@ -1807,7 +1812,7 @@ TEST(JSONSchema_frame_2019_09, recursive_anchor_on_relative_id) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalItems", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalItems/$id", "/additionalItems/$id", "https://json-schema.org/draft/2019-09/schema", @@ -1830,7 +1835,7 @@ TEST(JSONSchema_frame_2019_09, recursive_anchor_on_relative_id) { EXPECT_ANONYMOUS_FRAME_DYNAMIC_ANCHOR( frame, "middle", "/additionalItems", "https://json-schema.org/draft/2019-09/schema", - "https://json-schema.org/draft/2019-09/schema", {"/~I~"}, ""); + "https://json-schema.org/draft/2019-09/schema", {"/~?~/~I~"}, ""); // References diff --git a/test/jsonschema/jsonschema_frame_2020_12_test.cc b/test/jsonschema/jsonschema_frame_2020_12_test.cc index a80e679a3..66c35a15c 100644 --- a/test/jsonschema/jsonschema_frame_2020_12_test.cc +++ b/test/jsonschema/jsonschema_frame_2020_12_test.cc @@ -68,7 +68,7 @@ TEST(JSONSchema_frame_2020_12, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "https://json-schema.org/draft/2020-12/schema", - "https://json-schema.org/draft/2020-12/schema", {"/~P~"}, ""); + "https://json-schema.org/draft/2020-12/schema", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "https://example.com#/$id", "/additionalProperties/$id", "https://json-schema.org/draft/2020-12/schema", @@ -87,7 +87,7 @@ TEST(JSONSchema_frame_2020_12, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "https://json-schema.org/draft/2020-12/schema", - "https://json-schema.org/draft/2020-12/schema", {"/~P~"}, ""); + "https://json-schema.org/draft/2020-12/schema", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/$id", "/additionalProperties/$id", "https://json-schema.org/draft/2020-12/schema", @@ -211,7 +211,7 @@ TEST(JSONSchema_frame_2020_12, one_level_applicators_without_identifiers) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/items", "https://www.sourcemeta.com/schema", "/items", - "https://www.sourcemeta.com/schema", "/items", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/items", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/items/type", "https://www.sourcemeta.com/schema", "/items/type", @@ -262,7 +262,7 @@ TEST(JSONSchema_frame_2020_12, one_level_applicators_with_identifiers) { EXPECT_FRAME_STATIC_2020_12_RESOURCE( frame, "https://www.sourcemeta.com/foo", "https://www.sourcemeta.com/test/qux", "/items", - "https://www.sourcemeta.com/foo", "", {"/~I~"}, ""); + "https://www.sourcemeta.com/foo", "", {"/~?~/~I~"}, ""); // Anchors @@ -284,7 +284,7 @@ TEST(JSONSchema_frame_2020_12, one_level_applicators_with_identifiers) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/test/qux#/items", "https://www.sourcemeta.com/test/qux", "/items", - "https://www.sourcemeta.com/foo", "", {"/~I~"}, ""); + "https://www.sourcemeta.com/foo", "", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/test/qux#/items/$id", "https://www.sourcemeta.com/test/qux", "/items/$id", @@ -353,7 +353,7 @@ TEST(JSONSchema_frame_2020_12, subschema_absolute_identifier) { EXPECT_FRAME_STATIC_2020_12_RESOURCE( frame, "https://www.sourcemeta.com/foo", "https://www.sourcemeta.com/schema", "/items", - "https://www.sourcemeta.com/foo", "", {"/~I~"}, ""); + "https://www.sourcemeta.com/foo", "", {"/~?~/~I~"}, ""); // JSON Pointers @@ -368,7 +368,7 @@ TEST(JSONSchema_frame_2020_12, subschema_absolute_identifier) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/items", "https://www.sourcemeta.com/schema", "/items", - "https://www.sourcemeta.com/foo", "", {"/~I~"}, ""); + "https://www.sourcemeta.com/foo", "", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/items/$id", "https://www.sourcemeta.com/schema", "/items/$id", @@ -441,12 +441,13 @@ TEST(JSONSchema_frame_2020_12, nested_schemas) { EXPECT_FRAME_STATIC_2020_12_ANCHOR( frame, "https://www.sourcemeta.com/baz#extra", "https://www.sourcemeta.com/schema", "/properties/baz/items", - "https://www.sourcemeta.com/baz", "/items", {"/baz/~I~"}, + "https://www.sourcemeta.com/baz", "/items", {"/baz/~?~/~I~"}, "/properties/baz"); - EXPECT_FRAME_STATIC_2020_12_RESOURCE( - frame, "https://www.sourcemeta.com/qux", - "https://www.sourcemeta.com/schema", "/properties/foo/items", - "https://www.sourcemeta.com/qux", "", {"/foo/~I~"}, "/properties/foo"); + EXPECT_FRAME_STATIC_2020_12_RESOURCE(frame, "https://www.sourcemeta.com/qux", + "https://www.sourcemeta.com/schema", + "/properties/foo/items", + "https://www.sourcemeta.com/qux", "", + {"/foo/~?~/~I~"}, "/properties/foo"); // JSON Pointers @@ -479,7 +480,8 @@ TEST(JSONSchema_frame_2020_12, nested_schemas) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/properties/foo/items", "https://www.sourcemeta.com/schema", "/properties/foo/items", - "https://www.sourcemeta.com/qux", "", {"/foo/~I~"}, "/properties/foo"); + "https://www.sourcemeta.com/qux", "", {"/foo/~?~/~I~"}, + "/properties/foo"); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/properties/foo/items/$id", "https://www.sourcemeta.com/schema", "/properties/foo/items/$id", @@ -496,7 +498,8 @@ TEST(JSONSchema_frame_2020_12, nested_schemas) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/foo#/items", "https://www.sourcemeta.com/schema", "/properties/foo/items", - "https://www.sourcemeta.com/qux", "", {"/foo/~I~"}, "/properties/foo"); + "https://www.sourcemeta.com/qux", "", {"/foo/~?~/~I~"}, + "/properties/foo"); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/foo#/items/$id", "https://www.sourcemeta.com/schema", "/properties/foo/items/$id", @@ -532,7 +535,7 @@ TEST(JSONSchema_frame_2020_12, nested_schemas) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/properties/baz/items", "https://www.sourcemeta.com/schema", "/properties/baz/items", - "https://www.sourcemeta.com/baz", "/items", {"/baz/~I~"}, + "https://www.sourcemeta.com/baz", "/items", {"/baz/~?~/~I~"}, "/properties/baz"); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/properties/baz/items/$anchor", @@ -547,7 +550,7 @@ TEST(JSONSchema_frame_2020_12, nested_schemas) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/baz#/items", "https://www.sourcemeta.com/schema", "/properties/baz/items", - "https://www.sourcemeta.com/baz", "/items", {"/baz/~I~"}, + "https://www.sourcemeta.com/baz", "/items", {"/baz/~?~/~I~"}, "/properties/baz"); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/baz#/items/$anchor", @@ -731,10 +734,10 @@ TEST(JSONSchema_frame_2020_12, explicit_argument_id_different) { EXPECT_FRAME_STATIC_2020_12_ANCHOR( frame, "https://www.sourcemeta.com/schema#foo", "https://www.sourcemeta.com/schema", "/items", - "https://www.sourcemeta.com/schema", "/items", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/items", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2020_12_ANCHOR( frame, "https://www.example.com#foo", "https://www.sourcemeta.com/schema", - "/items", "https://www.example.com", "/items", {"/~I~"}, ""); + "/items", "https://www.example.com", "/items", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2020_12_ANCHOR( frame, "https://www.sourcemeta.com/test#bar", "https://www.sourcemeta.com/schema", "/properties/one", @@ -760,7 +763,7 @@ TEST(JSONSchema_frame_2020_12, explicit_argument_id_different) { EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/items", "https://www.sourcemeta.com/schema", "/items", "https://www.example.com", - "/items", {"/~I~"}, ""); + "/items", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/items/$anchor", "https://www.sourcemeta.com/schema", "/items/$anchor", @@ -1865,7 +1868,7 @@ TEST(JSONSchema_frame_2020_12, properties_with_refs) { frame, "https://www.sourcemeta.com/schema#/properties/foo", "https://www.sourcemeta.com/schema", "/properties/foo", "https://www.sourcemeta.com/schema", "/properties/foo", - POINTER_TEMPLATES("/foo", "/bar", "/baz/~I~"), ""); + POINTER_TEMPLATES("/foo", "/bar", "/baz/~?~/~I~"), ""); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/properties/foo/type", "https://www.sourcemeta.com/schema", "/properties/foo/type", @@ -1876,7 +1879,7 @@ TEST(JSONSchema_frame_2020_12, properties_with_refs) { frame, "https://www.sourcemeta.com/schema#/properties/bar", "https://www.sourcemeta.com/schema", "/properties/bar", "https://www.sourcemeta.com/schema", "/properties/bar", - POINTER_TEMPLATES("/bar", "/baz/~I~"), ""); + POINTER_TEMPLATES("/bar", "/baz/~?~/~I~"), ""); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/properties/bar/$ref", "https://www.sourcemeta.com/schema", "/properties/bar/$ref", @@ -1891,7 +1894,7 @@ TEST(JSONSchema_frame_2020_12, properties_with_refs) { frame, "https://www.sourcemeta.com/schema#/properties/baz/items", "https://www.sourcemeta.com/schema", "/properties/baz/items", "https://www.sourcemeta.com/schema", "/properties/baz/items", - {"/baz/~I~"}, "/properties/baz"); + {"/baz/~?~/~I~"}, "/properties/baz"); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/properties/baz/items/$ref", "https://www.sourcemeta.com/schema", "/properties/baz/items/$ref", @@ -1996,7 +1999,7 @@ TEST(JSONSchema_frame_2020_12, property_ref_defs) { frame, "https://www.sourcemeta.com/schema#/$defs/helper/items", "https://www.sourcemeta.com/schema", "/$defs/helper/items", "https://www.sourcemeta.com/schema", "/$defs/helper/items", - POINTER_TEMPLATES("/bar", "/foo/~I~"), "/$defs/helper"); + POINTER_TEMPLATES("/bar", "/foo/~?~/~I~"), "/$defs/helper"); EXPECT_FRAME_STATIC_2020_12_SUBSCHEMA( frame, "https://www.sourcemeta.com/schema#/$defs/helper/items/" @@ -2005,7 +2008,8 @@ TEST(JSONSchema_frame_2020_12, property_ref_defs) { "/$defs/helper/items/additionalProperties", "https://www.sourcemeta.com/schema", "/$defs/helper/items/additionalProperties", - POINTER_TEMPLATES("/bar/~P~", "/foo/~I~/~P~"), "/$defs/helper/items"); + POINTER_TEMPLATES("/bar/~?~/~P~", "/foo/~?~/~I~/~?~/~P~"), + "/$defs/helper/items"); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/$defs/helper/items/" @@ -2094,7 +2098,7 @@ TEST(JSONSchema_frame_2020_12, property_cross_ref) { frame, "https://www.sourcemeta.com/schema#/properties/bar/items", "https://www.sourcemeta.com/schema", "/properties/bar/items", "https://www.sourcemeta.com/schema", "/properties/bar/items", - POINTER_TEMPLATES("/bar/~I~", "/foo/~I~"), "/properties/bar"); + POINTER_TEMPLATES("/bar/~?~/~I~", "/foo/~?~/~I~"), "/properties/bar"); EXPECT_FRAME_STATIC_2020_12_POINTER( frame, "https://www.sourcemeta.com/schema#/properties/bar/items/$anchor", "https://www.sourcemeta.com/schema", "/properties/bar/items/$anchor", @@ -2108,14 +2112,14 @@ TEST(JSONSchema_frame_2020_12, property_cross_ref) { "/properties/bar/items/additionalProperties", "https://www.sourcemeta.com/schema", "/properties/bar/items/additionalProperties", - POINTER_TEMPLATES("/bar/~I~/~P~", "/foo/~I~/~P~"), + POINTER_TEMPLATES("/bar/~?~/~I~/~?~/~P~", "/foo/~?~/~I~/~?~/~P~"), "/properties/bar/items"); EXPECT_FRAME_STATIC_2020_12_ANCHOR( frame, "https://www.sourcemeta.com/schema#foo", "https://www.sourcemeta.com/schema", "/properties/bar/items", "https://www.sourcemeta.com/schema", "/properties/bar/items", - POINTER_TEMPLATES("/bar/~I~", "/foo/~I~"), "/properties/bar"); + POINTER_TEMPLATES("/bar/~?~/~I~", "/foo/~?~/~I~"), "/properties/bar"); // References diff --git a/test/jsonschema/jsonschema_frame_draft0_test.cc b/test/jsonschema/jsonschema_frame_draft0_test.cc index a0b14ea5a..18b7e35db 100644 --- a/test/jsonschema/jsonschema_frame_draft0_test.cc +++ b/test/jsonschema/jsonschema_frame_draft0_test.cc @@ -51,7 +51,7 @@ TEST(JSONSchema_frame_draft0, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "http://json-schema.org/draft-00/schema#", - "http://json-schema.org/draft-00/hyper-schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-00/hyper-schema#", {"/~?~/~P~"}, ""); // JSON Pointers @@ -69,7 +69,7 @@ TEST(JSONSchema_frame_draft0, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "http://json-schema.org/draft-00/schema#", - "http://json-schema.org/draft-00/hyper-schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-00/hyper-schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/id", "/additionalProperties/id", "http://json-schema.org/draft-00/schema#", diff --git a/test/jsonschema/jsonschema_frame_draft1_test.cc b/test/jsonschema/jsonschema_frame_draft1_test.cc index a404fad25..0cb5b8783 100644 --- a/test/jsonschema/jsonschema_frame_draft1_test.cc +++ b/test/jsonschema/jsonschema_frame_draft1_test.cc @@ -51,7 +51,7 @@ TEST(JSONSchema_frame_draft1, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "http://json-schema.org/draft-01/schema#", - "http://json-schema.org/draft-01/hyper-schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-01/hyper-schema#", {"/~?~/~P~"}, ""); // JSON Pointers @@ -69,7 +69,7 @@ TEST(JSONSchema_frame_draft1, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "http://json-schema.org/draft-01/schema#", - "http://json-schema.org/draft-01/hyper-schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-01/hyper-schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/id", "/additionalProperties/id", "http://json-schema.org/draft-01/schema#", diff --git a/test/jsonschema/jsonschema_frame_draft2_test.cc b/test/jsonschema/jsonschema_frame_draft2_test.cc index c4b97590b..01b6a4d80 100644 --- a/test/jsonschema/jsonschema_frame_draft2_test.cc +++ b/test/jsonschema/jsonschema_frame_draft2_test.cc @@ -51,7 +51,7 @@ TEST(JSONSchema_frame_draft2, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "http://json-schema.org/draft-02/schema#", - "http://json-schema.org/draft-02/hyper-schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-02/hyper-schema#", {"/~?~/~P~"}, ""); // JSON Pointers @@ -69,7 +69,7 @@ TEST(JSONSchema_frame_draft2, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "http://json-schema.org/draft-02/schema#", - "http://json-schema.org/draft-02/hyper-schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-02/hyper-schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/id", "/additionalProperties/id", "http://json-schema.org/draft-02/schema#", diff --git a/test/jsonschema/jsonschema_frame_draft3_test.cc b/test/jsonschema/jsonschema_frame_draft3_test.cc index e5f3d106d..7ae45613a 100644 --- a/test/jsonschema/jsonschema_frame_draft3_test.cc +++ b/test/jsonschema/jsonschema_frame_draft3_test.cc @@ -49,7 +49,7 @@ TEST(JSONSchema_frame_draft3, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "http://json-schema.org/draft-03/schema#", - "http://json-schema.org/draft-03/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-03/schema#", {"/~?~/~P~"}, ""); // JSON Pointers @@ -66,7 +66,7 @@ TEST(JSONSchema_frame_draft3, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "http://json-schema.org/draft-03/schema#", - "http://json-schema.org/draft-03/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-03/schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/id", "/additionalProperties/id", "http://json-schema.org/draft-03/schema#", diff --git a/test/jsonschema/jsonschema_frame_draft4_test.cc b/test/jsonschema/jsonschema_frame_draft4_test.cc index 5b9ca5da7..9bffeddd2 100644 --- a/test/jsonschema/jsonschema_frame_draft4_test.cc +++ b/test/jsonschema/jsonschema_frame_draft4_test.cc @@ -58,7 +58,7 @@ TEST(JSONSchema_frame_draft4, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "http://json-schema.org/draft-04/schema#", - "http://json-schema.org/draft-04/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-04/schema#", {"/~?~/~P~"}, ""); // JSON Pointers @@ -75,7 +75,7 @@ TEST(JSONSchema_frame_draft4, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "http://json-schema.org/draft-04/schema#", - "http://json-schema.org/draft-04/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-04/schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/id", "/additionalProperties/id", "http://json-schema.org/draft-04/schema#", diff --git a/test/jsonschema/jsonschema_frame_draft6_test.cc b/test/jsonschema/jsonschema_frame_draft6_test.cc index 652c7eb41..ccc4637ee 100644 --- a/test/jsonschema/jsonschema_frame_draft6_test.cc +++ b/test/jsonschema/jsonschema_frame_draft6_test.cc @@ -58,7 +58,7 @@ TEST(JSONSchema_frame_draft6, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "http://json-schema.org/draft-06/schema#", - "http://json-schema.org/draft-06/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-06/schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "https://example.com#/$id", "/additionalProperties/$id", "http://json-schema.org/draft-06/schema#", @@ -75,7 +75,7 @@ TEST(JSONSchema_frame_draft6, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "http://json-schema.org/draft-06/schema#", - "http://json-schema.org/draft-06/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-06/schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/$id", "/additionalProperties/$id", "http://json-schema.org/draft-06/schema#", diff --git a/test/jsonschema/jsonschema_frame_draft7_test.cc b/test/jsonschema/jsonschema_frame_draft7_test.cc index bd4600945..30a9698a9 100644 --- a/test/jsonschema/jsonschema_frame_draft7_test.cc +++ b/test/jsonschema/jsonschema_frame_draft7_test.cc @@ -58,7 +58,7 @@ TEST(JSONSchema_frame_draft7, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_RESOURCE( frame, "https://example.com", "/additionalProperties", "http://json-schema.org/draft-07/schema#", - "http://json-schema.org/draft-07/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-07/schema#", {"/~?~/~P~"}, ""); // JSON Pointers @@ -75,7 +75,7 @@ TEST(JSONSchema_frame_draft7, anonymous_with_nested_schema_resource) { EXPECT_ANONYMOUS_FRAME_STATIC_SUBSCHEMA( frame, "#/additionalProperties", "/additionalProperties", "http://json-schema.org/draft-07/schema#", - "http://json-schema.org/draft-07/schema#", {"/~P~"}, ""); + "http://json-schema.org/draft-07/schema#", {"/~?~/~P~"}, ""); EXPECT_ANONYMOUS_FRAME_STATIC_POINTER( frame, "#/additionalProperties/$id", "/additionalProperties/$id", "http://json-schema.org/draft-07/schema#", diff --git a/test/jsonschema/jsonschema_frame_test.cc b/test/jsonschema/jsonschema_frame_test.cc index cd9cbd7a6..d60f68200 100644 --- a/test/jsonschema/jsonschema_frame_test.cc +++ b/test/jsonschema/jsonschema_frame_test.cc @@ -307,7 +307,7 @@ TEST(JSONSchema_frame, no_id_with_default) { "https://www.sourcemeta.com/schema", "/items", "https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2020-12/schema", - "https://www.sourcemeta.com/schema", "/items", {"/~I~"}, ""); + "https://www.sourcemeta.com/schema", "/items", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_POINTER( frame, "https://www.sourcemeta.com/schema#/items/type", "https://www.sourcemeta.com/schema", "/items/type", @@ -351,12 +351,12 @@ TEST(JSONSchema_frame, anchor_on_absolute_subid) { "https://www.example.com", "/items", "https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2020-12/schema", - "https://www.example.org", "", {"/~I~"}, ""); + "https://www.example.org", "", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_ANCHOR( frame, "https://www.example.org#foo", "https://www.example.com", "/items/items", "https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2020-12/schema", "https://www.example.org", - "/items", {"/~I~/~I~"}, "/items"); + "/items", {"/~?~/~I~/~?~/~I~"}, "/items"); // JSON Pointers @@ -370,11 +370,11 @@ TEST(JSONSchema_frame, anchor_on_absolute_subid) { "https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2020-12/schema", "https://www.example.com", "/$schema", {}, ""); - EXPECT_FRAME_STATIC_SUBSCHEMA(frame, "https://www.example.com#/items", - "https://www.example.com", "/items", - "https://json-schema.org/draft/2020-12/schema", - "https://json-schema.org/draft/2020-12/schema", - "https://www.example.org", "", {"/~I~"}, ""); + EXPECT_FRAME_STATIC_SUBSCHEMA( + frame, "https://www.example.com#/items", "https://www.example.com", + "/items", "https://json-schema.org/draft/2020-12/schema", + "https://json-schema.org/draft/2020-12/schema", "https://www.example.org", + "", {"/~?~/~I~"}, ""); EXPECT_FRAME_STATIC_POINTER(frame, "https://www.example.com#/items/$id", "https://www.example.com", "/items/$id", "https://json-schema.org/draft/2020-12/schema", @@ -384,7 +384,7 @@ TEST(JSONSchema_frame, anchor_on_absolute_subid) { frame, "https://www.example.com#/items/items", "https://www.example.com", "/items/items", "https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2020-12/schema", "https://www.example.org", - "/items", {"/~I~/~I~"}, "/items"); + "/items", {"/~?~/~I~/~?~/~I~"}, "/items"); EXPECT_FRAME_STATIC_POINTER( frame, "https://www.example.com#/items/items/$anchor", "https://www.example.com", "/items/items/$anchor", @@ -400,7 +400,7 @@ TEST(JSONSchema_frame, anchor_on_absolute_subid) { frame, "https://www.example.org#/items", "https://www.example.com", "/items/items", "https://json-schema.org/draft/2020-12/schema", "https://json-schema.org/draft/2020-12/schema", "https://www.example.org", - "/items", {"/~I~/~I~"}, "/items"); + "/items", {"/~?~/~I~/~?~/~I~"}, "/items"); EXPECT_FRAME_STATIC_POINTER(frame, "https://www.example.org#/items/$anchor", "https://www.example.com", "/items/items/$anchor", "https://json-schema.org/draft/2020-12/schema", diff --git a/test/jsonschema/jsonschema_official_walker_2019_09_test.cc b/test/jsonschema/jsonschema_official_walker_2019_09_test.cc index c4bcdf742..4c4b46608 100644 --- a/test/jsonschema/jsonschema_official_walker_2019_09_test.cc +++ b/test/jsonschema/jsonschema_official_walker_2019_09_test.cc @@ -132,7 +132,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_allOf) { using namespace sourcemeta::core; const auto result{ schema_official_walker("allOf", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceInline); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -143,7 +143,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_anyOf) { using namespace sourcemeta::core; const auto result{ schema_official_walker("anyOf", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -154,7 +154,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_oneOf) { using namespace sourcemeta::core; const auto result{ schema_official_walker("oneOf", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -176,7 +176,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_if) { using namespace sourcemeta::core; const auto result{ schema_official_walker("if", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -187,7 +187,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_then) { using namespace sourcemeta::core; const auto result{ schema_official_walker("then", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -199,7 +199,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_else) { using namespace sourcemeta::core; const auto result{ schema_official_walker("else", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2019-09/vocab/applicator"); @@ -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"); @@ -234,7 +234,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_additionalItems) { using namespace sourcemeta::core; const auto result{schema_official_walker("additionalItems", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); 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"); @@ -323,7 +324,7 @@ TEST(JSONSchema_official_walker_2019_09, applicator_unevaluatedItems) { using namespace sourcemeta::core; const auto result{schema_official_walker("unevaluatedItems", VOCABULARIES_2019_09_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); 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"); @@ -1546,11 +1548,13 @@ TEST(JSONSchema_official_walker_2019_09, instance_locations) { // Applicator vocabulary (any) EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 1, "/allOf/0", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 2, "/allOf/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 3, "/anyOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 4, "/oneOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 5, "/if", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 6, "/then", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 7, "/else", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 3, "/anyOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 4, "/oneOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 5, "/if", "", "/~?~", "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 6, "/then", "", "/~?~", "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 7, "/else", "", "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 8, "/not", "", "", ""); // Applicator vocabulary (object) @@ -1559,15 +1563,15 @@ TEST(JSONSchema_official_walker_2019_09, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 10, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 11, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 12, "/patternProperties/^f", "", "/~R^f~", "/~R^f~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 13, "/patternProperties/x$", "", "/~Rx$~", "/~Rx$~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 14, "/dependentSchemas/foo", "", - "", ""); + "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 15, "/dependentSchemas/bar", "", - "", ""); + "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 16, "/propertyNames", "", "/~K~", "/~K~"); @@ -1575,7 +1579,7 @@ TEST(JSONSchema_official_walker_2019_09, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 17, "/contains", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 18, "/additionalItems", "", - "/~I~", "/~I~"); + "/~?~/~I~", "/~?~/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 19, "/items", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 20, "/items/items/0", "/items", @@ -1585,9 +1589,9 @@ TEST(JSONSchema_official_walker_2019_09, instance_locations) { // Unevaluated applicators EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 22, "/unevaluatedProperties", - "", "/~P~", "/~P~"); + "", "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 23, "/unevaluatedItems", "", - "/~I~", "/~I~"); + "/~?~/~I~", "/~?~/~I~"); // Content vocabulary EXPECT_OFFICIAL_WALKER_ENTRY_2019_09(entries, 24, "/contentSchema", "", "", @@ -1634,5 +1638,5 @@ TEST(JSONSchema_official_walker_2019_09, definitions_subschemas) { entries, 2, "/$defs/foo/properties/bar", "/$defs/foo", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_2019_09_ORPHAN( entries, 3, "/$defs/foo/properties/bar/additionalProperties", - "/$defs/foo/properties/bar", "/bar/~P~", "/~P~"); + "/$defs/foo/properties/bar", "/bar/~?~/~P~", "/~?~/~P~"); } diff --git a/test/jsonschema/jsonschema_official_walker_2020_12_test.cc b/test/jsonschema/jsonschema_official_walker_2020_12_test.cc index 3b77905db..eef411851 100644 --- a/test/jsonschema/jsonschema_official_walker_2020_12_test.cc +++ b/test/jsonschema/jsonschema_official_walker_2020_12_test.cc @@ -140,7 +140,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_allOf) { using namespace sourcemeta::core; const auto result{ schema_official_walker("allOf", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceInline); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -151,7 +151,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_anyOf) { using namespace sourcemeta::core; const auto result{ schema_official_walker("anyOf", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -162,7 +162,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_oneOf) { using namespace sourcemeta::core; const auto result{ schema_official_walker("oneOf", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -184,7 +184,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_if) { using namespace sourcemeta::core; const auto result{ schema_official_walker("if", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -195,7 +195,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_then) { using namespace sourcemeta::core; const auto result{ schema_official_walker("then", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -207,7 +207,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_else) { using namespace sourcemeta::core; const auto result{ schema_official_walker("else", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/applicator"); @@ -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"); @@ -241,7 +241,7 @@ TEST(JSONSchema_official_walker_2020_12, applicator_items) { using namespace sourcemeta::core; const auto result{ schema_official_walker("items", VOCABULARIES_2020_12_APPLICATOR)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); 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"); @@ -330,7 +331,7 @@ TEST(JSONSchema_official_walker_2020_12, unevaluated_unevaluatedItems_only) { using namespace sourcemeta::core; const auto result{schema_official_walker("unevaluatedItems", VOCABULARIES_2020_12_UNEVALUATED)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/unevaluated"); @@ -348,7 +349,7 @@ TEST(JSONSchema_official_walker_2020_12, VOCABULARIES_2020_12_APPLICATOR.cend(), std::inserter(vocabularies, vocabularies.end())); const auto result{schema_official_walker("unevaluatedItems", vocabularies)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "https://json-schema.org/draft/2020-12/vocab/unevaluated"); @@ -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"); @@ -1622,11 +1625,13 @@ TEST(JSONSchema_official_walker_2020_12, instance_locations) { // Applicator vocabulary (any) EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 1, "/allOf/0", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 2, "/allOf/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 3, "/anyOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 4, "/oneOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 5, "/if", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 6, "/then", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 7, "/else", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 3, "/anyOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 4, "/oneOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 5, "/if", "", "/~?~", "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 6, "/then", "", "/~?~", "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 7, "/else", "", "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 8, "/not", "", "", ""); // Applicator vocabulary (object) @@ -1635,23 +1640,23 @@ TEST(JSONSchema_official_walker_2020_12, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 10, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 11, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 12, "/patternProperties/^f", "", "/~R^f~", "/~R^f~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 13, "/patternProperties/x$", "", "/~Rx$~", "/~Rx$~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 14, "/dependentSchemas/foo", "", - "", ""); + "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 15, "/dependentSchemas/bar", "", - "", ""); + "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 16, "/propertyNames", "", "/~K~", "/~K~"); // Applicator vocabulary (array) EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 17, "/contains", "", "/~I~", "/~I~"); - EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 18, "/items", "", "/~I~", - "/~I~"); + EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 18, "/items", "", "/~?~/~I~", + "/~?~/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 19, "/prefixItems/0", "", "/0", "/0"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 20, "/prefixItems/1", "", "/1", @@ -1659,9 +1664,9 @@ TEST(JSONSchema_official_walker_2020_12, instance_locations) { // Unevaluated vocabulary EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 21, "/unevaluatedProperties", - "", "/~P~", "/~P~"); + "", "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 22, "/unevaluatedItems", "", - "/~I~", "/~I~"); + "/~?~/~I~", "/~?~/~I~"); // Content vocabulary EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 23, "/contentSchema", "", "", @@ -1701,13 +1706,13 @@ TEST(JSONSchema_official_walker_2020_12, instance_locations_nested) { EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 0, "", std::nullopt, "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12(entries, 1, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12( entries, 2, "/additionalProperties/properties/foo", - "/additionalProperties", "/~P~/foo", "/foo"); + "/additionalProperties", "/~?~/~P~/foo", "/foo"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12( entries, 3, "/additionalProperties/properties/foo/allOf/0", - "/additionalProperties/properties/foo", "/~P~/foo", ""); + "/additionalProperties/properties/foo", "/~?~/~P~/foo", ""); } TEST(JSONSchema_official_walker_2020_12, instance_locations_defs_with_ref) { @@ -1769,5 +1774,5 @@ TEST(JSONSchema_official_walker_2020_12, definitions_subschemas) { entries, 2, "/$defs/foo/properties/bar", "/$defs/foo", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_2020_12_ORPHAN( entries, 3, "/$defs/foo/properties/bar/additionalProperties", - "/$defs/foo/properties/bar", "/bar/~P~", "/~P~"); + "/$defs/foo/properties/bar", "/bar/~?~/~P~", "/~?~/~P~"); } diff --git a/test/jsonschema/jsonschema_official_walker_draft0_test.cc b/test/jsonschema/jsonschema_official_walker_draft0_test.cc index 3e54993ff..a2b484f56 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#"); @@ -76,7 +77,7 @@ TEST(JSONSchema_official_walker_draft0, additionalProperties) { TEST(JSONSchema_official_walker_draft0, type) { using namespace sourcemeta::core; const auto result{schema_official_walker("type", VOCABULARIES_DRAFT0)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); 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#"); @@ -452,7 +454,7 @@ TEST(JSONSchema_official_walker_draft0, hyperschema_type) { using namespace sourcemeta::core; const auto result{ schema_official_walker("type", VOCABULARIES_DRAFT0_HYPERSCHEMA)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); 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~"); @@ -802,8 +804,10 @@ TEST(JSONSchema_official_walker_draft0, instance_locations) { "/~I~/1", "/1"); // Applicators (any) - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 8, "/type/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 9, "/type/2", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 8, "/type/1", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 9, "/type/2", "", "/~?~", + "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 10, "/extends", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT0(entries, 11, "/extends/extends/0", "/extends", "", ""); diff --git a/test/jsonschema/jsonschema_official_walker_draft1_test.cc b/test/jsonschema/jsonschema_official_walker_draft1_test.cc index 121ae8bd8..dfba137ce 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#"); @@ -76,7 +77,7 @@ TEST(JSONSchema_official_walker_draft1, additionalProperties) { TEST(JSONSchema_official_walker_draft1, type) { using namespace sourcemeta::core; const auto result{schema_official_walker("type", VOCABULARIES_DRAFT1)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); 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#"); @@ -452,7 +454,7 @@ TEST(JSONSchema_official_walker_draft1, hyperschema_type) { using namespace sourcemeta::core; const auto result{ schema_official_walker("type", VOCABULARIES_DRAFT1_HYPERSCHEMA)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); 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~"); @@ -802,8 +804,10 @@ TEST(JSONSchema_official_walker_draft1, instance_locations) { "/~I~/1", "/1"); // Applicators (any) - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 8, "/type/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 9, "/type/2", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 8, "/type/1", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 9, "/type/2", "", "/~?~", + "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 10, "/extends", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT1(entries, 11, "/extends/extends/0", "/extends", "", ""); diff --git a/test/jsonschema/jsonschema_official_walker_draft2_test.cc b/test/jsonschema/jsonschema_official_walker_draft2_test.cc index 0c18845b3..61ef8d819 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#"); @@ -76,7 +77,7 @@ TEST(JSONSchema_official_walker_draft2, additionalProperties) { TEST(JSONSchema_official_walker_draft2, type) { using namespace sourcemeta::core; const auto result{schema_official_walker("type", VOCABULARIES_DRAFT2)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); 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#"); @@ -471,7 +473,7 @@ TEST(JSONSchema_official_walker_draft2, hyperschema_type) { using namespace sourcemeta::core; const auto result{ schema_official_walker("type", VOCABULARIES_DRAFT2_HYPERSCHEMA)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); 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~"); @@ -823,8 +825,10 @@ TEST(JSONSchema_official_walker_draft2, instance_locations) { "/~I~/1", "/1"); // Applicators (any) - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 8, "/type/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 9, "/type/2", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 8, "/type/1", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 9, "/type/2", "", "/~?~", + "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 10, "/extends", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT2(entries, 11, "/extends/extends/0", "/extends", "", ""); diff --git a/test/jsonschema/jsonschema_official_walker_draft3_test.cc b/test/jsonschema/jsonschema_official_walker_draft3_test.cc index e2504bb71..c00cfec94 100644 --- a/test/jsonschema/jsonschema_official_walker_draft3_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft3_test.cc @@ -57,7 +57,7 @@ TEST(JSONSchema_official_walker_draft3, additionalItems) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalItems", VOCABULARIES_DRAFT3)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-03/schema#"); @@ -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#"); @@ -117,7 +118,7 @@ TEST(JSONSchema_official_walker_draft3, additionalProperties) { TEST(JSONSchema_official_walker_draft3, type) { using namespace sourcemeta::core; const auto result{schema_official_walker("type", VOCABULARIES_DRAFT3)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-03/schema#"); @@ -317,7 +318,7 @@ TEST(JSONSchema_official_walker_draft3, divisibleBy) { TEST(JSONSchema_official_walker_draft3, disallow) { using namespace sourcemeta::core; const auto result{schema_official_walker("disallow", VOCABULARIES_DRAFT3)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); 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"); @@ -671,10 +672,14 @@ TEST(JSONSchema_official_walker_draft3, instance_locations) { "/~I~/1", "/1"); // Applicators (any) - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 11, "/type/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 12, "/type/2", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 13, "/disallow/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 14, "/disallow/2", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 11, "/type/1", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 12, "/type/2", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 13, "/disallow/1", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 14, "/disallow/2", "", "/~?~", + "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 15, "/extends", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT3(entries, 16, "/extends/extends/0", "/extends", "", ""); diff --git a/test/jsonschema/jsonschema_official_walker_draft4_test.cc b/test/jsonschema/jsonschema_official_walker_draft4_test.cc index 36e9bbb15..ad122f21b 100644 --- a/test/jsonschema/jsonschema_official_walker_draft4_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft4_test.cc @@ -55,7 +55,7 @@ TEST(JSONSchema_official_walker_draft4, definitions) { TEST(JSONSchema_official_walker_draft4, allOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("allOf", VOCABULARIES_DRAFT4)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceInline); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-04/schema#"); @@ -66,7 +66,7 @@ TEST(JSONSchema_official_walker_draft4, allOf) { TEST(JSONSchema_official_walker_draft4, anyOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("anyOf", VOCABULARIES_DRAFT4)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-04/schema#"); @@ -77,7 +77,7 @@ TEST(JSONSchema_official_walker_draft4, anyOf) { TEST(JSONSchema_official_walker_draft4, oneOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("oneOf", VOCABULARIES_DRAFT4)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-04/schema#"); @@ -112,7 +112,7 @@ TEST(JSONSchema_official_walker_draft4, additionalItems) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalItems", VOCABULARIES_DRAFT4)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-04/schema#"); @@ -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#"); @@ -678,8 +679,10 @@ TEST(JSONSchema_official_walker_draft4, instance_locations) { // Applicators (any) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 1, "/allOf/0", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 2, "/allOf/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 3, "/anyOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 4, "/oneOf/0", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 3, "/anyOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 4, "/oneOf/0", "", "/~?~", + "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 5, "/not", "", "", ""); // Applicators (object) @@ -688,17 +691,17 @@ TEST(JSONSchema_official_walker_draft4, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 7, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 8, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 9, "/patternProperties/^f", "", "/~R^f~", "/~R^f~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 10, "/patternProperties/x$", "", "/~Rx$~", "/~Rx$~"); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 11, "/dependencies/baz", "", "", - ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 11, "/dependencies/baz", "", + "/~?~", "/~?~"); // Applicators (array) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 12, "/additionalItems", "", - "/~I~", "/~I~"); + "/~?~/~I~", "/~?~/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 13, "/items", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4(entries, 14, "/items/items/0", "/items", @@ -744,5 +747,5 @@ TEST(JSONSchema_official_walker_draft4, definitions_subschemas) { "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT4_ORPHAN( entries, 3, "/definitions/foo/properties/bar/additionalProperties", - "/definitions/foo/properties/bar", "/bar/~P~", "/~P~"); + "/definitions/foo/properties/bar", "/bar/~?~/~P~", "/~?~/~P~"); } diff --git a/test/jsonschema/jsonschema_official_walker_draft6_test.cc b/test/jsonschema/jsonschema_official_walker_draft6_test.cc index 6f9bf9a71..e615c5708 100644 --- a/test/jsonschema/jsonschema_official_walker_draft6_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft6_test.cc @@ -55,7 +55,7 @@ TEST(JSONSchema_official_walker_draft6, definitions) { TEST(JSONSchema_official_walker_draft6, allOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("allOf", VOCABULARIES_DRAFT6)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceInline); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-06/schema#"); @@ -66,7 +66,7 @@ TEST(JSONSchema_official_walker_draft6, allOf) { TEST(JSONSchema_official_walker_draft6, anyOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("anyOf", VOCABULARIES_DRAFT6)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-06/schema#"); @@ -77,7 +77,7 @@ TEST(JSONSchema_official_walker_draft6, anyOf) { TEST(JSONSchema_official_walker_draft6, oneOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("oneOf", VOCABULARIES_DRAFT6)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-06/schema#"); @@ -112,7 +112,7 @@ TEST(JSONSchema_official_walker_draft6, additionalItems) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalItems", VOCABULARIES_DRAFT6)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-06/schema#"); @@ -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#"); @@ -732,8 +733,10 @@ TEST(JSONSchema_official_walker_draft6, instance_locations) { // Applicators (any) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 1, "/allOf/0", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 2, "/allOf/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 3, "/anyOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 4, "/oneOf/0", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 3, "/anyOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 4, "/oneOf/0", "", "/~?~", + "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 5, "/not", "", "", ""); // Applicators (object) @@ -742,13 +745,13 @@ TEST(JSONSchema_official_walker_draft6, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 7, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 8, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 9, "/patternProperties/^f", "", "/~R^f~", "/~R^f~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 10, "/patternProperties/x$", "", "/~Rx$~", "/~Rx$~"); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 11, "/dependencies/baz", "", "", - ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 11, "/dependencies/baz", "", + "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 12, "/propertyNames", "", "/~K~", "/~K~"); @@ -756,7 +759,7 @@ TEST(JSONSchema_official_walker_draft6, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 13, "/contains", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 14, "/additionalItems", "", - "/~I~", "/~I~"); + "/~?~/~I~", "/~?~/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 15, "/items", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6(entries, 16, "/items/items/0", "/items", @@ -802,5 +805,5 @@ TEST(JSONSchema_official_walker_draft6, definitions_subschemas) { "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT6_ORPHAN( entries, 3, "/definitions/foo/properties/bar/additionalProperties", - "/definitions/foo/properties/bar", "/bar/~P~", "/~P~"); + "/definitions/foo/properties/bar", "/bar/~?~/~P~", "/~?~/~P~"); } diff --git a/test/jsonschema/jsonschema_official_walker_draft7_test.cc b/test/jsonschema/jsonschema_official_walker_draft7_test.cc index e19362681..236585a81 100644 --- a/test/jsonschema/jsonschema_official_walker_draft7_test.cc +++ b/test/jsonschema/jsonschema_official_walker_draft7_test.cc @@ -66,7 +66,7 @@ TEST(JSONSchema_official_walker_draft7, comment) { TEST(JSONSchema_official_walker_draft7, allOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("allOf", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceInline); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -77,7 +77,7 @@ TEST(JSONSchema_official_walker_draft7, allOf) { TEST(JSONSchema_official_walker_draft7, anyOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("anyOf", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -88,7 +88,7 @@ TEST(JSONSchema_official_walker_draft7, anyOf) { TEST(JSONSchema_official_walker_draft7, oneOf) { using namespace sourcemeta::core; const auto result{schema_official_walker("oneOf", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorElementsInPlaceSome); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -110,7 +110,7 @@ TEST(JSONSchema_official_walker_draft7, not) { TEST(JSONSchema_official_walker_draft7, if) { using namespace sourcemeta::core; const auto result{schema_official_walker("if", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -121,7 +121,7 @@ TEST(JSONSchema_official_walker_draft7, if) { TEST(JSONSchema_official_walker_draft7, then) { using namespace sourcemeta::core; const auto result{schema_official_walker("then", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -132,7 +132,7 @@ TEST(JSONSchema_official_walker_draft7, then) { TEST(JSONSchema_official_walker_draft7, else) { using namespace sourcemeta::core; const auto result{schema_official_walker("else", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlace); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueInPlaceMaybe); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -156,7 +156,7 @@ TEST(JSONSchema_official_walker_draft7, additionalItems) { using namespace sourcemeta::core; const auto result{ schema_official_walker("additionalItems", VOCABULARIES_DRAFT7)}; - EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseAnyItem); + EXPECT_EQ(result.type, SchemaKeywordType::ApplicatorValueTraverseSomeItem); EXPECT_TRUE(result.vocabulary.has_value()); EXPECT_EQ(result.vocabulary.value(), "http://json-schema.org/draft-07/schema#"); @@ -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#"); @@ -917,11 +918,13 @@ TEST(JSONSchema_official_walker_draft7, instance_locations) { // Applicators (any) EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 1, "/allOf/0", "", "", ""); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 2, "/allOf/1", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 3, "/anyOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 4, "/oneOf/0", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 5, "/if", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 6, "/then", "", "", ""); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 7, "/else", "", "", ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 3, "/anyOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 4, "/oneOf/0", "", "/~?~", + "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 5, "/if", "", "/~?~", "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 6, "/then", "", "/~?~", "/~?~"); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 7, "/else", "", "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 8, "/not", "", "", ""); // Applicators (object) @@ -930,13 +933,13 @@ TEST(JSONSchema_official_walker_draft7, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 10, "/properties/bar", "", "/bar", "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 11, "/additionalProperties", "", - "/~P~", "/~P~"); + "/~?~/~P~", "/~?~/~P~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 12, "/patternProperties/^f", "", "/~R^f~", "/~R^f~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 13, "/patternProperties/x$", "", "/~Rx$~", "/~Rx$~"); - EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 14, "/dependencies/baz", "", "", - ""); + EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 14, "/dependencies/baz", "", + "/~?~", "/~?~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 15, "/propertyNames", "", "/~K~", "/~K~"); @@ -944,7 +947,7 @@ TEST(JSONSchema_official_walker_draft7, instance_locations) { EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 16, "/contains", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 17, "/additionalItems", "", - "/~I~", "/~I~"); + "/~?~/~I~", "/~?~/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 18, "/items", "", "/~I~", "/~I~"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7(entries, 19, "/items/items/0", "/items", @@ -990,5 +993,5 @@ TEST(JSONSchema_official_walker_draft7, definitions_subschemas) { "/bar"); EXPECT_OFFICIAL_WALKER_ENTRY_DRAFT7_ORPHAN( entries, 3, "/definitions/foo/properties/bar/additionalProperties", - "/definitions/foo/properties/bar", "/bar/~P~", "/~P~"); + "/definitions/foo/properties/bar", "/bar/~?~/~P~", "/~?~/~P~"); } 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", {}}; }