mirror of
https://github.com/ditkrg/rswag.git
synced 2026-01-25 07:16:40 +00:00
Allow tests to be run without generating docs
By providing the 'document: false' metadata, tests will be run but no swagger documentation will be generated for the tagged example groups. It works on all kinds of example groups (responses, verbs, paths etc..).
This commit is contained in:
@@ -25,7 +25,11 @@ module Rswag
|
||||
metadata = notification.metadata
|
||||
end
|
||||
|
||||
# !metadata[:document] won't work, since nil means we should generate
|
||||
# docs.
|
||||
return if metadata[:document] == false
|
||||
return unless metadata.has_key?(:response)
|
||||
|
||||
swagger_doc = @config.get_swagger_doc(metadata[:swagger_doc])
|
||||
swagger_doc.deep_merge!(metadata_to_swagger(metadata))
|
||||
end
|
||||
|
||||
@@ -26,23 +26,37 @@ module Rswag
|
||||
{
|
||||
path_item: { template: '/blogs' },
|
||||
operation: { verb: :post, summary: 'Creates a blog' },
|
||||
response: { code: '201', description: 'blog created' }
|
||||
response: { code: '201', description: 'blog created' },
|
||||
document: document
|
||||
}
|
||||
end
|
||||
|
||||
it 'converts to swagger and merges into the corresponding swagger doc' do
|
||||
expect(swagger_doc).to match(
|
||||
paths: {
|
||||
'/blogs' => {
|
||||
post: {
|
||||
summary: 'Creates a blog',
|
||||
responses: {
|
||||
'201' => { description: 'blog created' }
|
||||
context 'with the document tag set to false' do
|
||||
let(:document) { false }
|
||||
|
||||
it 'does not update the swagger doc' do
|
||||
expect(swagger_doc).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
context 'with the document tag set to anything but false' do
|
||||
# anything works, including its absence when specifying responses.
|
||||
let(:document) { nil }
|
||||
|
||||
it 'converts to swagger and merges into the corresponding swagger doc' do
|
||||
expect(swagger_doc).to match(
|
||||
paths: {
|
||||
'/blogs' => {
|
||||
post: {
|
||||
summary: 'Creates a blog',
|
||||
responses: {
|
||||
'201' => { description: 'blog created' }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user