Skip to content

Commit b4c0fbd

Browse files
committed
Defining and using route.version method instead of route.options[:version].
1 parent 07372f5 commit b4c0fbd

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

lib/grape-swagger/doc_methods/path_string.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ def build(route, options = {})
1313
# set item from path, this could be used for the definitions object
1414
item = route.path.gsub(%r{/{(.+?)}}, '').split('/').last.singularize.underscore.camelize || 'Item'
1515

16-
if route.options[:version] && options[:add_version]
17-
route.path.sub!('{version}', route.options[:version].to_s)
16+
if route.version && options[:add_version]
17+
route.path.sub!('{version}', route.version.to_s)
1818
else
1919
route.path.sub!('/{version}', '')
2020
end

lib/grape-swagger/grape/route.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# backwards compatibility for Grape < 0.16.0
22
module Grape
33
class Route
4-
[:path, :prefix, :entity, :description, :settings, :params, :headers, :http_codes].each do |m|
4+
[:path, :prefix, :entity, :description, :settings, :params, :headers, :http_codes, :version]
5+
.each do |m|
56
define_method m do
67
send "route_#{m}"
78
end

0 commit comments

Comments
 (0)