Skip to content

OpenAPI documentation coverage check for Rails Routes.

License

Notifications You must be signed in to change notification settings

smridge/swagcov

Repository files navigation

Swagcov

Gem Version Gem Downloads Ruby Style Guide GitHub License

Tests Build Linting Build CodeQL Build Coverage Status

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 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:

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

Examples

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 and only endpoint configurations:

    docs:
      paths:
        - swagger.yaml
    
    routes:
      paths:
        only:
          - ^/v2
        ignore:
          - /v2/users
          - /v2/users/:id:
            - GET

Contributing

See CONTRIBUTING.md for detail

Credit

To @lonelyelk for initial development!

Contributors

About

OpenAPI documentation coverage check for Rails Routes.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages