diff --git a/lib/grape-swagger/endpoint.rb b/lib/grape-swagger/endpoint.rb index 6d83976b..70a8a8ea 100644 --- a/lib/grape-swagger/endpoint.rb +++ b/lib/grape-swagger/endpoint.rb @@ -123,7 +123,7 @@ def method_object(route, options, path) method[:parameters] = params_object(route, options, path, method[:consumes]) method[:security] = security_object(route) method[:responses] = response_object(route, options) - method[:tags] = route.tags || tag_object(route, path) + method[:tags] = route.options.key?(:tags) ? route.tags : tag_object(route, path) method[:operationId] = GrapeSwagger::DocMethods::OperationId.build(route, path) method[:deprecated] = deprecated_object(route) method.delete_if { |_, value| value.nil? } diff --git a/spec/swagger_v2/endpoint_versioned_path_spec.rb b/spec/swagger_v2/endpoint_versioned_path_spec.rb index 0a2d84e9..d6cc2f1b 100644 --- a/spec/swagger_v2/endpoint_versioned_path_spec.rb +++ b/spec/swagger_v2/endpoint_versioned_path_spec.rb @@ -53,6 +53,23 @@ end end + context 'when tags are explicitly set to nil' do + let(:item) do + Class.new(Grape::API) do + version 'v1', using: :path + + resource :item do + desc 'Item description', tags: nil + get '/' + end + end + end + + it 'omits the tags key instead of falling back to the default tag' do + expect(subject.first['/v1/item'][:get]).not_to have_key(:tags) + end + end + context 'when parameter with a custom type is specified' do let(:item) do Class.new(Grape::API) do