Sha256: b12b23c24daf164ba9dd3f1b9fa1c33a54ede5fb3274d5c37f7f568031f209b2

Contents?: true

Size: 716 Bytes

Versions: 1

Compression:

Stored size: 716 Bytes

Contents

require "mountapi/schema/string"
require "mountapi/schema/integer"
require "mountapi/schema/object"
require "mountapi/schema/array"
require "mountapi/schema/number"
require "mountapi/schema/boolean"

module Mountapi
  module Schema
    def self.build(open_api_schema)
      type = open_api_schema&.type&.to_sym || :string

      case type
      when :integer
        Schema::Integer
      when :string
        Schema::String
      when :object
        Schema::Object
      when :number
        Schema::Number
      when :boolean
        Schema::Boolean
      when :array
        Schema::Array
      else
        raise ArgumentError, "unknown parameter type: #{type}"
      end.new(open_api_schema)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mountapi-0.11.1 lib/mountapi/schema.rb