https://github.com/smridge/swagcov
OpenAPI documentation coverage check for Rails Routes.
https://github.com/smridge/swagcov
openapi rspec rswag ruby
Last synced: about 2 months ago
JSON representation
OpenAPI documentation coverage check for Rails Routes.
- Host: GitHub
- URL: https://github.com/smridge/swagcov
- Owner: smridge
- License: mit
- Created: 2021-02-23T04:36:40.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2025-04-16T23:23:11.000Z (2 months ago)
- Last Synced: 2025-04-17T09:32:33.256Z (2 months ago)
- Topics: openapi, rspec, rswag, ruby
- Language: Ruby
- Homepage:
- Size: 2.63 MB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Swagcov
[](https://rubygems.org/gems/swagcov)

[](https://github.com/rubocop-hq/rubocop)
[](https://github.com/smridge/swagcov/blob/main/LICENSE)


[](https://coveralls.io/github/smridge/swagcov?branch=main)See OpenAPI documentation coverage report for Rails Routes.
## Usages
- 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` |## Ruby and Rails Version Support
Versioning support from a test coverage perspective, see [tests.yml](/.github/workflows/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` | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |## Installation
Add this line to your application's Gemfile:
```ruby
gem "swagcov"
```Execute:
```shell
bundle
```Create a `.swagcov.yml` in root of your Rails application. Alternatively, run:
```shell
bundle exec rake swagcov:install
```- Add the paths of your `openapi` yml files (**required**):
```yml
docs:
paths:
- swagger.yaml
```- Add `only` routes (**optional**) :
```yml
routes:
paths:
only:
- ^/v1
```- Add `ignore` routes (**optional**) :
```yml
routes:
paths:
ignore:
- /v1/foobar/:token
```- Full Example `.swagcov.yml` Config File:
```yml
docs:
paths:
- swagger.yamlroutes:
paths:
only:
- ^/v1
ignore:
- /v1/foobar/:token
- /v1/foobar:
- GET
```Execute:
```shell
bundle exec rake swagcov
```## Examples
Configurations and output from running `bundle exec rake swagcov` from the root of your Rails Application
- All Routes (minimal configuration):
```yml
docs:
paths:
- swagger.yaml
```
- With `only` endpoint configuration:
```yml
docs:
paths:
- swagger.yamlroutes:
paths:
only:
- ^/v2
```
- With `ignore` and `only` endpoint configurations:
```yml
docs:
paths:
- swagger.yamlroutes:
paths:
only:
- ^/v2
ignore:
- /v2/users
- /v2/users/:id:
- GET
```
## Contributing
See [CONTRIBUTING.md](CONTRIBUTING.md) for detail### Credit
To [@lonelyelk](https://github.com/lonelyelk) for initial development!