Module: ElasticGraph::JSONIngestion::SchemaDefinition::SchemaElements::ScalarTypeExtension
- Includes:
- HasJSONSchema
- Defined in:
- elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rb
Overview
Extends scalar types with JSON schema validation and serialization behavior.
Constant Summary collapse
- BUILT_IN_SCALAR_JSON_SCHEMA_OPTIONS_BY_NAME =
Default JSON schema options applied to ElasticGraph's built-in scalar types as they are constructed.
{ "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
-
#initialize_json_schema_extension { ... } ⇒ void
Applies any built-in JSON schema options, yields for further configuration, validates the result, and applies runtime metadata derived from the final JSON schema configuration.
Methods included from HasJSONSchema
#json_schema, #json_schema_options
Instance Method Details
#initialize_json_schema_extension { ... } ⇒ void
This method returns an undefined value.
Applies any built-in JSON schema options, yields for further configuration, validates the result, and applies runtime metadata derived from the final JSON schema configuration.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'elasticgraph-json_ingestion/lib/elastic_graph/json_ingestion/schema_definition/schema_elements/scalar_type_extension.rb', line 44 def initialize_json_schema_extension original_name = type_ref.with_reverted_override.name if ( = BUILT_IN_SCALAR_JSON_SCHEMA_OPTIONS_BY_NAME[original_name]) json_schema(**) end yield return if graphql_only? if .empty? raise Errors::SchemaError, "Scalar types require `json_schema` to be configured, but `#{name}` lacks `json_schema`." end if !grouping_missing_value_placeholder_overridden && (placeholder = inferred_grouping_missing_value_placeholder) self. = .with(grouping_missing_value_placeholder: placeholder) end end |