Module: ElasticGraph::JSONIngestion::SchemaDefinition::FactoryExtension Private

Defined in:
elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/factory_extension.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Extension module applied to ElasticGraph::SchemaDefinition::Factory to wire up JSON Schema support on Results and SchemaArtifactManager instances.

Constant Summary collapse

BUILT_IN_SCALAR_JSON_SCHEMA_OPTIONS_BY_NAME =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Default JSON schema options applied to ElasticGraph's built-in scalar types as they are constructed. Keyed by the un-overridden type name, because built-in type registration always uses the canonical type name before type_name_overrides are applied to the resulting type reference.

{
  "Boolean" => {type: "boolean"},
  "Float" => {type: "number"},
  "ID" => {type: "string"},
  "Int" => {type: "integer", minimum: INT_MIN, maximum: INT_MAX},
  "String" => {type: "string"},
  "Cursor" => {type: "string"},
  "Date" => {type: "string", format: "date"},
  "DateTime" => {type: "string", format: "date-time"},
  "LocalTime" => {type: "string", pattern: VALID_LOCAL_TIME_JSON_SCHEMA_PATTERN},
  "TimeZone" => {type: "string", enum: GraphQL::ScalarCoercionAdapters::VALID_TIME_ZONES.to_a.freeze},
  "Untyped" => {type: ["array", "boolean", "integer", "number", "object", "string"].freeze},
  "JsonSafeLong" => {type: "integer", minimum: JSON_SAFE_LONG_MIN, maximum: JSON_SAFE_LONG_MAX},
  "LongString" => {type: "integer", minimum: LONG_STRING_MIN, maximum: LONG_STRING_MAX}
}.freeze

Instance Method Summary collapse

Instance Method Details

#new_resultsElasticGraph::SchemaDefinition::Results

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new Results instance with JSON Schema extensions.

Returns:



119
120
121
122
123
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/factory_extension.rb', line 119

def new_results
  super.tap do |results|
    results.extend(ResultsExtension)
  end
end

#new_schema_artifact_managerElasticGraph::SchemaDefinition::SchemaArtifactManager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Creates a new SchemaArtifactManager instance with JSON Schema extensions.

Returns:

  • (ElasticGraph::SchemaDefinition::SchemaArtifactManager)

    the created artifact manager



128
129
130
131
132
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/factory_extension.rb', line 128

def new_schema_artifact_manager(...)
  super.tap do |manager|
    manager.extend(SchemaArtifactManagerExtension)
  end
end