Module: RspecApiDocumentation::OpenApi::Helper

Defined in:
lib/rspec_api_documentation/open_api/helper.rb

Class Method Summary collapse

Class Method Details

.extract_items(value, opts = {}) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/rspec_api_documentation/open_api/helper.rb', line 18

def extract_items(value, opts = {})
  result = {type: extract_type(value)}
  if result[:type] == :array
    result[:items] = extract_items(value[0], opts)
  else
    opts.each { |k, v| result[k] = v if v }
  end
  result
end

.extract_type(value) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/rspec_api_documentation/open_api/helper.rb', line 6

def extract_type(value)
  case value
  when Rack::Test::UploadedFile then :file
  when Array then :array
  when Hash then :object
  when TrueClass, FalseClass then :boolean
  when Integer then :integer
  when Float then :number
  else :string
  end
end