swagcov 1.2.0 → 1.3.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 +31 -8
- data/LICENSE +1 -1
- data/README.md +12 -12
- data/exe/swagcov +2 -6
- data/lib/swagcov/formatter/console.rb +19 -14
- data/lib/swagcov/openapi_files.rb +1 -1
- data/lib/swagcov/version.rb +1 -1
- metadata +57 -53
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4524e4731ad8f843011f1134d56d67cc9fda049aa3febb0ec06e0bfcb9206b2f
|
|
4
|
+
data.tar.gz: 8606e3d882d27cb59290576ecd56903e36703c71a22a6d5a39cbc972de637824
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a52559ea8b4693348515e2ac128fa14ef8b3e8d53fbddc94691bea609abc9c4e39451089bf0e52a9de1c9b6c2e6888fb71e908359558226c0447bd8f6380893b
|
|
7
|
+
data.tar.gz: 1e15fe68b40ffdb582adf54eef5e9796b0555f702dec58c4dca7429cd77e0d4c10067e09566f99177466a89f1c67b433c04b91c6e76ec75cc34f7ce3c35cdb72
|
data/CHANGELOG.md
CHANGED
|
@@ -2,12 +2,35 @@
|
|
|
2
2
|
## main (unreleased)
|
|
3
3
|
-
|
|
4
4
|
|
|
5
|
-
## 1.
|
|
5
|
+
## 1.3.0 (2026-10-18)
|
|
6
|
+
### Fixes
|
|
7
|
+
- Fix Coverage percentage when there are no routes (NaN) ([#195](https://github.com/smridge/swagcov/pull/195))
|
|
8
|
+
- Fix Route processing with optional segements (`RegexpError` resolved) ([#202](https://github.com/smridge/swagcov/pull/202)) - _[@aaronlippold](https://github.com/aaronlippold)_ and _[@smridge](https://github.com/smridge)_
|
|
9
|
+
- For example, the below `routes route` will now process as expected with `/health_check(/:checks)`
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
Prefix Verb URI Pattern Controller#Action
|
|
13
|
+
GET|POST /health_check(/:checks)(.:format) health_check/health_check#index {format: "txt"}
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
### Enhancements
|
|
17
|
+
- Add support for Ruby 4.1 ([#209](https://github.com/smridge/swagcov/pull/209))
|
|
18
|
+
- Improve path width calculation for output ([#196](https://github.com/smridge/swagcov/pull/196))
|
|
19
|
+
- Improve route output performance ([#197](https://github.com/smridge/swagcov/pull/197))
|
|
20
|
+
|
|
21
|
+
## 1.2.1 (2026-01-03)
|
|
6
22
|
### Fix
|
|
23
|
+
- Load ordering for executable (safely removed unnecessary `logger` requirement) ([#190](https://github.com/smridge/swagcov/pull/190))
|
|
24
|
+
|
|
25
|
+
### Administrative
|
|
26
|
+
- Update `LICENSE` copyright year range (2021-2026) ([#191](https://github.com/smridge/swagcov/pull/191))
|
|
27
|
+
|
|
28
|
+
## 1.2.0 (2025-12-20)
|
|
29
|
+
### Fixes
|
|
7
30
|
- Improve check for skipping mounted applications for Rails 4.2 applications ([#179](https://github.com/smridge/swagcov/pull/179))
|
|
8
31
|
- Resolve constants for loading rake task ([#181](https://github.com/smridge/swagcov/pull/181))
|
|
9
32
|
|
|
10
|
-
###
|
|
33
|
+
### Enhancements
|
|
11
34
|
- Update dotfile template generated for install with better suggestions for ignoring certain endpoints ([#184](https://github.com/smridge/swagcov/pull/184))
|
|
12
35
|
- Add support for Ruby 4.0 ([#176](https://github.com/smridge/swagcov/pull/176))
|
|
13
36
|
- Add support for Rails 8.1 ([#167](https://github.com/smridge/swagcov/pull/167))
|
|
@@ -17,7 +40,7 @@
|
|
|
17
40
|
- Improve matching for non api and turbo related routes ([#161](https://github.com/smridge/swagcov/pull/161))
|
|
18
41
|
|
|
19
42
|
## 1.1.0 (2025-08-08)
|
|
20
|
-
###
|
|
43
|
+
### Enhancements
|
|
21
44
|
- Exclude `new` and `edit` controller action routes that are non api routes by rails defaults/convention ([#155](https://github.com/smridge/swagcov/pull/155))
|
|
22
45
|
- For example the below routes are now automatically skipped since these are _generally_ `html` formats.
|
|
23
46
|
```
|
|
@@ -44,7 +67,7 @@
|
|
|
44
67
|
- Reduce `Metrics/AbcSize` for better maintainability ([#138](https://github.com/smridge/swagcov/pull/138), [#139](https://github.com/smridge/swagcov/pull/139), [#140](https://github.com/smridge/swagcov/pull/140))
|
|
45
68
|
|
|
46
69
|
## 0.10.0 (2025-05-08)
|
|
47
|
-
###
|
|
70
|
+
### Enhancements
|
|
48
71
|
- Add executable for streamlined command line usage ([#120](https://github.com/smridge/swagcov/pull/120))
|
|
49
72
|
- The below options are now available:
|
|
50
73
|
```
|
|
@@ -67,7 +90,7 @@
|
|
|
67
90
|
- `rake swagcov:install` is now `rake swagcov -- --init`
|
|
68
91
|
|
|
69
92
|
## 0.9.0 (2025-05-07)
|
|
70
|
-
###
|
|
93
|
+
### Enhancements
|
|
71
94
|
- Add support for `.json` OpenAPI file types ([#112](https://github.com/smridge/swagcov/pull/112), [#113](https://github.com/smridge/swagcov/pull/113))
|
|
72
95
|
- Update rake task descriptions ([#114](https://github.com/smridge/swagcov/pull/114))
|
|
73
96
|
- Improve performance of OpenAPI response key matching for route paths ([#115](https://github.com/smridge/swagcov/pull/115))
|
|
@@ -77,7 +100,7 @@
|
|
|
77
100
|
- Performance of coverage output by memoizing path string length ([#108](https://github.com/smridge/swagcov/pull/108))
|
|
78
101
|
|
|
79
102
|
## 0.8.0 (2025-04-22)
|
|
80
|
-
###
|
|
103
|
+
### Enhancements
|
|
81
104
|
- Reduce gem dependencies by replacing `rails` with `railties` ([#101](https://github.com/smridge/swagcov/pull/101))
|
|
82
105
|
- Remove unnecessary file from gem package ([#105](https://github.com/smridge/swagcov/pull/105))
|
|
83
106
|
|
|
@@ -89,7 +112,7 @@
|
|
|
89
112
|
bundle exec rake swagcov:generate_todo
|
|
90
113
|
```
|
|
91
114
|
|
|
92
|
-
###
|
|
115
|
+
### Refactors
|
|
93
116
|
- Add `Swagcov.project_root` method ([#86](https://github.com/smridge/swagcov/pull/86))
|
|
94
117
|
- Separate coverage collection and output ([#83](https://github.com/smridge/swagcov/pull/83))
|
|
95
118
|
- Replace ActiveSupport string method with ruby string method ([#85](https://github.com/smridge/swagcov/pull/85))
|
|
@@ -97,7 +120,7 @@
|
|
|
97
120
|
- Rename `Swagcov::Install` to `Swagcov::Command::GenerateDotfile` ([#88](https://github.com/smridge/swagcov/pull/88))
|
|
98
121
|
- Refactor `GenerateDotfile` to be consistent with `GenerateTodoFile` ([#97](https://github.com/smridge/swagcov/pull/97))
|
|
99
122
|
|
|
100
|
-
###
|
|
123
|
+
### Fixes
|
|
101
124
|
- Add exit code to install task + update messaging ([#87](https://github.com/smridge/swagcov/pull/87))
|
|
102
125
|
- Ignored path verb matching when duplicate path keys are present ([#92](https://github.com/smridge/swagcov/pull/92))
|
|
103
126
|
- Fix exit code error handling ([#95](https://github.com/smridge/swagcov/pull/95))
|
data/LICENSE
CHANGED
data/README.md
CHANGED
|
@@ -67,16 +67,16 @@ For example `SWAGCOV_DOTFILE=".openapi_coverage_config.yml" bundle exec swagcov`
|
|
|
67
67
|
Versioning support from a test coverage perspective, see [tests.yml](/.github/workflows/tests.yml) for detail
|
|
68
68
|
| `ruby -v` | `rails 8.1` | `rails 8.0` | `rails 7.2` | `rails 7.1` | `rails 7.0` | `rails 6.1` | `rails 6.0` | `rails 5.2` | `rails 5.1` | `rails 5.0` | `rails 4.2` |
|
|
69
69
|
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
|
|
70
|
-
| `4.
|
|
71
|
-
| `
|
|
72
|
-
| `3.4` | ✅ | ✅
|
|
73
|
-
| `3.3` | ✅ | ✅
|
|
74
|
-
| `3.2` | ✅ | ✅
|
|
75
|
-
| `3.1` | ❌ | ❌
|
|
76
|
-
| `3.0` | ❌ | ❌
|
|
77
|
-
| `2.7` | ❌ | ❌
|
|
78
|
-
| `2.6` | ❌ | ❌
|
|
79
|
-
| `2.5` | ❌ | ❌
|
|
70
|
+
| `4.1` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | ❌ | ❌ |
|
|
71
|
+
| `4.0` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
72
|
+
| `3.4` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
73
|
+
| `3.3` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
74
|
+
| `3.2` | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ |
|
|
75
|
+
| `3.1` | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
76
|
+
| `3.0` | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
77
|
+
| `2.7` | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
78
|
+
| `2.6` | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
79
|
+
| `2.5` | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
|
|
80
80
|
|
|
81
81
|
|
|
82
82
|
## Installation
|
|
@@ -207,8 +207,8 @@ Configurations and output from running `swagcov` / `rake swagcov` from the root
|
|
|
207
207
|
## Contributing
|
|
208
208
|
See [CONTRIBUTING.md](CONTRIBUTING.md) for detail
|
|
209
209
|
|
|
210
|
-
###
|
|
211
|
-
|
|
210
|
+
### Backstory
|
|
211
|
+
We had a need to determine what our documentation coverage looked like. [@lonelyelk](https://github.com/lonelyelk) created an initial internal script and [@smridge](https://github.com/smridge) converted it to a configurable open source package.
|
|
212
212
|
|
|
213
213
|
### Contributors
|
|
214
214
|
<a href="https://github.com/smridge/swagcov/graphs/contributors">
|
data/exe/swagcov
CHANGED
|
@@ -6,12 +6,6 @@
|
|
|
6
6
|
# Booting rails approach should work for most applications
|
|
7
7
|
# Rake task option as an alternative should always work as expected
|
|
8
8
|
|
|
9
|
-
# Load logger before rails
|
|
10
|
-
# Fix for booting rails 6.0-7.0 apps (uninitialized constant ActiveSupport::LoggerThreadSafeLevel::Logger)
|
|
11
|
-
require "logger"
|
|
12
|
-
|
|
13
|
-
require "swagcov"
|
|
14
|
-
|
|
15
9
|
RAILS_APP_PATH = File.expand_path("config/application", Dir.pwd)
|
|
16
10
|
|
|
17
11
|
def boot_rails_application!
|
|
@@ -24,4 +18,6 @@ end
|
|
|
24
18
|
|
|
25
19
|
boot_rails_application!
|
|
26
20
|
|
|
21
|
+
require "swagcov"
|
|
22
|
+
|
|
27
23
|
Swagcov::Runner.new(args: ARGV).run
|
|
@@ -3,14 +3,15 @@
|
|
|
3
3
|
module Swagcov
|
|
4
4
|
module Formatter
|
|
5
5
|
class Console
|
|
6
|
-
attr_reader :data
|
|
6
|
+
attr_reader :data, :min_path_width, :route_format
|
|
7
7
|
|
|
8
8
|
def initialize data: ::Swagcov::Coverage.new.collect
|
|
9
9
|
@data = data
|
|
10
|
+
@min_path_width = calc_min_path_width
|
|
11
|
+
@route_format = format_route
|
|
10
12
|
end
|
|
11
13
|
|
|
12
14
|
def run
|
|
13
|
-
min_path_width
|
|
14
15
|
routes_output(data[:covered], "green")
|
|
15
16
|
routes_output(data[:ignored], "yellow")
|
|
16
17
|
routes_output(data[:uncovered], "red")
|
|
@@ -21,34 +22,38 @@ module Swagcov
|
|
|
21
22
|
|
|
22
23
|
private
|
|
23
24
|
|
|
25
|
+
def calc_min_path_width
|
|
26
|
+
paths = data.values_at(:covered, :ignored, :uncovered).flat_map { |routes| routes.map { |route| route[:path] } }
|
|
27
|
+
paths.max_by(&:length)&.size.to_i + 1
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def format_route
|
|
31
|
+
"%<verb>10s %<path>-#{min_path_width}s %<status>s"
|
|
32
|
+
end
|
|
33
|
+
|
|
24
34
|
def routes_output routes, status_color
|
|
25
35
|
routes.each do |route|
|
|
26
36
|
$stdout.puts(
|
|
27
37
|
format(
|
|
28
|
-
|
|
38
|
+
route_format,
|
|
29
39
|
{ verb: route[:verb], path: route[:path], status: route[:status].send(status_color) }
|
|
30
40
|
)
|
|
31
41
|
)
|
|
32
42
|
end
|
|
33
43
|
end
|
|
34
44
|
|
|
35
|
-
def min_path_width
|
|
36
|
-
strings = []
|
|
37
|
-
|
|
38
|
-
%i[covered ignored uncovered].each { |key| data[key].each { |hash| strings << hash[:path] } }
|
|
39
|
-
|
|
40
|
-
@min_path_width ||= strings.max_by(&:length)&.size.to_i + 1
|
|
41
|
-
end
|
|
42
|
-
|
|
43
45
|
def final_output
|
|
46
|
+
total_count = data[:total_count]
|
|
47
|
+
covered_count = data[:covered_count]
|
|
48
|
+
|
|
44
49
|
$stdout.puts
|
|
45
50
|
$stdout.puts(
|
|
46
51
|
format(
|
|
47
52
|
"OpenAPI documentation coverage %<percentage>.2f%% (%<covered>d/%<total>d)",
|
|
48
53
|
{
|
|
49
|
-
percentage: 100.0 *
|
|
50
|
-
covered:
|
|
51
|
-
total:
|
|
54
|
+
percentage: total_count.zero? ? 0.0 : 100.0 * covered_count / total_count,
|
|
55
|
+
covered: covered_count,
|
|
56
|
+
total: total_count
|
|
52
57
|
}
|
|
53
58
|
)
|
|
54
59
|
)
|
|
@@ -10,7 +10,7 @@ module Swagcov
|
|
|
10
10
|
|
|
11
11
|
def find_response_keys path:, route_verb:
|
|
12
12
|
# replace :id with {id}
|
|
13
|
-
regex = ::Regexp.new("^#{path.gsub(%r{:[
|
|
13
|
+
regex = ::Regexp.new("^#{path.gsub(%r{:([^/.?]+)}, '{\1}')}?$")
|
|
14
14
|
|
|
15
15
|
matching_paths_key = @openapi_path_keys.grep(regex).first
|
|
16
16
|
matching_request_method_key = @openapi_paths.dig(matching_paths_key, route_verb.downcase)
|
data/lib/swagcov/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,79 +1,83 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: swagcov
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
|
-
- Sarah Ridge
|
|
7
|
+
- Sarah Ridge
|
|
8
8
|
bindir: exe
|
|
9
9
|
cert_chain: []
|
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
|
-
- !ruby/object:Gem::Dependency
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: railties
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
-
|
|
17
|
+
- ">="
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: "4.2"
|
|
20
|
+
type: :runtime
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
-
|
|
25
|
+
- ">="
|
|
26
|
+
- !ruby/object:Gem::Version
|
|
27
|
+
version: "4.2"
|
|
26
28
|
email:
|
|
27
|
-
- sarahmarie@hey.com
|
|
29
|
+
- sarahmarie@hey.com
|
|
28
30
|
executables:
|
|
29
|
-
- swagcov
|
|
31
|
+
- swagcov
|
|
30
32
|
extensions: []
|
|
31
33
|
extra_rdoc_files: []
|
|
32
34
|
files:
|
|
33
|
-
- CHANGELOG.md
|
|
34
|
-
- LICENSE
|
|
35
|
-
- README.md
|
|
36
|
-
- exe/swagcov
|
|
37
|
-
- lib/swagcov.rb
|
|
38
|
-
- lib/swagcov/command/generate_dotfile.rb
|
|
39
|
-
- lib/swagcov/command/generate_todo_file.rb
|
|
40
|
-
- lib/swagcov/command/report_coverage.rb
|
|
41
|
-
- lib/swagcov/command/report_version.rb
|
|
42
|
-
- lib/swagcov/core_ext/string.rb
|
|
43
|
-
- lib/swagcov/coverage.rb
|
|
44
|
-
- lib/swagcov/dotfile.rb
|
|
45
|
-
- lib/swagcov/errors.rb
|
|
46
|
-
- lib/swagcov/formatter/console.rb
|
|
47
|
-
- lib/swagcov/openapi_files.rb
|
|
48
|
-
- lib/swagcov/options.rb
|
|
49
|
-
- lib/swagcov/railtie.rb
|
|
50
|
-
- lib/swagcov/runner.rb
|
|
51
|
-
- lib/swagcov/version.rb
|
|
52
|
-
- lib/tasks/swagcov.rake
|
|
53
|
-
homepage: https://github.com/smridge/swagcov
|
|
35
|
+
- CHANGELOG.md
|
|
36
|
+
- LICENSE
|
|
37
|
+
- README.md
|
|
38
|
+
- exe/swagcov
|
|
39
|
+
- lib/swagcov.rb
|
|
40
|
+
- lib/swagcov/command/generate_dotfile.rb
|
|
41
|
+
- lib/swagcov/command/generate_todo_file.rb
|
|
42
|
+
- lib/swagcov/command/report_coverage.rb
|
|
43
|
+
- lib/swagcov/command/report_version.rb
|
|
44
|
+
- lib/swagcov/core_ext/string.rb
|
|
45
|
+
- lib/swagcov/coverage.rb
|
|
46
|
+
- lib/swagcov/dotfile.rb
|
|
47
|
+
- lib/swagcov/errors.rb
|
|
48
|
+
- lib/swagcov/formatter/console.rb
|
|
49
|
+
- lib/swagcov/openapi_files.rb
|
|
50
|
+
- lib/swagcov/options.rb
|
|
51
|
+
- lib/swagcov/railtie.rb
|
|
52
|
+
- lib/swagcov/runner.rb
|
|
53
|
+
- lib/swagcov/version.rb
|
|
54
|
+
- lib/tasks/swagcov.rake
|
|
55
|
+
homepage: "https://github.com/smridge/swagcov"
|
|
54
56
|
licenses:
|
|
55
|
-
- MIT
|
|
57
|
+
- MIT
|
|
56
58
|
metadata:
|
|
57
|
-
allowed_push_host: https://rubygems.org
|
|
58
|
-
homepage_uri: https://github.com/smridge/swagcov
|
|
59
|
-
source_code_uri: https://github.com/smridge/swagcov
|
|
60
|
-
changelog_uri: https://github.com/smridge/swagcov/blob/main/CHANGELOG.md
|
|
61
|
-
rubygems_mfa_required:
|
|
59
|
+
allowed_push_host: "https://rubygems.org"
|
|
60
|
+
homepage_uri: "https://github.com/smridge/swagcov"
|
|
61
|
+
source_code_uri: "https://github.com/smridge/swagcov"
|
|
62
|
+
changelog_uri: "https://github.com/smridge/swagcov/blob/main/CHANGELOG.md"
|
|
63
|
+
rubygems_mfa_required: "true"
|
|
62
64
|
rdoc_options: []
|
|
63
65
|
require_paths:
|
|
64
|
-
- lib
|
|
66
|
+
- lib
|
|
65
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
68
|
requirements:
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
-
|
|
70
|
+
- ">="
|
|
71
|
+
- !ruby/object:Gem::Version
|
|
72
|
+
version: 2.5.0
|
|
70
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
74
|
requirements:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
+
-
|
|
76
|
+
- ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: "0"
|
|
75
79
|
requirements: []
|
|
76
|
-
rubygems_version: 4.0.
|
|
80
|
+
rubygems_version: 4.1.0.beta2
|
|
77
81
|
specification_version: 4
|
|
78
82
|
summary: OpenAPI documentation coverage report for Rails Route endpoints
|
|
79
83
|
test_files: []
|