Sha256: d5eca97f3f48ac674850cbc4549cfc4af345e12a533dfe005a0e5257924307e2

Contents?: true

Size: 671 Bytes

Versions: 1

Compression:

Stored size: 671 Bytes

Contents

# frozen_string_literal: true

require "dry/schema/extensions/open_api/schema_compiler"

module Dry
  module Schema
    # JSONSchema extension
    #
    # @api public
    module OpenAPI
      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 open_api(loose: false)
          compiler = SchemaCompiler.new(root: true, loose: loose)
          compiler.call(to_ast)
          compiler.to_hash
        end
      end
    end

    Processor.include(OpenAPI::SchemaMethods)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
dry-schema-extensions-1.0.0 lib/dry/schema/extensions/open_api.rb