Class: Cocina::JsonSchemaWrapper

Inherits:
Object
  • Object
show all
Defined in:
lib/cocina/json_schema_wrapper.rb

Overview

Wrapper for JSON Schema support using json_schemer

Defined Under Namespace

Classes: MissingReferenceError, OpenApiError, SchemaWrapper

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(spec_hash, strict_reference_validation: true) ⇒ JsonSchemaWrapper

Returns a new instance of JsonSchemaWrapper.



9
10
11
12
13
14
15
# File 'lib/cocina/json_schema_wrapper.rb', line 9

def initialize(spec_hash, strict_reference_validation: true)
  @spec = spec_hash
  @strict_reference_validation = strict_reference_validation
  @schemas = {}
  @schema_validators = {}
  initialize_schemas
end

Instance Attribute Details

#schemasObject (readonly)

Returns the value of attribute schemas.



21
22
23
# File 'lib/cocina/json_schema_wrapper.rb', line 21

def schemas
  @schemas
end

#specObject (readonly)

Returns the value of attribute spec.



21
22
23
# File 'lib/cocina/json_schema_wrapper.rb', line 21

def spec
  @spec
end

Class Method Details

.parse(spec_hash, strict_reference_validation: true) ⇒ Object



17
18
19
# File 'lib/cocina/json_schema_wrapper.rb', line 17

def self.parse(spec_hash, strict_reference_validation: true)
  new(spec_hash, strict_reference_validation:)
end