Module: JSI

Defined in:
lib/jsi.rb,
lib/jsi/ptr.rb,
lib/jsi/base.rb,
lib/jsi/util.rb,
lib/jsi/schema.rb,
lib/jsi/version.rb,
lib/jsi/base/node.rb,
lib/jsi/jsi_coder.rb,
lib/jsi/metaschema.rb,
lib/jsi/schema/ref.rb,
lib/jsi/schema_set.rb,
lib/jsi/validation.rb,
lib/jsi/simple_wrap.rb,
lib/jsi/schema/issue.rb,
lib/jsi/util/private.rb,
lib/jsi/util/typelike.rb,
lib/jsi/schema/draft04.rb,
lib/jsi/schema/draft06.rb,
lib/jsi/schema/draft07.rb,
lib/jsi/schema_classes.rb,
lib/jsi/metaschema_node.rb,
lib/jsi/schema_registry.rb,
lib/jsi/validation/error.rb,
lib/jsi/schema/validation.rb,
lib/jsi/validation/result.rb,
lib/jsi/schema/application.rb,
lib/jsi/schema/validation/not.rb,
lib/jsi/schema/validation/ref.rb,
lib/jsi/schema/validation/core.rb,
lib/jsi/schema/validation/enum.rb,
lib/jsi/schema/validation/type.rb,
lib/jsi/schema/validation/array.rb,
lib/jsi/schema/validation/const.rb,
lib/jsi/schema/validation/items.rb,
lib/jsi/schema/validation/object.rb,
lib/jsi/schema/validation/someof.rb,
lib/jsi/schema/validation/string.rb,
lib/jsi/util/private/attr_struct.rb,
lib/jsi/schema/validation/draft04.rb,
lib/jsi/schema/validation/draft06.rb,
lib/jsi/schema/validation/draft07.rb,
lib/jsi/schema/validation/numeric.rb,
lib/jsi/schema/validation/pattern.rb,
lib/jsi/schema/application/draft04.rb,
lib/jsi/schema/application/draft06.rb,
lib/jsi/schema/application/draft07.rb,
lib/jsi/schema/validation/contains.rb,
lib/jsi/schema/validation/required.rb,
lib/jsi/schema/schema_ancestor_node.rb,
lib/jsi/schema/validation/ifthenelse.rb,
lib/jsi/schema/validation/properties.rb,
lib/jsi/schema/validation/dependencies.rb,
lib/jsi/metaschema_node/bootstrap_schema.rb,
lib/jsi/schema/validation/draft04/minmax.rb,
lib/jsi/schema/validation/property_names.rb,
lib/schemas/json-schema.org/draft-04/schema.rb,
lib/schemas/json-schema.org/draft-06/schema.rb,
lib/schemas/json-schema.org/draft-07/schema.rb,
lib/jsi/schema/application/child_application.rb,
lib/jsi/schema/application/inplace_application.rb,
lib/jsi/schema/application/child_application/items.rb,
lib/jsi/schema/application/inplace_application/ref.rb,
lib/jsi/schema/application/child_application/draft04.rb,
lib/jsi/schema/application/child_application/draft06.rb,
lib/jsi/schema/application/child_application/draft07.rb,
lib/jsi/schema/application/child_application/contains.rb,
lib/jsi/schema/application/inplace_application/someof.rb,
lib/jsi/schema/application/inplace_application/draft04.rb,
lib/jsi/schema/application/inplace_application/draft06.rb,
lib/jsi/schema/application/inplace_application/draft07.rb,
lib/jsi/schema/application/child_application/properties.rb,
lib/jsi/schema/application/inplace_application/ifthenelse.rb,
lib/jsi/schema/application/inplace_application/dependencies.rb

Defined Under Namespace

Modules: DescribesSchemaModule, JSONSchemaOrgDraft04, JSONSchemaOrgDraft06, JSONSchemaOrgDraft07, Metaschema, Schema, SchemaClasses, SchemaModule, SchemaModulePossibly, SimpleWrap, Typelike, Util, Validation Classes: Base, Bug, JSICoder, MetaschemaNode, NotASchemaModule, Ptr, SchemaRegistry, SchemaSet

Constant Summary collapse

VERSION =
"0.7.0".freeze

Class Method Summary collapse

Class Method Details

.new_schema(schema_object, **kw) ⇒ JSI::Base

instantiates a given schema object as a JSI Schema.

see JSI::Schema.new_schema

Parameters:

  • schema_object (#to_hash, Boolean, JSI::Schema)

    an object to be instantiated as a schema. if it's already a JSI::Schema, it is returned as-is.

  • default_metaschema (#new_schema)

    the metaschema to use if the schema_object does not have a '$schema' property. this may be a metaschema or a metaschema's schema module (e.g. JSI::JSONSchemaOrgDraft07).

  • uri (nil, #to_str, Addressable::URI)

    the URI of the schema document. relative URIs within the document are resolved using this uri as their base. the result schema will be registered with this URI in the schema_registry.

Returns:

  • (JSI::Base)

    a JSI which is a Schema whose instance is the given schema_object and whose schemas are the metaschema's inplace applicators.


55
56
57
# File 'lib/jsi.rb', line 55

def self.new_schema(schema_object, **kw)
  JSI::Schema.new_schema(schema_object, **kw)
end

.new_schema_module(schema_object, **kw) ⇒ Module, JSI::SchemaModule

instantiates a given schema object as a JSI Schema and returns its JSI Schema Module.

shortcut to chain JSI::Schema.new_schema + JSI::Schema#jsi_schema_module.

Parameters:

  • schema_object (#to_hash, Boolean, JSI::Schema)

    an object to be instantiated as a schema. if it's already a JSI::Schema, it is returned as-is.

  • default_metaschema (#new_schema)

    the metaschema to use if the schema_object does not have a '$schema' property. this may be a metaschema or a metaschema's schema module (e.g. JSI::JSONSchemaOrgDraft07).

  • uri (nil, #to_str, Addressable::URI)

    the URI of the schema document. relative URIs within the document are resolved using this uri as their base. the result schema will be registered with this URI in the schema_registry.

Returns:


65
66
67
# File 'lib/jsi.rb', line 65

def self.new_schema_module(schema_object, **kw)
  JSI::Schema.new_schema(schema_object, **kw).jsi_schema_module
end

.schema_registryJSI::SchemaRegistry

JSI.schema_registry is the SchemaRegistry in which schemas are registered.

Returns:


72
73
74
75
# File 'lib/jsi.rb', line 72

def self.schema_registry
  return @schema_registry if instance_variable_defined?(:@schema_registry)
  @schema_registry = SchemaRegistry.new
end