Class: Swaggard::Swagger::Parameters::Query

Inherits:
Base
  • Object
show all
Defined in:
lib/swaggard/swagger/parameters/query.rb

Instance Attribute Summary

Attributes inherited from Base

#description, #is_required, #name

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Query

Returns a new instance of Query.



8
9
10
11
# File 'lib/swaggard/swagger/parameters/query.rb', line 8

def initialize(string)
  @in = 'query'
  parse(string)
end

Instance Method Details

#to_docObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/swaggard/swagger/parameters/query.rb', line 13

def to_doc
  schema = @type.to_doc

  if @options.present? && @type.is_array?
    schema['items']['enum'] = @options
  elsif @options.present?
    schema['enum'] = @options
  end

  {
    'name'        => @name,
    'in'          => @in,
    'required'    => @is_required,
    'description' => description,
    'schema'      => schema
  }
end