110 Commits
2.0.0 ... 2.2.0

Author SHA1 Message Date
Greg Myers
a46a5be3bb Use presence on tags in travis 2019-11-02 16:55:21 +00:00
Greg Myers
ccce4d6360 Fix travis.yml 2019-11-02 16:11:42 +00:00
Greg Myers
663294b84b Merge pull request #251 from BookOfGreg/improved-yaml-support
Improved yaml support
2019-11-02 16:09:50 +00:00
Greg Myers
889dd0922a Merge branch 'master' into improved-yaml-support 2019-11-02 16:03:11 +00:00
Greg Myers
99281f96be Merge pull request #252 from BookOfGreg/speedup-travis
Use a prebuilt ruby
2019-11-02 16:02:51 +00:00
Greg Myers
3dc0909a6a Use specific directory. We dont bundle to vendor/bundle 2019-11-02 15:59:48 +00:00
Greg Myers
dad99930aa trigger build 2019-11-02 15:56:08 +00:00
Greg Myers
c108a8367c try conditional stages 2019-11-02 15:48:29 +00:00
Greg Myers
8d8fc11e55 correct ruby-version for travis 2019-11-02 15:35:51 +00:00
Greg Myers
8d04646341 Cache the correct directory 2019-11-02 15:09:21 +00:00
Greg Myers
f8fb73fb14 Use a prebuilt ruby
https://docs.travis-ci.com/user/reference/bionic/
Pre-installed Rubies: 2.3.8, 2.4.5, 2.5.3 and 2.6.3.
2019-11-02 15:03:45 +00:00
Greg Myers
4516ad4b78 Update changelog and tweak readme 2019-11-02 14:52:37 +00:00
Greg Myers
2d5da62bf1 CHANGELOG.md 2019-11-02 14:02:31 +00:00
Greg Myers
dc161fe275 Serve yaml files as yaml instead of converting them to json 2019-11-02 13:57:47 +00:00
Greg Myers
eeb1026691 Fix invalid Swagger in YAML values
The original fix failed because though the Keys were now strings, some
of the values for path variables were also symbols.
Psych does have a safe_load which has a whitelist of classes but it does
not have a safe_dump mode. We could have used deep_transform_values and
manually converted the classes we did not want, but why risk a buggy
implementation when JSON.generate works just fine?
2019-11-02 13:13:06 +00:00
Greg Myers
2c0f3c9396 Fix invalid Swagger in YAML 2019-11-02 12:58:36 +00:00
Greg Myers
acab437a7d Add failing test showing Psych errors 2019-11-02 12:55:09 +00:00
Greg Myers
3ff1de5d65 Update changelog 2019-11-02 11:40:07 +00:00
Greg Myers
0e04635b15 Write the files using specified format 2019-11-02 11:19:01 +00:00
Greg Myers
73b84101cc Adding yaml as option for generator
New installations will get :yaml as it's default with openapi 3 as the
version. Old installations will have the key missing and will default
to :json with an easy upgrade path.
2019-11-02 10:45:38 +00:00
Greg Myers
2cf6812ae0 Update README.md 2019-10-19 21:39:24 +01:00
Greg Myers
90d7fada85 Merge pull request #249 from BookOfGreg/fix/swagger-generator
Point the railtie to the correct file
2019-10-18 23:28:43 +01:00
Greg Myers
c14f72a45e Point the railtie to the correct file
Fixes #248
2019-10-18 23:18:32 +01:00
Greg Myers
9722419647 Merge pull request #180 from fishpercolator/default_swaggerize
Add a 'rake rswag' that runs swaggerize as the default
2019-10-17 22:35:50 +01:00
Greg Myers
bf6bd59094 Merge pull request #247 from laurawatson/swaggerize-task
Update README
2019-10-17 18:28:37 +01:00
Laura Watson
ea2ed6ca49 Update README 2019-10-17 17:18:27 +01:00
Greg Myers
d12c018cb7 Merge pull request #246 from laurawatson/pr-template
PR & Issue templates
2019-10-17 16:54:22 +01:00
Greg Myers
d84a89510d Merge pull request #190 from bclewis1/allow-yaml-parsing-in-rswag-api
Allow parsing of yml swagger files in rswag-api
2019-10-17 16:53:11 +01:00
Laura Watson
8d7385fcac update copy 2019-10-17 16:22:12 +01:00
Laura Watson
a18d9e5163 update copy 2019-10-17 14:36:25 +01:00
Laura Watson
5b1dde772a Update pr template 2019-10-17 14:27:07 +01:00
Laura Watson
29becf98f8 add issue templates 2019-10-17 14:16:46 +01:00
Laura Watson
1d5ed8345f add a PR template 2019-10-17 13:37:36 +01:00
Laura Watson
71423cffb6 Merge branch 'master' of github.com:rswag/rswag 2019-10-17 13:34:54 +01:00
Greg Myers
0def9fad6f Merge pull request #152 from DocSpring/fix_irb_context_warning
Call disable_monkey_patching! for RSpec configuration, to fix IRB context warning in Rails console
2019-10-17 10:47:59 +01:00
Nathan Broadbent
e5eb44191c Use RSpec.describe to fix IRB context warning in Rails console 2019-10-17 16:40:31 +07:00
Greg Myers
28245d4dd0 Update README.md 2019-10-17 10:02:24 +01:00
Greg Myers
07c4c74d75 Update changelog 2019-10-17 00:02:09 +01:00
Greg Myers
b1e089af6a Merge pull request #204 from stefanosx/patch-1
Update README.md
2019-10-16 23:45:53 +01:00
Greg Myers
47eb1e49ee Merge pull request #245 from BookOfGreg/feature/spec_generator
Feature/spec generator
2019-10-16 23:30:08 +01:00
Greg Myers
4d29e09010 Add spec generator test 2019-10-16 23:19:24 +01:00
Greg Myers
189a7ef061 Move spec generator files, organize whitespace in generator output 2019-10-16 22:05:14 +01:00
Greg Myers
5ee880b769 Merge branch 'feature/request_spec_generator' 2019-10-16 21:12:51 +01:00
Greg Myers
778d250385 Split file join path 2019-10-16 21:12:36 +01:00
Greg Myers
dd2eaf2feb Merge pull request #75 from paulccarey/feature/request_spec_generator
adds request spec generator (shamelessly stollen from rspec-rails-swagger)
2019-10-16 21:11:20 +01:00
Greg Myers
77d00407a4 whitespace linting 2019-10-16 20:51:53 +01:00
Greg Myers
8b61984fb3 Merge branch 'master' into feature/request_spec_generator 2019-10-16 20:44:11 +01:00
Greg Myers
3542cd0857 Add a Sprockets 4 manifest
Fix #243
2019-10-14 22:17:12 +01:00
Greg Myers
69edcd1be6 Merge branch 'master' into allow-yaml-parsing-in-rswag-api 2019-10-14 21:41:18 +01:00
Greg Myers
b41d4e1276 Merge pull request #240 from hdpuk86/update-swagger-ui-to-3.18.2
update swagger ui to 3.18.2
2019-10-08 23:54:14 +01:00
Hayley
dc2ebd94bb update swagger ui to 3.18.2 2019-10-08 16:18:55 +01:00
Greg Myers
17d7e020e8 Merge pull request #237 from PMGH/master
Add options and trace verbs
2019-10-05 20:35:48 +01:00
Laura Watson
57da84d055 add options and trace 2019-10-04 14:52:47 +01:00
Peter McCready
5c9154864e add options and trace verbs 2019-10-04 14:51:41 +01:00
Greg Myers
0246ff164f Update readme 2019-10-03 23:00:27 +01:00
Greg Myers
f4ba3266ba Merge pull request #235 from BookOfGreg/doc/update-contrib
Update contributing instructions. Add changelog
2019-10-03 22:46:41 +01:00
Greg Myers
a3aa56e2df Add a message on how to release to contributing guide 2019-10-03 22:37:48 +01:00
Greg Myers
3329c1ec55 Add Changelog
Fix #38
2019-10-02 14:10:18 +01:00
Greg Myers
8bdf3eac08 Update the contributing doc, referencing the CI files 2019-10-02 13:50:56 +01:00
Greg Myers
ed25ff36e6 Merge pull request #210 from olleolleolle/patch-1
CONTRIBUTING: Correct URL
2019-09-30 21:54:54 +01:00
Greg Myers
7df00dde94 Merge pull request #227 from biow0lf/biow0lf-patch-1
Fix typo
2019-09-30 21:12:11 +01:00
Greg Myers
2a8c0cee4b Merge pull request #234 from rswag/BookOfGreg-patch-1
Update README.md
2019-09-30 21:09:23 +01:00
Greg Myers
e03af84262 Merge pull request #228 from thiagopradi/rails-6-full-support
Rails 6 Support
2019-09-30 21:09:04 +01:00
Greg Myers
b7a6b2de8b Update README.md
Repoint readme links
2019-09-30 21:06:14 +01:00
Thiago Pradi
4bdbd7ed98 Use updated ruby on CI too 2019-09-23 23:03:09 -03:00
Thiago Pradi
6c684729d1 Use updated ruby version 2019-09-23 22:56:24 -03:00
Thiago Pradi
81f8e0dbaf Removing Rails 3/4 - they are not supported by the Rails Core Team 2019-08-25 23:19:03 -03:00
Thiago Pradi
91a0f88eb5 Use different Sqlite versions for Rails versions 2019-08-25 23:11:57 -03:00
Thiago Pradi
586d0211ff Force SQlite 1.3 version 2019-08-25 23:06:19 -03:00
Thiago Pradi
d379338017 Enforce SQlite version 2019-08-25 23:00:07 -03:00
Thiago Pradi
7179802fe0 Using alternative config for xfvb 2019-08-25 22:50:28 -03:00
Thiago Pradi
16458d458a Adding extra lib to fix build 2019-08-25 22:45:12 -03:00
Thiago Pradi
621d6f4754 Updating travis file and adding Rails 6 to build matrix 2019-08-25 22:37:22 -03:00
Thiago Pradi
ac65dc1780 Gemfile / gemspec files compatible with Rails 6 2019-08-25 22:36:14 -03:00
Igor Zubkov
a00145c1f7 Fix typo 2019-08-20 16:51:27 +03:00
Olle Jonsson
f969fb6573 CONTRIBUTING: Correct URL 2019-04-17 14:46:26 +02:00
Richard Morris
10bb732148 Merge pull request #177 from FormAPI/show_response_body_for_invalid_code
Show response body when the response code is unexpected.
2019-04-08 12:25:28 +01:00
Richard Morris
c74c88fd46 Merge pull request #176 from BookOfGreg/patch-1
Update swagger_helper.rb
2019-04-08 12:24:54 +01:00
Richard Morris
9cb187192d Merge pull request #23 from drewish/contributing
Add a contributing file
2019-04-08 12:17:32 +01:00
Richard Morris
636cdcd8b3 Merge pull request #92 from seriousbee/add-section-on-formatting-to-RM
Updated Readme.md:
2019-04-08 12:17:05 +01:00
stefanosx
49b5059273 Update README.md
You need to run the generation of rswag:api:install rswag:ui:install in separated lines to work
2019-03-06 12:59:24 +01:00
Ben Lewis
9eb2d3ddec Allow ".yaml" and ".yml" filename endings for yaml 2019-02-12 10:47:15 +00:00
Ben Lewis
51b47f32e8 version compatibility 2019-02-06 12:15:01 +00:00
Ben Lewis
29c9f7cae2 Allow parsing of yml swagger files in rswag-api 2019-02-06 11:43:02 +00:00
Rich Daley
bfd3d66ec2 Add a 'rake rswag' that runs swaggerize as the default 2019-01-07 14:17:53 +00:00
Nathan Broadbent
e381bf85d4 Show response body when the response code is unexpected. Makes it much easier to debug test failures 2018-12-22 15:20:49 +07:00
Greg Myers
9642937ee2 Update swagger_helper.rb
Use standard filesystem helpers to avoid OS specific slash errors.
2018-12-18 13:29:40 +00:00
Richard Morris
a50bf616b9 Merge pull request #156 from earksiinni/patch-1
Fix installation instructions for separate gems
2018-10-09 15:02:44 -07:00
Ersin Akinci
d69aa16985 Fix installation instructions for separate gems 2018-10-09 13:44:58 -07:00
Richard Morris
4d1f5f831b Merge pull request #150 from MSanteler/master
Update comment in swagger_helper template
2018-09-19 16:24:18 -07:00
Matthew Santeler
aa8f16070d Update comment in swagger_helper template 2018-09-19 15:24:16 -04:00
Richard Morris
6fc9faab57 Reflect swagger-ui upgrade in readme 2018-07-11 09:01:50 -07:00
Richard Morris
5ea1670d79 Merge pull request #136 from ledermann/upgrade-swagger-ui-to-3-17-3
Upgrade Swagger UI to 3.17.3
2018-07-10 07:53:01 -07:00
Georg Ledermann
00aa08bb22 ⬆️ Upgrade "swagger-ui" to 3.17.3 2018-07-10 14:49:12 +02:00
Richard Morris
ef91e087d3 Update compatibility chart to reflect realty 2018-06-21 23:27:57 -07:00
Richard Morris
be6def33ac Merge pull request #134 from ledermann/upgrade-swagger-ui-to-3-17-1
Upgrade Swagger UI to 3.17.1
2018-06-21 07:34:15 -07:00
Georg Ledermann
6b04c72cc9 ⬆️ Upgrade "swagger-ui" to 3.17.1 2018-06-21 09:11:06 +02:00
Richard Morris
890a31e749 Merge pull request #129 from hoshinotsuyoshi/fix_typo_readme
Fix typo in README
2018-05-30 18:16:01 -07:00
hoshinotsuyoshi
862ea53cf4 Fix typo in README
Fixed Gemfile example.
2018-05-31 08:54:12 +09:00
Richard Morris
254ade95db Update README.md 2018-05-24 20:28:17 -07:00
Richard Morris
b9f71fe9b1 Merge pull request #117 from imRohan/master
Fixed typos in the swagger_helper.rb file
2018-05-24 20:00:10 -07:00
Richard Morris
870d467046 Merge pull request #125 from indocomsoft/patch-1
Fix travis to not cleanup when publishing rswag-ui
2018-05-24 19:59:56 -07:00
Julius Putra Tanu Setiaji
334671cb95 Fix travis to not cleanup when publishing rswag-ui
This is to keep `node_modules` directory.
2018-05-25 10:05:48 +08:00
domaindrivendev
efdfee5110 Tweak rswag-ui.gemspec to include node_modules 2018-05-24 09:31:06 -07:00
domaindrivendev
0c49c7e667 Ensure npm install runs during the deploy rswag-ui job 2018-05-24 08:58:19 -07:00
Richard Morris
e52ea0ba69 Update readme 2018-05-21 16:18:30 -07:00
Rohan Likhite
fee3b3bb84 fixed typos in the swagger_helper.rb file 2018-03-29 11:42:36 -04:00
Tomasz Czernuszenko
3eda72155a Updated Readme.md:
Added a section on markdown formatting and and clarified some descriptions of API versioning
2017-08-07 14:12:40 +01:00
Paul Carey
c9bda862b6 adds request spec generator shamelessly stollen from rspec-rails-swagger 2017-07-06 10:45:54 +01:00
andrew morton
4842055ee6 Add a contributing file
The exact sequence of commands to be able to run the tests wasn't obvious
to me so I'm assumiing others could use a hand.

