Skip to content

Commit

Permalink
ruby-grape#91 Filter out params which exist only due to nested params
Browse files Browse the repository at this point in the history
  • Loading branch information
davetapley committed Sep 19, 2014
1 parent 791943c commit 47168a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/grape-swagger.rb
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,13 @@ def as_markdown(description)

def parse_params(params, path, method)
params ||= []
params.map do |param, value|

non_nested_parent_params = params.reject do |param, _|
is_nested_param = /^#{ Regexp.quote param }\[.+\]$/
params.keys.any? { |p| p.match is_nested_param }
end

non_nested_parent_params.map do |param, value|
value[:type] = 'File' if value.is_a?(Hash) && ['Rack::Multipart::UploadedFile', 'Hash'].include?(value[:type])
items = {}

Expand Down

0 comments on commit 47168a4

Please sign in to comment.