Module: JSI::SchemaModule::DescribesSchemaModule

Included in:
JSONSchemaDraft04, JSONSchemaDraft06, JSONSchemaDraft07
Defined in:
lib/jsi/schema_classes.rb

Overview

A module to extend the JSI::SchemaModule of a schema which describes other schemas (a JSI::Schema::DescribesSchema)

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#schema_implementation_modulesSet<Module> (readonly)

Returns:

  • (Set<Module>)


89
90
91
# File 'lib/jsi/schema_classes.rb', line 89

def schema_implementation_modules
  @schema_implementation_modules
end

Instance Method Details

#new_schema(schema_content, **kw) { ... } ⇒ JSI::Base subclass + JSI::Schema

Instantiates the given schema content as a JSI Schema.

see JSI::Schema::DescribesSchema#new_schema

Parameters:

  • schema_content

    an object to be instantiated as a JSI Schema - typically a Hash

  • uri (#to_str, Addressable::URI)

    The retrieval URI of the schema document. If specified, the root schema will be identified by this URI, in addition to any absolute URI declared with an id keyword, for resolution in the schema_registry.

    It is rare that this needs to be specified. Most schemas, if they use absolute URIs, will use the $id keyword (id in draft 4) to specify this. A different retrieval URI is useful in unusual cases:

    • A schema in the document uses relative URIs for $id or $ref without an absolute id in an ancestor schema - these will be resolved relative to this URI
    • Another schema refers with $ref to the schema being instantiated by this retrieval URI, rather than an id declared in the schema - the schema is resolvable by this URI in the schema_registry.
  • register (Boolean)

    Whether the instantiated schema and any subschemas with absolute URIs will be registered in the schema registry indicated by param schema_registry.

  • schema_registry (SchemaRegistry, nil)

    The registry this schema will use.

    • The schema and subschemas will be registered here with any declared URI, unless the register param is false.
    • References from within the schema (typically from $ref keywords) are resolved using this registry.
  • stringify_symbol_keys (Boolean)

    Whether the schema content will have any Symbol keys of Hashes replaced with Strings (recursively through the document). Replacement is done on a copy; the given schema content is not modified.

Yields:

  • If a block is given, it is evaluated in the context of the schema's JSI schema module using Module#module_exec.

Returns:

  • (JSI::Base subclass + JSI::Schema)

    a JSI which is a JSI::Schema whose content comes from the given schema_content and whose schemas are inplace applicators of this module's schema



79
80
81
# File 'lib/jsi/schema_classes.rb', line 79

def new_schema(schema_content, **kw, &block)
  schema.new_schema(schema_content, **kw, &block)
end

#new_schema_module(schema_content, **kw, &block) ⇒ Module + JSI::SchemaModule

Instantiates the given schema content as a JSI Schema, passing all params to JSI::Schema::DescribesSchema#new_schema, and returns its JSI Schema Module.

Returns:



84
85
86
# File 'lib/jsi/schema_classes.rb', line 84

def new_schema_module(schema_content, **kw, &block)
  schema.new_schema(schema_content, **kw, &block).jsi_schema_module
end