I used the factory_girl_rails gem's file as a starting point.
2016-09-13 06:47:01 -06:00
48 changed files with 574 additions and 85 deletions

17
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,17 @@
## Describe the bug
A clear and concise description of what the bug is.
## Steps to Test or Reproduce
Please provide an example repo or the steps to reproduce the behavior.
## Expected behavior
A clear and concise description of what you expected to happen.
## Screenshots
If applicable, add screenshots to help explain your problem.
## Additional context
Add any other context about the problem here.
## Rswag Version
The version of rswag are you using.

View File

@@ -0,0 +1,11 @@
## Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is.
## Describe the solution you'd like
A clear and concise description of what you want to happen.
## Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
## Additional context
Add any other context or screenshots about the feature request here.

View File

@@ -0,0 +1,15 @@
## Problem
A clear and concise description of what the problem is.
## Solution
A clear and concise description of what the solution is.
### Related Issues
Links to any related issues.
### Checklist
- [ ] Added tests
- [ ] Changelog updated
### Steps to Test or Reproduce
Outline the steps to test or reproduce the PR here.

View File

@@ -1 +1 @@
2.3.1
2.6.3

View File

@@ -1,30 +1,35 @@
language: ruby
dist: bionic
services:
- xvfb
rvm:
- 2.2.5
- 2.6.3
env:
- RAILS_VERSION=6.0.0
- RAILS_VERSION=5.2.0
- RAILS_VERSION=4.2.0
- RAILS_VERSION=3.2.22
addons:
apt:
packages:
- libqtwebkit-dev
- libqtwebkit4
cache:
directories:
- /home/travis/.rvm/gems/ruby-2.2.5
- /home/travis/.rvm/gems/ruby-2.6.3
install: ./ci/build.sh
before_script:
- export DISPLAY=:99.0
- sh -e /etc/init.d/xvfb start
- sleep 3
script: ./ci/test.sh
jobs:
include:
- stage: publish components
script: 'cd rswag-api'
if: tag IS present
deploy:
gemspec: rswag-api.gemspec
provider: rubygems
@@ -35,6 +40,7 @@ jobs:
- stage: publish components
script: 'cd rswag-specs'
if: tag IS present
deploy:
gemspec: rswag-specs.gemspec
provider: rubygems
@@ -45,16 +51,19 @@ jobs:
- stage: publish components
script: 'cd rswag-ui'
if: tag IS present
deploy:
gemspec: rswag-ui.gemspec
provider: rubygems
api_key: $RUBYGEMS_API_KEY
skip_cleanup: true
on:
branch: master
tags: true
- stage: publish rswag
script: 'cd rswag'
if: tag IS present
deploy:
gemspec: rswag.gemspec
provider: rubygems

