Module: Dry::Types::Builder

Defined in:
lib/dry/types/extensions/json_schema.rb

Overview

The ‘Builder` module provides a method to generate a JSON Schema hash from dry-types definitions.

Instance Method Summary collapse

Instance Method Details

#json_schema(options = {}) ⇒ Hash

Returns The generated JSON Schema as a hash.

Parameters:

  • options (Hash) (defaults to: {})

    Initialization options passed to ‘JSONSchema.new`

Returns:

  • (Hash)

    The generated JSON Schema as a hash.



317
318
319
320
321
# File 'lib/dry/types/extensions/json_schema.rb', line 317

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