File tree Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Expand file tree Collapse file tree 3 files changed +11
-5
lines changed Original file line number Diff line number Diff line change 13
13
* [ #2137 ] ( https://github.com/ruby-grape/grape/pull/2137 ) : Fix typos - [ @johnny-miyake ] ( https://github.com/johnny-miyake ) .
14
14
* [ #2131 ] ( https://github.com/ruby-grape/grape/pull/2131 ) : Fix Ruby 2.7 keyword deprecation warning in validators/coerce - [ @K0H205 ] ( https://github.com/K0H205 ) .
15
15
* [ #2132 ] ( https://github.com/ruby-grape/grape/pull/2132 ) : Use #ruby2_keywords for correct delegation on Ruby <= 2.6, 2.7 and 3 - [ @eregon ] ( https://github.com/eregon ) .
16
+ * [ #2152 ] ( https://github.com/ruby-grape/grape/pull/2152 ) : Fix configuration method inside namespaced params - [ @fsainz ] ( https://github.com/fsainz ) .
16
17
17
18
### 1.5.1 (2020/11/15)
18
19
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def initialize(opts, &block)
39
39
end
40
40
41
41
def configuration
42
- @api . configuration . evaluate
42
+ @api . configuration . respond_to? ( : evaluate) ? @api . configuration . evaluate : @api . configuration
43
43
end
44
44
45
45
# @return [Boolean] whether or not this entire scope needs to be
Original file line number Diff line number Diff line change @@ -340,19 +340,24 @@ def app
340
340
context 'when the configuration is read within a namespace' do
341
341
before do
342
342
a_remounted_api . namespace 'api' do
343
+ params do
344
+ requires configuration [ :required_param ]
345
+ end
343
346
get "/#{ configuration [ :path ] } " do
344
347
'10 votes'
345
348
end
346
349
end
347
- root_api . mount a_remounted_api , with : { path : 'votes' }
348
- root_api . mount a_remounted_api , with : { path : 'scores' }
350
+ root_api . mount a_remounted_api , with : { path : 'votes' , required_param : 'param_key' }
351
+ root_api . mount a_remounted_api , with : { path : 'scores' , required_param : 'param_key' }
349
352
end
350
353
351
354
it 'will use the dynamic configuration on all routes' do
352
- get 'api/votes'
355
+ get 'api/votes' , param_key : 'a'
353
356
expect ( last_response . body ) . to eql '10 votes'
354
- get 'api/scores'
357
+ get 'api/scores' , param_key : 'a'
355
358
expect ( last_response . body ) . to eql '10 votes'
359
+ get 'api/votes'
360
+ expect ( last_response . status ) . to eq 400
356
361
end
357
362
end
358
363
You can’t perform that action at this time.
0 commit comments