Module: JSI

Extended by:
Util
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/jsi_coder.rb,
lib/jsi/metaschema.rb,
lib/jsi/schema/ref.rb,
lib/jsi/schema_set.rb,
lib/jsi/validation.rb,
lib/jsi/pathed_node.rb,
lib/jsi/simple_wrap.rb,
lib/jsi/schema/issue.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/typelike_modules.rb,
lib/jsi/util/attr_struct.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/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: Arraylike, DescribesSchemaModule, Hashlike, JSONSchemaOrgDraft04, JSONSchemaOrgDraft06, JSONSchemaOrgDraft07, Metaschema, PathedArrayNode, PathedHashNode, PathedNode, Schema, SchemaClasses, SchemaModule, SchemaModulePossibly, SimpleWrap, Typelike, Util, Validation Classes: Base, Bug, JSICoder, MetaschemaNode, NotASchemaModule, Ptr, SchemaRegistry, SchemaSet

Constant Summary collapse

VERSION =
"0.6.0".freeze

Class Method Summary collapse

Methods included from Util

deep_stringify_symbol_keys, ensure_module_set, ok_ruby_method_name?, stringify_symbol_keys, ycomb

Class Method Details

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

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::Schema)

    a JSI::Schema representing the given schema_object


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

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:


76
77
78
# File 'lib/jsi.rb', line 76

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:


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

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