Class: GrapeSwagger::RequestParamParsers::Body

Inherits:
Object
  • Object
show all
Defined in:
lib/grape-swagger/request_param_parsers/body.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(_route, params, settings, endpoint) ⇒ Body

Returns a new instance of Body.



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

def initialize(_route, 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/request_param_parsers/body.rb', line 6

def endpoint
  @endpoint
end

#paramsObject (readonly)

Returns the value of attribute params.



6
7
8
# File 'lib/grape-swagger/request_param_parsers/body.rb', line 6

def params
  @params
end

#routeObject (readonly)

Returns the value of attribute route.



6
7
8
# File 'lib/grape-swagger/request_param_parsers/body.rb', line 6

def route
  @route
end

#settingsObject (readonly)

Returns the value of attribute settings.



6
7
8
# File 'lib/grape-swagger/request_param_parsers/body.rb', line 6

def settings
  @settings
end

Class Method Details

.parse(route, params, settings, endpoint) ⇒ Object



8
9
10
# File 'lib/grape-swagger/request_param_parsers/body.rb', line 8

def self.parse(route, params, settings, endpoint)
  new(route, params, settings, endpoint).parse
end

Instance Method Details

#parseObject



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

def parse
  public_params.each_with_object({}) do |(name, options), memo|
    name = name.to_s
    param_type = options[:type]&.to_s

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

    memo[name] = options
  end
end