Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 12 additions & 10 deletions lib/rspec_api_documentation/dsl/endpoint/params.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand All @@ -49,7 +52,6 @@ def extended
private

attr_reader :extra_params

end
end
end
Expand Down