Module: JSI::Schema::DescribesSchema
- Defined in:
- lib/jsi/schema.rb
Overview
This module extends any JSI Schema which describes schemas.
Examples of a schema which describes schemas include the JSON Schema metaschemas and the OpenAPI schema definition which describes "A deterministic version of a JSON Schema object."
Schemas which describes schemas include JSI::Schema in their JSI Schema module, so for a schema which is an instance of DescribesSchema, 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 Method Summary collapse
-
#new_schema(schema_content, uri: nil, register: true, schema_registry: JSI.schema_registry, stringify_symbol_keys: true) { ... } ⇒ JSI::Base subclass + JSI::Schema
Instantiates the given schema content as a JSI Schema.
-
#new_schema_module(schema_content, **kw, &block) ⇒ Module + JSI::SchemaModule
Instantiates the given schema content as a JSI Schema, passing all params to #new_schema, and returns its JSI Schema Module.
Instance Method Details
#new_schema(schema_content, uri: nil, register: true, schema_registry: JSI.schema_registry, stringify_symbol_keys: true) { ... } ⇒ 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
.
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/jsi/schema.rb', line 183 def new_schema(schema_content, uri: nil, register: true, schema_registry: JSI.schema_registry, stringify_symbol_keys: true, &block ) schema_jsi = new_jsi(schema_content, uri: uri, register: register, schema_registry: schema_registry, stringify_symbol_keys: stringify_symbol_keys, ) if block schema_jsi.jsi_schema_module_exec(&block) end schema_jsi end |
#new_schema_module(schema_content, **kw, &block) ⇒ Module + JSI::SchemaModule
Instantiates the given schema content as a JSI Schema, passing all params to #new_schema, and returns its JSI Schema Module.
206 207 208 |
# File 'lib/jsi/schema.rb', line 206 def new_schema_module(schema_content, **kw, &block) new_schema(schema_content, **kw, &block).jsi_schema_module end |