Module: JSI::Schema::DescribesSchema
- Defined in:
- lib/jsi/schema.rb
Overview
JSI::Schema::DescribesSchema: a schema which describes another schema. this module extends a JSI::Schema instance and indicates that JSIs which instantiate the schema are themselves also schemas.
examples of a schema which describes a schema include the draft JSON Schema metaschemas and the OpenAPI schema definition which describes "A deterministic version of a JSON Schema object."
Instance Method Summary collapse
-
#new_schema(schema_content, uri: nil) ⇒ JSI::Base
instantiates the given schema content as a JSI Schema.
-
#new_schema_module(schema_content, **kw) ⇒ Module, JSI::SchemaModule
instantiates a given schema object as a JSI Schema and returns its JSI Schema Module.
Instance Method Details
#new_schema(schema_content, uri: nil) ⇒ JSI::Base
instantiates the given schema content as a JSI Schema.
the schema is instantiated after recursively converting any symbol hash keys in the structure to strings. note that this is in contrast to JSI::Schema#new_jsi, which does not alter its given instance.
the schema will be registered with the JSI.schema_registry
.
152 153 154 155 156 157 158 159 160 |
# File 'lib/jsi/schema.rb', line 152 def new_schema(schema_content, uri: nil ) schema_jsi = new_jsi(Util.deep_stringify_symbol_keys(schema_content), uri: uri, ) JSI.schema_registry.register(schema_jsi) schema_jsi end |
#new_schema_module(schema_content, **kw) ⇒ Module, JSI::SchemaModule
instantiates a given schema object as a JSI Schema and returns its JSI Schema Module.
shortcut to chain #new_schema + JSI::Schema#jsi_schema_module.
168 169 170 |
# File 'lib/jsi/schema.rb', line 168 def new_schema_module(schema_content, **kw) new_schema(schema_content, **kw).jsi_schema_module end |