Module: Mountapi::Schema

Defined in:
lib/mountapi/schema.rb,
lib/mountapi/schema/base.rb,
lib/mountapi/schema/array.rb,
lib/mountapi/schema/number.rb,
lib/mountapi/schema/object.rb,
lib/mountapi/schema/string.rb,
lib/mountapi/schema/boolean.rb,
lib/mountapi/schema/integer.rb,
lib/mountapi/schema/validator.rb

Defined Under Namespace

Modules: Base Classes: Array, Boolean, Integer, Number, Object, String, Validator

Class Method Summary collapse

Class Method Details

.build(open_api_schema) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/mountapi/schema.rb', line 10

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