diff --git a/lib/rspec_api_documentation/dsl/endpoint/params.rb b/lib/rspec_api_documentation/dsl/endpoint/params.rb index 63d7d752..a5e07bf2 100644 --- a/lib/rspec_api_documentation/dsl/endpoint/params.rb +++ b/lib/rspec_api_documentation/dsl/endpoint/params.rb @@ -29,15 +29,18 @@ def extended p[:value] = SetParam.new(self, nil, p).value 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] << '' + + [*p[:scope]].each do |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 + p[:scope] << '' + end end p[:value] = cur && (cur[p[:name].to_s] || cur[p[:name].to_sym]) @@ -49,7 +52,6 @@ def extended private attr_reader :extra_params - end end end