See OpenAPI documentation coverage report for Rails Routes.
- See overview of different endpoints covered, missing and what you choose to ignore.
- Add pass/fail to your build pipeline when missing Documentation Coverage.
rake task |
rails console |
Description |
---|---|---|
rake swagcov |
Swagcov::Command::ReportCoverage.new.run |
Check documentation coverage |
rake swagcov:install |
Swagcov::Command::GenerateDotfile.new.run |
Install required .swagcov.yml config file |
rake swagcov:generate_todo |
Swagcov::Command::GenerateTodoFile.new.run |
Generate .swagcov_todo.yml |
Versioning support from a test coverage perspective, see tests.yml for detail
ruby -v |
rails 4.2 |
rails 5.0 |
rails 5.1 |
rails 5.2 |
rails 6.0 |
rails 6.1 |
rails 7.0 |
rails 7.1 |
rails 7.2 |
rails 8.0 |
---|---|---|---|---|---|---|---|---|---|---|
2.5 |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
2.6 |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ | ❌ |
2.7 |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
3.0 |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ |
3.1 |
✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
3.2 |
❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
3.3 |
❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
3.4 |
❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
3.5 |
❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Add this line to your application's Gemfile:
gem "swagcov"
Execute:
bundle
Create a .swagcov.yml
in root of your Rails application. Alternatively, run:
bundle exec rake swagcov:install
-
Add the paths of your
openapi
yml files (required):docs: paths: - swagger.yaml
-
Add
only
routes (optional) :routes: paths: only: - ^/v1
-
Add
ignore
routes (optional) :routes: paths: ignore: - /v1/foobar/:token
-
Full Example
.swagcov.yml
Config File:docs: paths: - swagger.yaml routes: paths: only: - ^/v1 ignore: - /v1/foobar/:token - /v1/foobar: - GET
Execute:
bundle exec rake swagcov
Configurations and output from running bundle exec rake swagcov
from the root of your Rails Application
-
All Routes (minimal configuration):
docs: paths: - swagger.yaml
-
With
only
endpoint configuration:docs: paths: - swagger.yaml routes: paths: only: - ^/v2
-
With
ignore
andonly
endpoint configurations:docs: paths: - swagger.yaml routes: paths: only: - ^/v2 ignore: - /v2/users - /v2/users/:id: - GET
See CONTRIBUTING.md for detail
To @lonelyelk for initial development!