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.



308
309
310
311
312
# File 'lib/dry/types/extensions/json_schema.rb', line 308

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