Skip to content

Commit 97d40c2

Browse files
coverSilvio
authored and
Silvio
committed
Allow to set scoped params that are present in the path
1 parent db1d8c8 commit 97d40c2

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

lib/rspec_api_documentation/dsl/endpoint.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,12 @@ def delete_extra_param(key)
148148

149149
def set_param(hash, param)
150150
key = param[:name]
151-
return hash if in_path?(key)
152151

153152
keys = [param[:scope], key].flatten.compact
154153
method_name = keys.join('_')
155154

155+
return hash if in_path?(method_name)
156+
156157
unless respond_to?(method_name)
157158
method_name = key
158159
return hash unless respond_to?(method_name)

spec/dsl_spec.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@
105105
put "/orders/:id" do
106106
parameter :type, "The type of drink you want.", :required => true
107107
parameter :size, "The size of drink you want.", :required => true
108+
parameter :id, 'The ID of the resource.', :required => true, scope: :data
108109
parameter :note, "Any additional notes about your order."
109110

110111
let(:type) { "coffee" }
111112
let(:size) { "medium" }
113+
let(:data_id) { 2 }
112114

113115
let(:id) { 1 }
114116

@@ -129,6 +131,10 @@
129131
end
130132
end
131133

134+
it 'should set the scoped data ID' do
135+
expect(params['data']).to eq({'id' => 2})
136+
end
137+
132138
it "should allow extra parameters to be passed in" do
133139
expect(client).to receive(method).with(path, params.merge("extra" => true), nil)
134140
do_request(:extra => true)

0 commit comments

Comments
 (0)