require "jsi/version"
require "pp"
require "set"
require "json"
require "pathname"
require "bigdecimal"
require "addressable/uri"
module JSI
class Bug < NotImplementedError
end
FrozenError = Object.const_defined?(:FrozenError) ? ::FrozenError : Class.new(StandardError)
ROOT_PATH = Pathname.new(__FILE__).dirname.parent.expand_path
RESOURCES_PATH = ROOT_PATH.join('{resources}')
SCHEMAS_PATH = RESOURCES_PATH.join('schemas')
autoload :Util, 'jsi/util'
autoload :Ptr, 'jsi/ptr'
autoload :Schema, 'jsi/schema'
autoload :SchemaSet, 'jsi/schema_set'
autoload :Base, 'jsi/base'
autoload :Metaschema, 'jsi/metaschema'
autoload :MetaschemaNode, 'jsi/metaschema_node'
autoload :SchemaModule, 'jsi/schema_classes'
autoload :SchemaClasses, 'jsi/schema_classes'
autoload :SchemaRegistry, 'jsi/schema_registry'
autoload :Validation, 'jsi/validation'
autoload :JSICoder, 'jsi/jsi_coder'
autoload :JSONSchemaDraft04, 'schemas/json-schema.org/draft-04/schema'
autoload :JSONSchemaDraft06, 'schemas/json-schema.org/draft-06/schema'
autoload :JSONSchemaDraft07, 'schemas/json-schema.org/draft-07/schema'
autoload :JSONSchemaOrgDraft04, 'schemas/json-schema.org/draft-04/schema'
autoload :JSONSchemaOrgDraft06, 'schemas/json-schema.org/draft-06/schema'
autoload :JSONSchemaOrgDraft07, 'schemas/json-schema.org/draft-07/schema'
autoload :SimpleWrap, 'jsi/simple_wrap'
def self.new_schema_module(schema_content, **kw, &block)
new_schema(schema_content, **kw, &block).jsi_schema_module
end
def self.new_metaschema(metaschema_document,
schema_implementation_modules:
)
MetaschemaNode.new(metaschema_document,
schema_implementation_modules: schema_implementation_modules,
)
end
def self.new_metaschema_module(metaschema_document, **kw)
new_metaschema(metaschema_document, **kw).jsi_schema_module
end
def self.schema_registry
@schema_registry
end
def self.schema_registry=(schema_registry)
@schema_registry = schema_registry
end
DEFAULT_SCHEMA_REGISTRY = SchemaRegistry.new.tap do |schema_registry|
schema_registry.autoload_uri("http://json-schema.org/draft-04/schema") { JSI::JSONSchemaDraft04.schema }
schema_registry.autoload_uri("http://json-schema.org/draft-06/schema") { JSI::JSONSchemaDraft06.schema }
schema_registry.autoload_uri("http://json-schema.org/draft-07/schema") { JSI::JSONSchemaDraft07.schema }
end.freeze
self.schema_registry = DEFAULT_SCHEMA_REGISTRY.dup
Schema end