Class: GrapeSwagger::DocMethods::ParseParams

Inherits:
Object
  • Object
show all
Defined in:
lib/grape-swagger/doc_methods/parse_params.rb

Class Method Summary collapse

Class Method Details

.call(param, settings, path, route, definitions, consumes) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/grape-swagger/doc_methods/parse_params.rb', line 7

def call(param, settings, path, route, definitions, consumes)
  method = route.request_method
  additional_documentation = settings.fetch(:documentation, {})
  settings.merge!(additional_documentation)
  data_type = DataType.call(settings)

  value_type = settings.merge(data_type: data_type, path: path, param_name: param, method: method)

  # required properties
  @parsed_param = {
    in: param_type(value_type, consumes),
    name: settings[:full_name] || param
  }

  # optional properties
  document_description(settings)
  document_type_and_format(settings, data_type)
  document_array_param(value_type, definitions, consumes) if value_type[:is_array]
  document_default_value(settings) unless value_type[:is_array]
  document_range_values(settings) unless value_type[:is_array]
  document_required(settings)
  document_additional_properties(definitions, settings) unless value_type[:is_array]
  document_add_extensions(settings)
  document_example(settings) if @parsed_param[:in] == 'body'

  @parsed_param
end