Class: ElasticGraph::SchemaDefinition::Indexing::JSONSchemaWithMetadata::Merger::JSONSchemaResolver
- Inherits:
-
Object
- Object
- ElasticGraph::SchemaDefinition::Indexing::JSONSchemaWithMetadata::Merger::JSONSchemaResolver
- Defined in:
- lib/elastic_graph/schema_definition/indexing/json_schema_with_metadata.rb
Instance Method Summary collapse
-
#initialize(state, json_schema, old_type_name_by_current_name) ⇒ JSONSchemaResolver
constructor
A new instance of JSONSchemaResolver.
-
#necessary_path_missing?(field_path) ⇒ Boolean
Indicates if the given ‘field_path` is (1) necessary and (2) missing from the JSON schema, indicating a problem.
Constructor Details
#initialize(state, json_schema, old_type_name_by_current_name) ⇒ JSONSchemaResolver
Returns a new instance of JSONSchemaResolver.
187 188 189 190 191 192 193 194 195 196 197 198 199 |
# File 'lib/elastic_graph/schema_definition/indexing/json_schema_with_metadata.rb', line 187 def initialize(state, json_schema, old_type_name_by_current_name) @state = state @old_type_name_by_current_name = old_type_name_by_current_name @meta_by_old_type_and_name_in_index = ::Hash.new do |hash, type_name| properties = json_schema.fetch("$defs").fetch(type_name).fetch("properties") hash[type_name] = properties.filter_map do |name, prop| if ( = prop["ElasticGraph"]) [.fetch("nameInIndex"), ] end end.to_h end end |
Instance Method Details
#necessary_path_missing?(field_path) ⇒ Boolean
Indicates if the given ‘field_path` is (1) necessary and (2) missing from the JSON schema, indicating a problem.
-
Returns ‘false` is the given `field_path` is present in the JSON schema.
-
Returns ‘false` is the parent type of `field_path` has not been retained in this JSON schema version (in that case, the field path is not necessary).
-
Otherwise, returns ‘true` since the field path is both necessary and missing.
207 208 209 210 211 212 213 214 215 |
# File 'lib/elastic_graph/schema_definition/indexing/json_schema_with_metadata.rb', line 207 def necessary_path_missing?(field_path) parent_type = field_path.first_part.parent_type.name field_path.path_parts.any? do |path_part| necessary_path_part_missing?(parent_type, path_part.name_in_index) do || parent_type = @state.type_ref(.fetch("type")).fully_unwrapped.name end end end |