swagcov 0.11.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +83 -49
- data/lib/swagcov/command/generate_dotfile.rb +1 -1
- data/lib/swagcov/command/generate_todo_file.rb +1 -1
- data/lib/swagcov/dotfile.rb +2 -5
- data/lib/swagcov/version.rb +1 -1
- data/lib/swagcov.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 142f669b882f17b5a640aa9cd72b0cc12019cda4e4bc48d9fea5d432fcfff505
|
4
|
+
data.tar.gz: 5eac1740f216095d93ec1d0f69553eab305aa60ac8e8fb3935a9d75446db05ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 283c6d98acb19f7184ba06ef95a184fcb2844062647699a934ffd5ecb1f4f1c34f47df7cd5ede1aae39a4277f84c3237aed655e4268094921b48ac34ef0f1b73
|
7
|
+
data.tar.gz: 6107ded5f46b2472d38dc4a454ff01bb8da7dcbddc1668b22858031e38a8c3097781b32c794dfbd064a9e13e19d426482d06c1c9935059725069e94255b76cdd
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
2
2
|
## main (unreleased)
|
3
3
|
-
|
4
4
|
|
5
|
+
## 1.0.0 (2025-05-19)
|
6
|
+
### Refactor
|
7
|
+
- Default Environment Variable approach ([#143](https://github.com/smridge/swagcov/pull/143))
|
8
|
+
- `swagcov` is considered tested and stable for a version 1.0.0 release, see [README](/README.md) for documentation
|
9
|
+
|
5
10
|
## 0.11.0 (2025-05-13)
|
6
11
|
### Enhancement
|
7
12
|
- Add swagcov `version` option ([#134](https://github.com/smridge/swagcov/pull/134))
|
data/README.md
CHANGED
@@ -47,6 +47,21 @@ The approaches below are listed in the following order:
|
|
47
47
|
- `rake swagcov -- --help`
|
48
48
|
- `Swagcov::Runner.new(args: ["--help"]).run`
|
49
49
|
|
50
|
+
### Environment Variables
|
51
|
+
The following default environment variables are automatically set (and can optionally be changed to your needs)
|
52
|
+
| Key | Value |
|
53
|
+
| :--- | :--- |
|
54
|
+
| `SWAGCOV_DOTFILE` | `.swagcov.yml` |
|
55
|
+
| `SWAGCOV_TODOFILE` | `.swagcov_todo.yml` |
|
56
|
+
|
57
|
+
For example `SWAGCOV_DOTFILE=".openapi_coverage_config.yml" bundle exec swagcov`
|
58
|
+
|
59
|
+
### Exit Codes
|
60
|
+
`swagcov` exits with the following status codes:
|
61
|
+
- `0` - (`success`) if no missing documentation coverage is detected
|
62
|
+
- `1` - (`offenses`) if missing documentation coverage is detected
|
63
|
+
- `2` - (`error`) if abnormal termination due to invalid configuration, cli options, or an internal error
|
64
|
+
|
50
65
|
## Ruby and Rails Version Support
|
51
66
|
Versioning support from a test coverage perspective, see [tests.yml](/.github/workflows/tests.yml) for detail
|
52
67
|
| `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` |
|
@@ -62,68 +77,87 @@ Versioning support from a test coverage perspective, see [tests.yml](/.github/wo
|
|
62
77
|
| `3.5` | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
63
78
|
|
64
79
|
## Installation
|
65
|
-
Add this line to your application's Gemfile:
|
66
|
-
```ruby
|
67
|
-
gem "swagcov"
|
68
|
-
```
|
69
|
-
|
70
|
-
Execute:
|
71
|
-
```shell
|
72
|
-
bundle
|
73
|
-
```
|
74
|
-
|
75
|
-
Create a `.swagcov.yml` in root of your Rails application. Alternatively, run:
|
76
|
-
```shell
|
77
|
-
bundle exec rake swagcov:install
|
78
|
-
```
|
79
|
-
|
80
|
-
- Add the paths of your OpenAPI `.yml` and/or `.json` files (**required**):
|
81
|
-
```yml
|
82
|
-
docs:
|
83
|
-
paths:
|
84
|
-
- swagger.yaml
|
85
|
-
- swagger.json
|
80
|
+
- Add this line to your application's Gemfile:
|
81
|
+
```ruby
|
82
|
+
gem "swagcov"
|
86
83
|
```
|
87
84
|
|
88
|
-
-
|
89
|
-
```yml
|
90
|
-
routes:
|
91
|
-
paths:
|
92
|
-
only:
|
93
|
-
- ^/v1
|
94
|
-
```
|
85
|
+
- Execute `bundle install` to install the gem
|
95
86
|
|
96
|
-
-
|
97
|
-
```
|
98
|
-
|
99
|
-
|
100
|
-
ignore:
|
101
|
-
- /v1/foobar/:token
|
87
|
+
- Generate the required `.swagcov.yml` configuration file in the root of your Rails application by executing one of the following commands:
|
88
|
+
```
|
89
|
+
bundle exec swagcov --init
|
90
|
+
bundle exec rake swagcov -- --init
|
102
91
|
```
|
103
92
|
|
104
|
-
|
105
|
-
```
|
93
|
+
You should now see the following file to configure to your needs:
|
94
|
+
```yaml
|
95
|
+
## Required field:
|
96
|
+
# List your OpenAPI documentation file(s) (accepts json or yaml)
|
106
97
|
docs:
|
107
98
|
paths:
|
108
99
|
- swagger.yaml
|
100
|
+
- swagger.json
|
109
101
|
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
102
|
+
## Optional fields:
|
103
|
+
# routes:
|
104
|
+
# paths:
|
105
|
+
# only:
|
106
|
+
# - ^/v2 # only track v2 endpoints
|
107
|
+
# ignore:
|
108
|
+
# - /v2/users # do not track certain endpoints
|
109
|
+
# - /v2/users/:id: # ignore only certain actions (verbs)
|
110
|
+
# - GET
|
118
111
|
```
|
119
112
|
|
120
|
-
Execute:
|
121
|
-
```
|
122
|
-
bundle exec
|
123
|
-
|
113
|
+
- Execute one of the following commands:
|
114
|
+
```
|
115
|
+
bundle exec swagcov
|
116
|
+
bundle exec rake swagcov
|
117
|
+
```
|
118
|
+
|
119
|
+
Example Output:
|
120
|
+
```
|
121
|
+
GET /articles 200
|
122
|
+
PATCH /articles/:id 200
|
123
|
+
DELETE /articles/:id 204
|
124
|
+
GET /users 200
|
125
|
+
POST /users 201
|
126
|
+
GET /users/:id 200
|
127
|
+
PUT /users/:id 200
|
128
|
+
DELETE /users/:id 204
|
129
|
+
GET /v1/articles 200
|
130
|
+
POST /v1/articles 201
|
131
|
+
GET /v1/articles/:id 200
|
132
|
+
PATCH /v1/articles/:id 200
|
133
|
+
PUT /v1/articles/:id 200
|
134
|
+
DELETE /v1/articles/:id 204
|
135
|
+
GET /v2/articles 200
|
136
|
+
POST /v2/articles 201
|
137
|
+
PATCH /v2/articles/:id 200
|
138
|
+
DELETE /v2/articles/:id 204
|
139
|
+
GET /v2/articles/:id ignored
|
140
|
+
PUT /v2/articles/:id ignored
|
141
|
+
POST /articles none
|
142
|
+
GET /articles/:id none
|
143
|
+
PUT /articles/:id none
|
144
|
+
PATCH /users/:id none
|
145
|
+
|
146
|
+
OpenAPI documentation coverage 81.82% (18/22)
|
147
|
+
2 ignored endpoints
|
148
|
+
22 total endpoints
|
149
|
+
18 covered endpoints
|
150
|
+
4 uncovered endpoints
|
151
|
+
```
|
152
|
+
|
153
|
+
- Optionally generate a `.swagcov_todo.yml` config file acting as a TODO list
|
154
|
+
```
|
155
|
+
bundle exec swagcov --todo
|
156
|
+
bundle exec rake swagcov -- --todo
|
157
|
+
```
|
124
158
|
|
125
159
|
## Examples
|
126
|
-
Configurations and output from running `
|
160
|
+
Configurations and output from running `swagcov` / `rake swagcov` from the root of your Rails Application
|
127
161
|
- All Routes (minimal configuration):
|
128
162
|
```yml
|
129
163
|
docs:
|
@@ -3,7 +3,7 @@
|
|
3
3
|
module Swagcov
|
4
4
|
module Command
|
5
5
|
class GenerateTodoFile
|
6
|
-
def initialize basename: ::Swagcov::
|
6
|
+
def initialize basename: ::Swagcov::TODOFILE,
|
7
7
|
data: ::Swagcov::Coverage.new(dotfile: ::Swagcov::Dotfile.new(skip_todo: true)).collect[:uncovered]
|
8
8
|
@dotfile = ::Swagcov.project_root.join(basename)
|
9
9
|
@data = data
|
data/lib/swagcov/dotfile.rb
CHANGED
@@ -2,13 +2,10 @@
|
|
2
2
|
|
3
3
|
module Swagcov
|
4
4
|
class Dotfile
|
5
|
-
|
6
|
-
TODO_CONFIG_FILE_NAME = ::ENV.fetch("SWAGCOV_TODOFILE", ".swagcov_todo.yml")
|
7
|
-
|
8
|
-
def initialize basename: DEFAULT_CONFIG_FILE_NAME, todo_basename: TODO_CONFIG_FILE_NAME, skip_todo: false
|
5
|
+
def initialize basename: ::Swagcov::DOTFILE, todo_basename: ::Swagcov::TODOFILE, skip_todo: false
|
9
6
|
@dotfile = load_yaml(basename, required: true)
|
10
7
|
|
11
|
-
raise ::Swagcov::Errors::BadConfiguration, "Invalid config file (#{
|
8
|
+
raise ::Swagcov::Errors::BadConfiguration, "Invalid config file (#{::Swagcov::DOTFILE})" unless valid?
|
12
9
|
|
13
10
|
@todo_file = load_yaml(todo_basename) unless skip_todo
|
14
11
|
@ignored_regex = path_config_regex(ignored_config)
|
data/lib/swagcov/version.rb
CHANGED
data/lib/swagcov.rb
CHANGED
@@ -24,6 +24,9 @@ module Swagcov
|
|
24
24
|
STATUS_OFFENSES = 1
|
25
25
|
STATUS_ERROR = 2
|
26
26
|
|
27
|
+
DOTFILE = ENV["SWAGCOV_DOTFILE"] ||= ".swagcov.yml"
|
28
|
+
TODOFILE = ENV["SWAGCOV_TODOFILE"] ||= ".swagcov_todo.yml"
|
29
|
+
|
27
30
|
def project_root
|
28
31
|
::Rails.root || ::Pathname.new(::FileUtils.pwd)
|
29
32
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: swagcov
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sarah Ridge
|
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
rubygems_version: 3.6.
|
76
|
+
rubygems_version: 3.6.9
|
77
77
|
specification_version: 4
|
78
78
|
summary: OpenAPI documentation coverage report for Rails Route endpoints
|
79
79
|
test_files: []
|