Module: OpenapiParameters::Converters

Defined in:
lib/openapi_parameters/converters.rb

Overview

Home for all converters

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.convertersObject (readonly)

Returns the value of attribute converters.



9
10
11
# File 'lib/openapi_parameters/converters.rb', line 9

def converters
  @converters
end

Class Method Details

.[](schema) ⇒ Object



15
16
17
18
19
20
# File 'lib/openapi_parameters/converters.rb', line 15

def [](schema)
  type = schema && schema['type']
  converters.fetch(type) do
    ->(value) { Converter.convert(value, schema) }
  end
end

.register(type, converter) ⇒ Object



11
12
13
# File 'lib/openapi_parameters/converters.rb', line 11

def register(type, converter)
  converters[type] = converter
end