Sha256: 1dd78fce5d82161311ccb0431207b9a84cb461c659595e158a515821cf8c8960

Contents?: true

Size: 683 Bytes

Versions: 21

Compression:

Stored size: 683 Bytes

Contents

# frozen_string_literal: true

require "dry/schema/extensions/json_schema/schema_compiler"

module Dry
  module Schema
    # JSONSchema extension
    #
    # @api public
    module JSONSchema
      module SchemaMethods
        # Convert the schema into a JSON schema hash
        #
        # @param [Symbol] loose Compile the schema in "loose" mode
        #
        # @return [Hash<Symbol=>Hash>]
        #
        # @api public
        def json_schema(loose: false)
          compiler = SchemaCompiler.new(root: true, loose: loose)
          compiler.call(to_ast)
          compiler.to_hash
        end
      end
    end

    Processor.include(JSONSchema::SchemaMethods)
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
dry-schema-1.14.0 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.13.3 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.13.2 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.13.1 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.13.0 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.12.0 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.11.3 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.11.2 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.11.1 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.11.0 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.10.6 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.10.5 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.10.4 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.10.3 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.10.2 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.10.1 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.9.3 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.9.2 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.9.1 lib/dry/schema/extensions/json_schema.rb
dry-schema-1.9.0 lib/dry/schema/extensions/json_schema.rb