Commit fcd9706f by andrew morton

Add helper for setting tags

parent c3f38ff9
...@@ -107,7 +107,7 @@ module RSpec ...@@ -107,7 +107,7 @@ module RSpec
operation[:parameters] = prepare_parameters(swagger_operation[:parameters]) operation[:parameters] = prepare_parameters(swagger_operation[:parameters])
end end
operation.merge!(swagger_operation.slice( operation.merge!(swagger_operation.slice(
:summary, :description, :externalDocs, :operationId, :tags, :summary, :description, :externalDocs, :operationId,
:consumes, :produces, :schemes, :deprecated, :security :consumes, :produces, :schemes, :deprecated, :security
)) ))
end end
......
...@@ -174,6 +174,10 @@ module RSpec ...@@ -174,6 +174,10 @@ module RSpec
metadata[:swagger_operation][:produces] = mime_types metadata[:swagger_operation][:produces] = mime_types
end end
def tags *tags
metadata[:swagger_operation][:tags] = tags
end
def response status_code, attributes = {}, &block def response status_code, attributes = {}, &block
attributes.symbolize_keys! attributes.symbolize_keys!
......
...@@ -186,6 +186,36 @@ RSpec.describe RSpec::Rails::Swagger::Helpers::Operation do ...@@ -186,6 +186,36 @@ RSpec.describe RSpec::Rails::Swagger::Helpers::Operation do
end end
subject { klass.new } subject { klass.new }
describe '#consumes' do
before { subject.metadata = {swagger_operation: {}} }
it 'accepts an array' do
subject.consumes('foo', 'bar')
expect(subject.metadata[:swagger_operation][:consumes]).to eq ['foo', 'bar']
end
end
describe '#produces' do
before { subject.metadata = {swagger_operation: {}} }
it 'accepts an array' do
subject.produces('foo', 'bar')
expect(subject.metadata[:swagger_operation][:produces]).to eq ['foo', 'bar']
end
end
describe '#tags' do
before { subject.metadata = {swagger_operation: {}} }
it 'accepts an array' do
subject.tags('foo', 'bar')
expect(subject.metadata[:swagger_operation][:tags]).to eq ['foo', 'bar']
end
end
describe '#response' do describe '#response' do
before { subject.metadata = {swagger_object: :operation} } before { subject.metadata = {swagger_object: :operation} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment