Skip to content

Commit

Permalink
Merge pull request #413 from Jack12816/master
Browse files Browse the repository at this point in the history
Added a fix for the value mapping of an array of objects
  • Loading branch information
oestrich authored Oct 7, 2018
2 parents 5a8157a + eb85f2f commit 6a4a173
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/rspec_api_documentation/dsl/endpoint/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ def extended
unless p[:value]
cur = extra_params
[*p[:scope]].each { |scope| cur = cur && (cur[scope.to_sym] || cur[scope.to_s]) }

# When the current parameter is an array of objects, we use the
# first one for the value and add a scope indicator. The
# resulting parameter name looks like +props[pictures][][id]+
# this.
if cur.is_a?(Array) && cur.first.is_a?(Hash)
cur = cur.first
param[:scope] << ''
end

p[:value] = cur && (cur[p[:name].to_s] || cur[p[:name].to_sym])
end
p
Expand Down

0 comments on commit 6a4a173

Please sign in to comment.