module RspecApiDocumentation::OpenApi::Helper

Public Instance Methods

extract_items(value, opts = {}) click to toggle source
# 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) click to toggle source
# 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