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:
28
README.md
28
README.md
@@ -454,12 +454,30 @@ end
|
||||
|
||||
### Running tests without documenting ###
|
||||
|
||||
If you want to use Rswag for testing without adding it to you swagger docs, you can simply nullify the response metadata after the test run.
|
||||
|
||||
If you want to use Rswag for testing without adding it to you swagger docs, you can provide the document tag:
|
||||
```ruby
|
||||
after do |example|
|
||||
example.metadata[:response] = null
|
||||
end
|
||||
describe 'Blogs API' do
|
||||
path '/blogs/{blog_id}' do
|
||||
get 'Retrieves a blog' do
|
||||
# documentation is now disabled for this response only
|
||||
response 200, 'blog found', document: false do
|
||||
...
|
||||
```
|
||||
|
||||
You can also reenable documentation for specific responses only:
|
||||
```ruby
|
||||
# documentation is now disabled
|
||||
describe 'Blogs API', document: false do
|
||||
path '/blogs/{blog_id}' do
|
||||
get 'Retrieves a blog' do
|
||||
# documentation is reenabled for this response only
|
||||
response 200, 'blog found', document: true do
|
||||
...
|
||||
end
|
||||
|
||||
response 401, 'special case' do
|
||||
...
|
||||
end
|
||||
```
|
||||
|
||||
### Route Prefix for Swagger JSON Endpoints ###
|
||||
|
||||
Reference in New Issue
Block a user