Class: GrapeSwagger::Endpoint::ParamsParser

Inherits:
Object
  • Object
show all
Defined in:
lib/grape-swagger/endpoint/params_parser.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params, settings, endpoint) ⇒ ParamsParser

Returns a new instance of ParamsParser.



12
13
14
15
16
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 12

def initialize(params, settings, endpoint)
  @params = params
  @settings = settings
  @endpoint = endpoint
end

Instance Attribute Details

#endpointObject (readonly)

Returns the value of attribute endpoint.



6
7
8
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 6

def endpoint
  @endpoint
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 6

def params
  @params
end

#settingsObject (readonly)

Returns the value of attribute settings.



6
7
8
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 6

def settings
  @settings
end

Class Method Details

.parse_request_params(params, settings, endpoint) ⇒ Object



8
9
10
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 8

def self.parse_request_params(params, settings, endpoint)
  new(params, settings, endpoint).parse_request_params
end

Instance Method Details

#parse_request_paramsObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/grape-swagger/endpoint/params_parser.rb', line 18

def parse_request_params
  public_params.each_with_object({}) do |(name, options), memo|
    name = name.to_s
    param_type = options[:type]
    param_type = param_type.to_s unless param_type.nil?

    if param_type_is_array?(param_type)
      options[:is_array] = true
      name += '[]' if array_use_braces?
    end

    memo[name] = options
  end
end