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
- #described_dialect ⇒ Schema::Dialect readonly
Instance Method Summary collapse
-
#new_schema(schema_content, base_uri: nil, register: true, stringify_symbol_keys: true, **conf_kw) ⇒ Base + Schema
Instantiates the given schema content as a JSI Schema.
-
#new_schema_module(schema_content, **kw) { ... } ⇒ 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
#described_dialect ⇒ Schema::Dialect (readonly)
76 77 78 |
# File 'lib/jsi/schema.rb', line 76 def described_dialect @described_dialect end |
Instance Method Details
#new_schema(schema_content, base_uri: nil, register: true, stringify_symbol_keys: true, **conf_kw) ⇒ Base + Schema
Instantiates the given schema content as a JSI Schema.
By default, the schema will be registered with the JSI.registry.
This can be controlled by the register param and registry configuration.
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 configured to_immutable.
Parameters are passed to JSI::SchemaSet#new_jsi and are documented there, but some have different defaults for new_schema.
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/jsi/schema.rb', line 99 def new_schema(schema_content, base_uri: nil, register: true, stringify_symbol_keys: true, **conf_kw ) raise(BlockGivenError) if block_given? new_jsi(schema_content, base_uri: base_uri, register: register, stringify_symbol_keys: stringify_symbol_keys, **conf_kw, mutable: false, ) end |
#new_schema_module(schema_content, **kw) { ... } ⇒ JSI::SchemaModule
Instantiates the given schema content as a JSI Schema, passing all params to #new_schema, and returns its JSI Schema Module.
121 122 123 124 125 |
# File 'lib/jsi/schema.rb', line 121 def new_schema_module(schema_content, **kw, &block) schema_jsi = new_schema(schema_content, **kw) schema_jsi.jsi_schema_module_exec(&block) if block schema_jsi.jsi_schema_module end |