Skip to content

Commit 6a4a173

Browse files
authored
Merge pull request #413 from Jack12816/master
Added a fix for the value mapping of an array of objects
2 parents 5a8157a + eb85f2f commit 6a4a173

File tree

1 file changed

+10
-0
lines changed
  • lib/rspec_api_documentation/dsl/endpoint

1 file changed

+10
-0
lines changed

lib/rspec_api_documentation/dsl/endpoint/params.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ def extended
3030
unless p[:value]
3131
cur = extra_params
3232
[*p[:scope]].each { |scope| cur = cur && (cur[scope.to_sym] || cur[scope.to_s]) }
33+
34+
# When the current parameter is an array of objects, we use the
35+
# first one for the value and add a scope indicator. The
36+
# resulting parameter name looks like +props[pictures][][id]+
37+
# this.
38+
if cur.is_a?(Array) && cur.first.is_a?(Hash)
39+
cur = cur.first
40+
param[:scope] << ''
41+
end
42+
3343
p[:value] = cur && (cur[p[:name].to_s] || cur[p[:name].to_sym])
3444
end
3545
p

0 commit comments

Comments
 (0)