Module: JSI::Schema::MetaSchema
- Defined in:
- lib/jsi/schema.rb
Overview
This module extends any JSI Schema that is a meta-schema, i.e. it describes schemas.
Examples of a meta-schema include the JSON Schema meta-schemas and the OpenAPI schema definition which describes "A deterministic version of a JSON Schema object."
Meta-schemas include JSI::Schema in their JSI Schema module, so for a schema which is an instance of JSI::Schema::MetaSchema, instances of that schema are instances of JSI::Schema and are schemas.
A schema is indicated as describing other schemas using the #describes_schema! method.
Instance Attribute Summary collapse
Instance Method Summary collapse
-
#new_schema(schema_content, uri: nil, register: true, schema_registry: JSI.schema_registry, stringify_symbol_keys: true, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE) { ... } ⇒ JSI::Base subclass + JSI::Schema
Instantiates the given schema content as a JSI Schema.
-
#new_schema_module(schema_content, **kw, &block) ⇒ JSI::SchemaModule
Instantiates the given schema content as a JSI Schema, passing all params to #new_schema, and returns its JSI Schema Module.
Instance Attribute Details
#schema_implementation_modules ⇒ Set<Module> (readonly)
148 149 150 |
# File 'lib/jsi/schema.rb', line 148 def schema_implementation_modules @schema_implementation_modules end |
Instance Method Details
#new_schema(schema_content, uri: nil, register: true, schema_registry: JSI.schema_registry, stringify_symbol_keys: true, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE) { ... } ⇒ JSI::Base subclass + JSI::Schema
Instantiates the given schema content as a JSI Schema.
By default, the schema will be registered with the JSI.schema_registry.
This can be controlled by params register and schema_registry.
By default, the schema_content will have any Symbol keys of Hashes replaced with Strings
(recursively through the document). This is controlled by the param stringify_symbol_keys.
Schemas instantiated with new_schema are immutable, their content transformed using
the to_immutable param.
190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/jsi/schema.rb', line 190 def new_schema(schema_content, uri: nil, register: true, schema_registry: JSI.schema_registry, stringify_symbol_keys: true, to_immutable: DEFAULT_CONTENT_TO_IMMUTABLE, &block ) schema_jsi = new_jsi(schema_content, uri: uri, register: register, schema_registry: schema_registry, stringify_symbol_keys: stringify_symbol_keys, to_immutable: to_immutable, mutable: false, ) schema_jsi.jsi_schema_module_exec(&block) if block schema_jsi end |
#new_schema_module(schema_content, **kw, &block) ⇒ JSI::SchemaModule
Instantiates the given schema content as a JSI Schema, passing all params to #new_schema, and returns its JSI Schema Module.
216 217 218 |
# File 'lib/jsi/schema.rb', line 216 def new_schema_module(schema_content, **kw, &block) new_schema(schema_content, **kw, &block).jsi_schema_module end |