Skip to content

Commit 7e60504

Browse files
committed
Pass request object to path_string
fix: ruby-grape#935
1 parent a5e2575 commit 7e60504

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

lib/grape-swagger/doc_methods.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def self.output_path_definitions(combi_routes, endpoint, target_class, options)
5050
options
5151
)
5252

53-
paths, definitions = endpoint.path_and_definition_objects(combi_routes, options)
53+
paths, definitions = endpoint.path_and_definition_objects(combi_routes, options, endpoint.request)
5454
tags = tags_from(paths, options)
5555

5656
output[:tags] = tags unless tags.empty? || paths.blank?

lib/grape-swagger/doc_methods/path_string.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ module GrapeSwagger
44
module DocMethods
55
class PathString
66
class << self
7-
def build(route, options = {})
7+
def build(route, options = {}, request = nil)
88
path = route.path.dup
99
# always removing format
1010
path.sub!(/\(\.\w+?\)$/, '')
@@ -25,7 +25,7 @@ def build(route, options = {})
2525
path.sub!('/{version}', '')
2626
end
2727

28-
path = "#{OptionalObject.build(:base_path, options)}#{path}" if options[:add_base_path]
28+
path = "#{OptionalObject.build(:base_path, options, request)}#{path}" if options[:add_base_path]
2929

3030
[item, path.start_with?('/') ? path : "/#{path}"]
3131
end

lib/grape-swagger/endpoint.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ def contact_object(infos)
7676
end
7777

7878
# building path and definitions objects
79-
def path_and_definition_objects(namespace_routes, options)
79+
def path_and_definition_objects(namespace_routes, options, request = nil)
8080
@paths = {}
8181
@definitions = {}
8282
add_definitions_from options[:models]
8383
namespace_routes.each_value do |routes|
84-
path_item(routes, options)
84+
path_item(routes, options, request)
8585
end
8686

8787
[@paths, @definitions]
@@ -94,11 +94,11 @@ def add_definitions_from(models)
9494
end
9595

9696
# path object
97-
def path_item(routes, options)
97+
def path_item(routes, options, request = nil)
9898
routes.each do |route|
9999
next if hidden?(route, options)
100100

101-
@item, path = GrapeSwagger::DocMethods::PathString.build(route, options)
101+
@item, path = GrapeSwagger::DocMethods::PathString.build(route, options, request)
102102
@entity = route.entity || route.options[:success]
103103

104104
verb, method_object = method_object(route, options, path)

0 commit comments

Comments
 (0)