Module: Dry::Schema::JSONSchema::SchemaMethods

Included in:
Processor
Defined in:
lib/dry/schema/extensions/json_schema.rb

Instance Method Summary collapse

Instance Method Details

#json_schema(loose: false) ⇒ Hash<Symbol=>Hash>

Convert the schema into a JSON schema hash

Parameters:

  • loose (Symbol) (defaults to: false)

    Compile the schema in “loose” mode

Returns:

  • (Hash<Symbol=>Hash>)


19
20
21
22
23
# File 'lib/dry/schema/extensions/json_schema.rb', line 19

def json_schema(loose: false)
  compiler = SchemaCompiler.new(root: true, loose: loose)
  compiler.call(to_ast)
  compiler.to_hash
end