Skip to content

Commit f93b48a

Browse files
committed
Use the version from route when tagging endpoints
1 parent 9177a28 commit f93b48a

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

lib/grape-swagger/endpoint.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ def method_object(route, options, path)
109109
method[:consumes] = consumes_object(route, options[:format])
110110
method[:parameters] = params_object(route)
111111
method[:responses] = response_object(route, options[:markdown])
112-
method[:tags] = tag_object(route, options[:version].to_s)
112+
method[:tags] = tag_object(route)
113113
method[:operationId] = GrapeSwagger::DocMethods::OperationId.build(route, path)
114114
method.delete_if { |_, value| value.blank? }
115115

@@ -194,8 +194,8 @@ def response_object(route, markdown)
194194
end
195195
end
196196

197-
def tag_object(route, version)
198-
Array(route.path.split('{')[0].split('/').reject(&:empty?).delete_if { |i| ((i == route.prefix.to_s) || (i == version)) }.first)
197+
def tag_object(route)
198+
Array(route.path.split('{')[0].split('/').reject(&:empty?).delete_if { |i| ((i == route.prefix.to_s) || (i == route.version)) }.first)
199199
end
200200

201201
private

spec/swagger_v2/endpoint_versioned_path_spec.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
end
2727

2828
it 'tags the endpoint with the resource name' do
29-
pending 'BUG: This is set to the first part of the path'
30-
expect(subject.first['/v1/item'][:get][:tags]).to eq ['items']
29+
expect(subject.first['/v1/item'][:get][:tags]).to eq ['item']
3130
end
3231
end

0 commit comments

Comments
 (0)