39
CHANGELOG.md Normal file
View File

@@ -0,0 +1,39 @@
# rswag
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
### Changed
### Deprecated
### Removed
### Fixed
### Security
## [2.2.0] - 2019-11-01
### Added
- New swagger_format config option for setting YAML output [#251](https://github.com/rswag/rswag/pull/251)
### Changed
- rswag-api will serve yaml files as yaml [#251](https://github.com/rswag/rswag/pull/251)
## [2.1.1] - 2019-10-18
### Fixed
- Fix incorrect require reference for swagger_generator [#248](https://github.com/rswag/rswag/issues/248)
## [2.1.0] - 2019-10-17
### Added
- New Spec Generator [#75](https://github.com/rswag/rswag/pull/75)
- Support for Options and Trace verbs; You must use a framework that supports this, for Options Rails 6.1+ Rails 6 does not support Trace. [#237](https://github.com/rswag/rswag/pull/75)
### Changed
- Update swagger-ui to 3.18.2 [#240](https://github.com/rswag/rswag/pull/240)
## [2.0.6] - 2019-10-03
### Added
- Support for Rails 6 [#228](https://github.com/rswag/rswag/pull/228)
- Support for Windows paths [#176](https://github.com/rswag/rswag/pull/176)
### Changed
- Show response body when error code is not expected [#117](https://github.com/rswag/rswag/pull/177)
## [2.0.5] - 2018-07-10

59
CONTRIBUTING.md Normal file
View File

@@ -0,0 +1,59 @@
# Contributing
## Fork, then clone the repo:
```
git clone git@github.com:rswag/rswag.git
cd rswag
```
## Build
Set up your machine:
```
./ci/build.sh
```
Or manually
```
bundle
cd test-app
bundle exec rake db:setup
cd -
cd rswag-ui
npm install
cd -
```
## Test
Make sure the tests pass:
```
./ci/test.sh
```
or manually
```
cd test-app
bundle exec rspec
```
Make your change. Add tests for your change. Make the tests pass:
```
bundle exec rspec
```
Push to your fork and [submit a Pull Request][pr].
[pr]: https://github.com/rswag/rswag/compare/
## Release
(for maintainers)
Update the changelog.md, putting the new version number in and moving the Unreleased marker.
Merge the changes into master you wish to release.
Add and push a new git tag, annotated tags preferred:
```
git tag -s 2.0.6 -m 'v2.0.6'
```
Travis will detect the tag and release all gems with that tag version number.

View File

@@ -9,11 +9,16 @@ gem 'rails', "#{rails_version}"
case rails_version.split('.').first
when '3'
gem 'strong_parameters'
when '4', '5'
when '4', '5', '6'
gem 'responders'
end
gem 'sqlite3'
case rails_version.split('.').first
when '3', '4', '5'
gem 'sqlite3', '~> 1.3.6'
when '6'
gem 'sqlite3', '~> 1.4.1'
end
gem 'rswag-api', path: './rswag-api'
gem 'rswag-ui', path: './rswag-ui'

View File

@@ -1,10 +1,11 @@
rswag (formerly swagger_rails)
rswag
=========
[![Build Status](https://travis-ci.org/domaindrivendev/rswag.svg?branch=master)](https://travis-ci.org/domaindrivendev/rswag)
[![Build Status](https://travis-ci.org/rswag/rswag.svg?branch=master)](https://travis-ci.org/rswag/rswag)
[![Maintainability](https://api.codeclimate.com/v1/badges/1175b984edc4610f82ab/maintainability)](https://codeclimate.com/github/rswag/rswag/maintainability)
[Swagger](http://swagger.io) tooling for Rails API's. Generate beautiful API documentation, including a UI to explore and test operations, directly from your rspec integration tests.
Rswag extends rspec-rails "request specs" with a Swagger-based DSL for describing and testing API operations. You describe your API operations with a succinct, intuitive syntax, and it automaticaly runs the tests. Once you have green tests, run a rake task to auto-generate corresponding Swagger files and expose them as JSON endpoints. Rswag also provides an embedded version of the awesome [swagger-ui](https://github.com/swagger-api/swagger-ui) that's powered by the exposed JSON. This toolchain makes it seamless to go from integration specs, which youre probably doing in some form already, to living documentation for your API consumers.
Rswag extends rspec-rails "request specs" with a Swagger-based DSL for describing and testing API operations. You describe your API operations with a succinct, intuitive syntax, and it automaticaly runs the tests. Once you have green tests, run a rake task to auto-generate corresponding Swagger files and expose them as YAML or JSON endpoints. Rswag also provides an embedded version of the awesome [swagger-ui](https://github.com/swagger-api/swagger-ui) that's powered by the exposed file. This toolchain makes it seamless to go from integration specs, which youre probably doing in some form already, to living documentation for your API consumers.
And that's not all ...
@@ -14,9 +15,9 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
|Rswag Version|Swagger (OpenAPI) Spec.|swagger-ui|
|----------|----------|----------|
|[master](https://github.com/domaindrivendev/rswag/tree/master)|2.0|3.13.2|
|[2.0.0](https://github.com/domaindrivendev/rswag/tree/2.0.0)|2.0|3.13.2|
|[1.6.0](https://github.com/domaindrivendev/rswag/tree/1.6.0)|2.0|2.2.5|
|[master](https://github.com/rswag/rswag/tree/master)|2.0|3.18.2|
|[2.2.0](https://github.com/rswag/rswag/tree/2.2.0)|2.0|3.18.2|
|[1.6.0](https://github.com/rswag/rswag/tree/1.6.0)|2.0|2.2.5|
## Getting Started ##
@@ -26,14 +27,15 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
gem 'rswag'
```
or if you like to avoid loading rspec in other bundler groups.
or if you like to avoid loading rspec in other bundler groups load the rswag-specs component separately.
Note: Adding it to the :development group is not strictly necessary, but without it, generators and rake tasks must be preceded by RAILS_ENV=test.
```ruby
# Gemfile
gem 'rswag-api'
gem 'rswag-ui'
groups :test do
group :development, :test do
gem 'rspec-rails'
gem 'rswag-specs'
end
@@ -45,6 +47,14 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
rails g rswag:install
```
Or run the install generators for each package separately if you installed Rswag as separate gems, as indicated above:
```ruby
rails g rswag:api:install
rails g rswag:ui:install
RAILS_ENV=test rails g rswag:specs:install
```
3. Create an integration spec to describe and test your API.
```ruby
@@ -113,12 +123,17 @@ Once you have an API that can describe itself in Swagger, you've opened the trea
end
```
There is also a generator which can help get you started `rails generate rspec:swagger API::MyController`
4. Generate the Swagger JSON file(s)
```ruby
rake rswag:specs:swaggerize
```
This common command is also aliased as `rake rswag`.
5. Spin up your app and check out the awesome, auto-generated docs at _/api-docs_!
## The rspec DSL ##
@@ -178,7 +193,7 @@ describe 'Blogs API' do
end
end
```
*Note:* the OAI v3 may be released soon(ish?) and include a nullable property. This may have an effect on the need/use of custom extension to the draft. Do not use this property if you don't understand the implications.
*Note:* OAI v3 has a nullable property. Rswag will work to support this soon. This may have an effect on the need/use of custom extension to the draft. Do not use this property if you don't understand the implications.
<https://github.com/OAI/OpenAPI-Specification/issues/229#issuecomment-280376087>
### Global Metadata ###
@@ -195,16 +210,18 @@ RSpec.configure do |config|
swagger: '2.0',
info: {
title: 'API V1',
version: 'v1'
version: 'v1',
description: 'This is the first version of my API'
},
basePath: '/api/v1'
},
'v2/swagger.json' => {
swagger: '2.0',
'v2/swagger.yaml' => {
openapi: '3.0.0',
info: {
title: 'API V2',
version: 'v2'
version: 'v2',
description: 'This is the second version of my API'
},
basePath: '/api/v2'
}
@@ -212,11 +229,12 @@ RSpec.configure do |config|
end
```
__NOTE__: By default, the paths, operations and responses defined in your spec files will be associated with the first Swagger document in _swagger_helper.rb_. If you're using multiple documents, you'll need to tag the individual specs with their target document name:
#### Supporting multiple versions of API ####
By default, the paths, operations and responses defined in your spec files will be associated with the first Swagger document in _swagger_helper.rb_. If your API has multiple versions, you should be using separate documents to describe each of them. In order to assign a file with a given version of API, you'll need to add the ```swagger_doc``` tag to each spec specifying its target document name:
```ruby
# spec/integration/v2/blogs_spec.rb
describe 'Blogs API', swagger_doc: 'v2/swagger.json' do
describe 'Blogs API', swagger_doc: 'v2/swagger.yaml' do
path '/blogs' do
...
@@ -226,6 +244,25 @@ describe 'Blogs API', swagger_doc: 'v2/swagger.json' do
end
```
#### Formatting the description literals: ####
Swagger supports the Markdown syntax to format strings. This can be especially handy if you were to provide a long description of a given API version or endpoint. Use [this guide](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) for reference.
__NOTE:__ There is one difference between the official Markdown syntax and Swagger interpretation, namely tables. To create a table like this:
| Column1 | Collumn2 |
| ------- | -------- |
| cell1 | cell2 |
you should use the folowing syntax, making sure there are no whitespaces at the start of any of the lines:
```
&#13;
| Column1 | Collumn2 |&#13;
| ------- | -------- |&#13;
| cell1 | cell2 |&#13;
&#13;
```
### Specifying/Testing API Security ###
Swagger allows for the specification of different security schemes and their applicability to operations in an API. To leverage this in rswag, you define the schemes globally in _swagger_helper.rb_ and then use the "security" attribute at the operation level to specify which schemes, if any, are applicable to that operation. Swagger supports :basic, :apiKey and :oauth2 scheme types. See [the spec](http://swagger.io/specification/#security-definitions-object-109) for more info.
@@ -414,6 +451,17 @@ RSpec.configure do |config|
config.swagger_dry_run = false
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.
```ruby
after do |example|
example.metadata[:response] = null
end
```
### Route Prefix for Swagger JSON Endpoints ###
The functionality to expose Swagger files, such as those generated by rswag-specs, as JSON endpoints is implemented as a Rails Engine. As with any Engine, you can change it's mount prefix in _routes.rb_:
@@ -457,7 +505,7 @@ Rswag::Api.configure do |c|
end
```
Note how the filter is passed the rack env for the current request. This provides a lot of flexibilty. For example, you can assign the "host" property (as shown) or you could inspect session information or an Authoriation header and remove operations based on user permissions.
Note how the filter is passed the rack env for the current request. This provides a lot of flexibilty. For example, you can assign the "host" property (as shown) or you could inspect session information or an Authorization header and remove operations based on user permissions.
### Enable Swagger Endpoints for swagger-ui ###
@@ -494,7 +542,7 @@ rails g rswag:ui:custom
This will add a local version that you can modify at _app/views/rswag/ui/home/index.html.erb_
### Publish UI Assets with "assets:precompile:
### Serve UI Assets Directly from your Web Server
Rswag ships with an embedded version of the [swagger-ui](https://github.com/swagger-api/swagger-ui), which is a static collection of JavaScript and CSS files. These assets are served by the rswag-ui middleware. However, for optimal performance you may want to serve them directly from your web server (e.g. Apache or NGINX). To do this, you'll need to copy them to the web server root. This is the "public" folder in a typical Rails application.

View File

@@ -1,4 +1,6 @@
require 'json'
require 'yaml'
require 'rack/mime'
module Rswag
module Api
@@ -14,13 +16,15 @@ module Rswag
filename = "#{@config.resolve_swagger_root(env)}/#{path}"
if env['REQUEST_METHOD'] == 'GET' && File.file?(filename)
swagger = load_json(filename)
swagger = parse_file(filename)
@config.swagger_filter.call(swagger, env) unless @config.swagger_filter.nil?
mime = Rack::Mime.mime_type(::File.extname(path), 'text/plain')
body = unload_swagger(filename, swagger)
return [
'200',
{ 'Content-Type' => 'application/json' },
[ JSON.dump(swagger) ]
{ 'Content-Type' => mime },
[ body ]
]
end
@@ -29,9 +33,29 @@ module Rswag
private
def parse_file(filename)
if /\.ya?ml$/ === filename
load_yaml(filename)
else
load_json(filename)
end
end
def load_yaml(filename)
YAML.safe_load(File.read(filename))
end
def load_json(filename)
JSON.parse(File.read(filename))
end
def unload_swagger(filename, swagger)
if /\.ya?ml$/ === filename
YAML.dump(swagger)
else
JSON.dump(swagger)
end
end
end
end
end

View File

@@ -13,5 +13,5 @@ Gem::Specification.new do |s|
s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile"]
s.add_dependency 'railties', '>= 3.1', '< 6.0'
s.add_dependency 'railties', '>= 3.1', '< 6.1'
end

View File

@@ -0,0 +1,5 @@
swagger: '2.0'
info:
title: API V1
version: v1
paths: {}

View File

@@ -76,6 +76,21 @@ module Rswag
expect(response[2].join).to include('"host":"tempuri.org"')
end
end
context 'when a path maps to a yaml swagger file' do
let(:env) { env_defaults.merge('PATH_INFO' => 'v1/swagger.yml') }
it 'returns a 200 status' do
expect(response.length).to eql(3)
expect(response.first).to eql('200')
end
it 'returns contents of the swagger file' do
expect(response.length).to eql(3)
expect(response[1]).to include( 'Content-Type' => 'text/yaml')
expect(response[2].join).to include('title: API V1')
end
end
end
end
end

View File

@@ -0,0 +1,9 @@
Description:
This creates an RSpec request spec to define Swagger documentation for a
controller. It will create a test for each of the controller's methods.
Example:
rails generate rspec:swagger V3::AccountsController
This will create:
spec/requests/v3/accounts_spec.rb

View File

@@ -0,0 +1,22 @@
require 'rswag/route_parser'
require 'rails/generators'
module Rspec
class SwaggerGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def setup
@routes = Rswag::RouteParser.new(controller_path).routes
end
def create_spec_file
template 'spec.rb', File.join('spec', 'requests', "#{controller_path}_spec.rb")
end
private
def controller_path
file_path.chomp('_controller')
end
end
end

View File

@@ -0,0 +1,30 @@
require 'swagger_helper'
RSpec.describe '<%= controller_path %>', type: :request do
<% @routes.each do | template, path_item | %>
path '<%= template %>' do
<% unless path_item[:params].empty? -%>
# You'll want to customize the parameter types...
<% path_item[:params].each do |param| -%>
parameter name: '<%= param %>', in: :path, type: :string, description: '<%= param %>'
<% end -%>
<% end -%>
<% path_item[:actions].each do | action, details | %>
<%= action %>('<%= details[:summary] %>') do
response(200, 'successful') do
<% unless path_item[:params].empty? -%>
<% path_item[:params].each do |param| -%>
let(:<%= param %>) { '123' }
<% end -%>
<% end -%>
after do |example|
example.metadata[:response][:examples] = { 'application/json' => JSON.parse(response.body, symbolize_names: true) }
end
run_test!
end
end
<% end -%>
end
<% end -%>
end

View File

@@ -3,18 +3,18 @@ require 'rails_helper'
RSpec.configure do |config|
# Specify a root folder where Swagger JSON files are generated
# NOTE: If you're using the rswag-api to serve API descriptions, you'll need
# to ensure that it's confiugred to server Swagger from the same folder
config.swagger_root = Rails.root.to_s + '/swagger'
# to ensure that it's configured to serve Swagger from the same folder
config.swagger_root = Rails.root.join('swagger').to_s
# Define one or more Swagger documents and provide global metadata for each one
# When you run the 'rswag:specs:to_swagger' rake task, the complete Swagger will
# When you run the 'rswag:specs:swaggerize' rake task, the complete Swagger will
# be generated at the provided relative path under swagger_root
# By default, the operations defined in spec files are added to the first
# document below. You can override this behavior by adding a swagger_doc tag to the
# the root example_group in your specs, e.g. describe '...', swagger_doc: 'v2/swagger.json'
config.swagger_docs = {
'v1/swagger.json' => {
swagger: '2.0',
'v1/swagger.yaml' => {
openapi: '3.0.1',
info: {
title: 'API V1',
version: 'v1'
@@ -22,4 +22,10 @@ RSpec.configure do |config|
paths: {}
}
}
# Specify the format of the output Swagger file when running 'rswag:specs:swaggerize'.
# The swagger_docs configuration option has the filename including format in
# the key, this may want to be changed to avoid putting yaml in json files.
# Defaults to json. Accepts ':json' and ':yaml'.
config.swagger_format = :yaml
end

View File

@@ -0,0 +1,58 @@
module Rswag
class RouteParser
attr_reader :controller
def initialize(controller)
@controller = controller
end
def routes
::Rails.application.routes.routes.select do |route|
route.defaults[:controller] == controller
end.reduce({}) do |tree, route|
path = path_from(route)
verb = verb_from(route)
tree[path] ||= { params: params_from(route), actions: {} }
tree[path][:actions][verb] = { summary: summary_from(route) }
tree
end
end
private
def path_from(route)
route.path.spec.to_s
.chomp('(.:format)') # Ignore any format suffix
.gsub(/:([^\/.?]+)/, '{\1}') # Convert :id to {id}
end
def verb_from(route)
verb = route.verb
if verb.kind_of? String
verb.downcase
else
verb.source.gsub(/[$^]/, '').downcase
end
end
def summary_from(route)
verb = route.requirements[:action]
noun = route.requirements[:controller].split('/').last.singularize
# Apply a few customizations to make things more readable
case verb
when 'index'
verb = 'list'
noun = noun.pluralize
when 'destroy'
verb = 'delete'
end
"#{verb} #{noun}"
end
def params_from(route)
route.segments - ['format']
end
end
end

View File

@@ -12,6 +12,7 @@ module Rswag
c.add_setting :swagger_root
c.add_setting :swagger_docs
c.add_setting :swagger_dry_run
c.add_setting :swagger_format
c.extend ExampleGroupHelpers, type: :request
c.include ExampleHelpers, type: :request
end

View File

@@ -31,6 +31,14 @@ module Rswag
end
end
def swagger_format
@swagger_format ||= begin
@rspec_config.swagger_format = :json if @rspec_config.swagger_format.nil? || @rspec_config.swagger_format.empty?
raise ConfigurationError, "Unknown swagger_format '#{@rspec_config.swagger_format}'" unless [:json, :yaml].include?(@rspec_config.swagger_format)
@rspec_config.swagger_format
end
end
def get_swagger_doc(name)
return swagger_docs.values.first if name.nil?
raise ConfigurationError, "Unknown swagger_doc '#{name}'" unless swagger_docs[name]

View File

@@ -7,7 +7,7 @@ module Rswag
describe(template, metadata, &block)
end
[ :get, :post, :patch, :put, :delete, :head ].each do |verb|
[ :get, :post, :patch, :put, :delete, :head, :options, :trace ].each do |verb|
define_method(verb) do |summary, &block|
api_metadata = { operation: { verb: verb, summary: summary } }
describe(verb, api_metadata, &block)

View File

@@ -5,6 +5,10 @@ module Rswag
rake_tasks do
load File.expand_path('../../../tasks/rswag-specs_tasks.rake', __FILE__)
end
generators do
require 'generators/rspec/swagger_generator.rb'
end
end
end
end

View File

@@ -14,17 +14,19 @@ module Rswag
def validate!(metadata, response)
swagger_doc = @config.get_swagger_doc(metadata[:swagger_doc])
validate_code!(metadata, response.code)
validate_code!(metadata, response)
validate_headers!(metadata, response.headers)
validate_body!(metadata, swagger_doc, response.body)
end
private
def validate_code!(metadata, code)
def validate_code!(metadata, response)
expected = metadata[:response][:code].to_s
if code != expected
raise UnexpectedResponse, "Expected response code '#{code}' to match '#{expected}'"
if response.code != expected
raise UnexpectedResponse,
"Expected response code '#{response.code}' to match '#{expected}'\n" \
"Response body: #{response.body}"
end
end

View File

@@ -37,7 +37,7 @@ module Rswag
FileUtils.mkdir_p dirname unless File.exists?(dirname)
File.open(file_path, 'w') do |file|
file.write(JSON.pretty_generate(doc))
file.write(pretty_generate(doc))
end
@output.puts "Swagger doc generated at #{file_path}"
@@ -46,6 +46,20 @@ module Rswag
private
def pretty_generate(doc)
if @config.swagger_format == :yaml
clean_doc = yaml_prepare(doc)
YAML.dump(clean_doc)
else # config errors are thrown in 'def swagger_format', no throw needed here
JSON.pretty_generate(doc)
end
end
def yaml_prepare(doc)
json_doc = JSON.pretty_generate(doc)
clean_doc = JSON.parse(json_doc)
end
def metadata_to_swagger(metadata)
response_code = metadata[:response][:code]
response = metadata[:response].reject { |k,v| k == :code }

View File

@@ -16,3 +16,6 @@ namespace :rswag do
end
end
end
task :rswag => ['rswag:specs:swaggerize']

View File

@@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.files = Dir["{lib}/**/*"] + ["MIT-LICENSE", "Rakefile" ]
s.add_dependency 'activesupport', '>= 3.1', '< 6.0'
s.add_dependency 'railties', '>= 3.1', '< 6.0'
s.add_dependency 'activesupport', '>= 3.1', '< 6.1'
s.add_dependency 'railties', '>= 3.1', '< 6.1'
s.add_dependency 'json-schema', '~> 2.2'
end

View File

@@ -0,0 +1,44 @@
require 'generator_spec'
require 'generators/rspec/swagger_generator'
require 'tmpdir'
module Rspec
describe SwaggerGenerator do
include GeneratorSpec::TestCase
destination Dir.mktmpdir
before(:all) do
prepare_destination
fixtures_dir = File.expand_path('../fixtures', __FILE__)
FileUtils.cp_r("#{fixtures_dir}/spec", destination_root)
end
after(:all) do
end
it 'installs the swagger_helper for rspec' do
allow_any_instance_of(Rswag::RouteParser).to receive(:routes).and_return(fake_routes)
run_generator ['Posts::CommentsController']
assert_file('spec/requests/posts/comments_spec.rb') do |content|
assert_match(/parameter name: 'post_id', in: :path, type: :string/, content)
assert_match(/patch\('update_comments comment'\)/, content)
end
end
private
def fake_routes
{
"/posts/{post_id}/comments/{id}" => {
:params => ["post_id", "id"],
:actions => {
"get" => { :summary=>"show comment" },
"patch" => { :summary=>"update_comments comment" }
}
}
}
end
end
end

View File

@@ -4,7 +4,7 @@ require 'generators/rswag/specs/install/install_generator'
module Rswag
module Specs
describe InstallGenerator do
RSpec.describe InstallGenerator do
include GeneratorSpec::TestCase
destination File.expand_path('../tmp', __FILE__)

View File

@@ -3,10 +3,12 @@ require 'rswag/specs/configuration'
module Rswag
module Specs
describe Configuration do
RSpec.describe Configuration do
subject { described_class.new(rspec_config) }
let(:rspec_config) { OpenStruct.new(swagger_root: swagger_root, swagger_docs: swagger_docs) }
let(:rspec_config) do
OpenStruct.new(swagger_root: swagger_root, swagger_docs: swagger_docs, swagger_format: swagger_format)
end
let(:swagger_root) { 'foobar' }
let(:swagger_docs) do
{
@@ -14,6 +16,7 @@ module Rswag
'v2/swagger.json' => { info: { title: 'v2' } }
}
end
let(:swagger_format) { :yaml }
describe '#swagger_root' do
let(:response) { subject.swagger_root }
@@ -46,6 +49,26 @@ module Rswag
end
end
describe '#swagger_format' do
let(:response) { subject.swagger_format }
context 'provided in rspec config' do
it { expect(response).to be_an_instance_of(Symbol) }
end
context 'unsupported format provided' do
let(:swagger_format) { :xml }
it { expect { response }.to raise_error ConfigurationError }
end
context 'not provided' do
let(:swagger_format) { nil }
it { expect(response).to eq(:json) }
end
end
describe '#get_swagger_doc(tag=nil)' do
let(:swagger_doc) { subject.get_swagger_doc(tag) }

View File

@@ -3,7 +3,7 @@ require 'rswag/specs/example_group_helpers'
module Rswag
module Specs
describe ExampleGroupHelpers do
RSpec.describe ExampleGroupHelpers do
subject { double('example_group') }
before do
@@ -24,7 +24,7 @@ module Rswag
end
end
describe '#get|post|patch|put|delete|head(verb, summary)' do
describe '#get|post|patch|put|delete|head|options|trace(verb, summary)' do
before { subject.post('Creates a blog') }
it "delegates to 'describe' with 'operation' metadata" do

View File

@@ -3,7 +3,7 @@ require 'rswag/specs/example_helpers'
module Rswag
module Specs
describe ExampleHelpers do
RSpec.describe ExampleHelpers do
subject { double('example') }
before do

View File

@@ -3,7 +3,7 @@ require 'rswag/specs/request_factory'
module Rswag
module Specs
describe RequestFactory do
RSpec.describe RequestFactory do
subject { RequestFactory.new(config) }
before do

View File

@@ -3,7 +3,7 @@ require 'rswag/specs/response_validator'
module Rswag
module Specs
describe ResponseValidator do
RSpec.describe ResponseValidator do
subject { ResponseValidator.new(config) }
before do

View File

@@ -4,7 +4,7 @@ require 'ostruct'
module Rswag
module Specs
describe SwaggerFormatter do
RSpec.describe SwaggerFormatter do
subject { described_class.new(output, config) }
# Mock out some infrastructure
@@ -53,14 +53,30 @@ module Rswag
'v1/swagger.json' => { info: { version: 'v1' } },
'v2/swagger.json' => { info: { version: 'v2' } }
)
allow(config).to receive(:swagger_format).and_return(swagger_format)
subject.stop(notification)
end
let(:notification) { double('notification') }
context 'with default format' do
let(:swagger_format) { :json }
it 'writes the swagger_doc(s) to file' do
expect(File).to exist("#{swagger_root}/v1/swagger.json")
expect(File).to exist("#{swagger_root}/v2/swagger.json")
expect { JSON.parse(File.read("#{swagger_root}/v2/swagger.json")) }.not_to raise_error
end
end
context 'with yaml format' do
let(:swagger_format) { :yaml }
it 'writes the swagger_doc(s) as yaml' do
expect(File).to exist("#{swagger_root}/v1/swagger.json")
expect { JSON.parse(File.read("#{swagger_root}/v1/swagger.json")) }.to raise_error(JSON::ParserError)
# Psych::DisallowedClass would be raised if we do not pre-process ruby symbols
expect { YAML.safe_load(File.read("#{swagger_root}/v1/swagger.json")) }.not_to raise_error
end
end
after do

View File

@@ -2,9 +2,9 @@ Rswag::Ui.configure do |c|
# List the Swagger endpoints that you want to be documented through the swagger-ui
# The first parameter is the path (absolute or relative to the UI host) to the corresponding
# JSON endpoint and the second is a title that will be displayed in the document selector
# NOTE: If you're using rspec-api to expose Swagger files (under swagger_root) as JSON endpoints,
# endpoint and the second is a title that will be displayed in the document selector
# NOTE: If you're using rspec-api to expose Swagger files (under swagger_root) as JSON or YAML endpoints,
# then the list below should correspond to the relative paths for those endpoints
c.swagger_endpoint '/api-docs/v1/swagger.json', 'API V1 Docs'
c.swagger_endpoint '/api-docs/v1/swagger.yaml', 'API V1 Docs'
end

View File

@@ -5,9 +5,9 @@
"requires": true,
"dependencies": {
"swagger-ui-dist": {
"version": "3.13.2",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.13.2.tgz",
"integrity": "sha1-EL9SK9J0q2SU0r0Nuvn+2ibbHKI="
"version": "3.18.2",
"resolved": "https://registry.npmjs.org/swagger-ui-dist/-/swagger-ui-dist-3.18.2.tgz",
"integrity": "sha512-pWAEiKkgWUJvjmLW9AojudnutJ+NTn5g6OdNLj1iIJWwCkoy40K3Upwa24DqFbmIE4vLX4XplND61hp2L+s5vg=="
}
}
}

View File

@@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"swagger-ui-dist": "3.13.2"
"swagger-ui-dist": "3.18.2"
}
}

View File

@@ -11,8 +11,8 @@ Gem::Specification.new do |s|
s.description = "Expose beautiful API documentation, that's powered by Swagger JSON endpoints, including a UI to explore and test operations"
s.license = "MIT"
s.files = Dir["{lib,node_modules}/**/*"] + ["MIT-LICENSE", "Rakefile" ]
s.files = Dir.glob("{lib,node_modules}/**/*") + ["MIT-LICENSE", "Rakefile" ]
s.add_dependency 'actionpack', '>=3.1', '< 6.0'
s.add_dependency 'railties', '>= 3.1', '< 6.0'
s.add_dependency 'actionpack', '>=3.1', '< 6.1'
s.add_dependency 'railties', '>= 3.1', '< 6.1'
end

View File

@@ -0,0 +1,2 @@
//= link_tree ../images
//= link_directory ../stylesheets .css

View File

View File

@@ -1,6 +1,6 @@
require 'rails_helper'
feature 'swagger-ui', js: true do
RSpec.feature 'swagger-ui', js: true do
scenario 'browsing api-docs' do
visit '/api-docs'

View File

@@ -1,6 +1,6 @@
require 'swagger_helper'
describe 'Auth Tests API', type: :request, swagger_doc: 'v1/swagger.json' do
RSpec.describe 'Auth Tests API', type: :request, swagger_doc: 'v1/swagger.json' do
path '/auth-tests/basic' do
post 'Authenticates with basic auth' do

View File

@@ -1,6 +1,6 @@
require 'swagger_helper'
describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
RSpec.describe 'Blogs API', type: :request, swagger_doc: 'v1/swagger.json' do
let(:api_key) { 'fake_key' }
path '/blogs' do

View File

@@ -1,7 +1,7 @@
require 'spec_helper'
require 'rake'
describe 'rswag:specs:swaggerize' do
RSpec.describe 'rswag:specs:swaggerize' do
let(:swagger_root) { Rails.root.to_s + '/swagger' }
before do
TestApp::Application.load_tasks

View File

@@ -3,7 +3,7 @@ require 'rails_helper'
RSpec.configure do |config|
# Specify a root folder where Swagger JSON files are generated
# NOTE: If you're using the rswag-api to serve API descriptions, you'll need
# to ensure that it's confiugred to server Swagger from the same folder
# to ensure that it's configured to serve Swagger from the same folder
config.swagger_root = Rails.root.to_s + '/swagger'
# Define one or more Swagger documents and provide global metadata for each one