File tree Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Expand file tree Collapse file tree 3 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 15
15
* [ #1365 ] ( https://github.com/ruby-grape/grape/pull/1365 ) : Fix finding exception handler in error middleware - [ @ktimothy ] ( https://github.com/ktimothy ) .
16
16
* [ #1380 ] ( https://github.com/ruby-grape/grape/pull/1380 ) : Fix ` allow_blank: false ` for ` Time ` attributes with valid values causes ` NoMethodError ` - [ @ipkes ] ( https://github.com/ipkes ) .
17
17
* [ #1384 ] ( https://github.com/ruby-grape/grape/pull/1384 ) : Fix parameter validation with an empty optional nested ` Array ` - [ @ipkes ] ( https://github.com/ipkes ) .
18
+ * [ #1414 ] ( https://github.com/ruby-grape/grape/pull/1414 ) : Fix multiple version definitions for path versioning - [ @304 ] ( https://github.com/304 ) .
18
19
19
20
0.16.2 (4/12/2016)
20
21
==================
Original file line number Diff line number Diff line change @@ -30,20 +30,21 @@ def version(*args, &block)
30
30
if args . any?
31
31
options = args . extract_options!
32
32
options = options . reverse_merge ( using : :path )
33
+ requested_versions = args . flatten
33
34
34
35
raise Grape ::Exceptions ::MissingVendorOption . new if options [ :using ] == :header && !options . key? ( :vendor )
35
36
36
- @versions = versions | args
37
+ @versions = versions | requested_versions
37
38
38
39
if block_given?
39
40
within_namespace do
40
- namespace_inheritable ( :version , args )
41
+ namespace_inheritable ( :version , requested_versions )
41
42
namespace_inheritable ( :version_options , options )
42
43
43
44
instance_eval ( &block )
44
45
end
45
46
else
46
- namespace_inheritable ( :version , args )
47
+ namespace_inheritable ( :version , requested_versions )
47
48
namespace_inheritable ( :version_options , options )
48
49
end
49
50
end
Original file line number Diff line number Diff line change @@ -302,16 +302,27 @@ def subject.enable_root_route!
302
302
303
303
describe 'path versioned APIs' do
304
304
before do
305
- subject . version 'v1' , using : :path
305
+ subject . version version , using : :path
306
306
subject . enable_root_route!
307
307
end
308
308
309
- it 'without a format' do
310
- versioned_get '/' , 'v1' , using : :path
309
+ context 'when a single version provided' do
310
+ let ( :version ) { 'v1' }
311
+
312
+ it 'without a format' do
313
+ versioned_get '/' , 'v1' , using : :path
314
+ end
315
+
316
+ it 'with a format' do
317
+ get '/v1/.json'
318
+ end
311
319
end
312
320
313
- it 'with a format' do
314
- get '/v1/.json'
321
+ context 'when array of versions provided' do
322
+ let ( :version ) { %w( v1 v2 ) }
323
+
324
+ it { versioned_get '/' , 'v1' , using : :path }
325
+ it { versioned_get '/' , 'v2' , using : :path }
315
326
end
316
327
end
317
328
You can’t perform that action at this time.
0 commit comments