swagcov 0.8.1 → 0.9.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 +6 -0
- data/README.md +5 -4
- data/lib/swagcov/command/generate_dotfile.rb +2 -1
- data/lib/swagcov/openapi_files.rb +4 -3
- data/lib/swagcov/version.rb +1 -1
- data/lib/tasks/swagcov/generate_todo.rake +1 -1
- data/lib/tasks/swagcov/install.rake +1 -1
- data/lib/tasks/swagcov.rake +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6982166b311ad4760552a4d9b867dd0933b08f67e27da868a5b679e3cf93e4f4
|
4
|
+
data.tar.gz: 27bf743505dd26ce0180e1cfb47cdaba3b08690b746a5577b47e9e3e0f821026
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df6f5c0dcd71a4f71954f40c818a831584a964983790bbb25e9aa335f569453b41cd6d6d1a5dc092389dc061338e90e3a44907cbf2c77016f7e43faae0ac2ca6
|
7
|
+
data.tar.gz: e27a24e341a0fee8d7122c92e778543c9dd64de52b9b7ad74a60f60c808ac96aed4b779945f15221560803094fffe131ebedb72f5a4440b7ad5be54d6ad94034
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,12 @@
|
|
2
2
|
## main (unreleased)
|
3
3
|
-
|
4
4
|
|
5
|
+
## 0.9.0 (2025-05-07)
|
6
|
+
### Enhancement
|
7
|
+
- Add support for `.json` OpenAPI file types ([#112](https://github.com/smridge/swagcov/pull/112), [#113](https://github.com/smridge/swagcov/pull/113))
|
8
|
+
- Update rake task descriptions ([#114](https://github.com/smridge/swagcov/pull/114))
|
9
|
+
- Improve performance of OpenAPI response key matching for route paths ([#115](https://github.com/smridge/swagcov/pull/115))
|
10
|
+
|
5
11
|
## 0.8.1 (2025-04-29)
|
6
12
|
### Fix
|
7
13
|
- Performance of coverage output by memoizing path string length ([#108](https://github.com/smridge/swagcov/pull/108))
|
data/README.md
CHANGED
@@ -17,9 +17,9 @@ See OpenAPI documentation coverage report for Rails Routes.
|
|
17
17
|
|
18
18
|
| `rake task` | `rails console` | Description |
|
19
19
|
| :--- | :--- | :--- |
|
20
|
-
| `rake swagcov` | `Swagcov::Command::ReportCoverage.new.run` | Check documentation coverage |
|
21
|
-
| `rake swagcov:install` | `Swagcov::Command::GenerateDotfile.new.run` |
|
22
|
-
| `rake swagcov:generate_todo` | `Swagcov::Command::GenerateTodoFile.new.run` | Generate `.swagcov_todo.yml` |
|
20
|
+
| `rake swagcov` | `Swagcov::Command::ReportCoverage.new.run` | Check OpenAPI documentation coverage for Rails Route endpoints |
|
21
|
+
| `rake swagcov:install` | `Swagcov::Command::GenerateDotfile.new.run` | Generate required `.swagcov.yml` config file |
|
22
|
+
| `rake swagcov:generate_todo` | `Swagcov::Command::GenerateTodoFile.new.run` | Generate optional `.swagcov_todo.yml` config file |
|
23
23
|
|
24
24
|
## Ruby and Rails Version Support
|
25
25
|
Versioning support from a test coverage perspective, see [tests.yml](/.github/workflows/tests.yml) for detail
|
@@ -51,11 +51,12 @@ Create a `.swagcov.yml` in root of your Rails application. Alternatively, run:
|
|
51
51
|
bundle exec rake swagcov:install
|
52
52
|
```
|
53
53
|
|
54
|
-
- Add the paths of your `
|
54
|
+
- Add the paths of your OpenAPI `.yml` and/or `.json` files (**required**):
|
55
55
|
```yml
|
56
56
|
docs:
|
57
57
|
paths:
|
58
58
|
- swagger.yaml
|
59
|
+
- swagger.json
|
59
60
|
```
|
60
61
|
|
61
62
|
- Add `only` routes (**optional**) :
|
@@ -19,10 +19,11 @@ module Swagcov
|
|
19
19
|
dotfile,
|
20
20
|
<<~YAML
|
21
21
|
## Required field:
|
22
|
-
# List your OpenAPI documentation
|
22
|
+
# List your OpenAPI documentation file(s) (accepts json or yaml)
|
23
23
|
docs:
|
24
24
|
paths:
|
25
25
|
- swagger.yaml
|
26
|
+
- swagger.json
|
26
27
|
|
27
28
|
## Optional fields:
|
28
29
|
# routes:
|
@@ -5,13 +5,14 @@ module Swagcov
|
|
5
5
|
def initialize filepaths:
|
6
6
|
@filepaths = filepaths
|
7
7
|
@openapi_paths = load_yamls
|
8
|
+
@openapi_path_keys = @openapi_paths.keys
|
8
9
|
end
|
9
10
|
|
10
11
|
def find_response_keys path:, route_verb:
|
11
12
|
# replace :id with {id}
|
12
13
|
regex = ::Regexp.new("^#{path.gsub(%r{:[^/]+}, '\\{[^/]+\\}')}?$")
|
13
14
|
|
14
|
-
matching_paths_key = @
|
15
|
+
matching_paths_key = @openapi_path_keys.grep(regex).first
|
15
16
|
matching_request_method_key = @openapi_paths.dig(matching_paths_key, route_verb.downcase)
|
16
17
|
|
17
18
|
matching_request_method_key["responses"].keys.map(&:to_s).sort if matching_request_method_key
|
@@ -26,8 +27,8 @@ module Swagcov
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def load_yaml filepath
|
29
|
-
::YAML.load_file(filepath)["paths"]
|
30
|
-
rescue ::Psych::SyntaxError
|
30
|
+
::YAML.load_file(filepath)["paths"] # loads yaml or json
|
31
|
+
rescue ::Psych::SyntaxError, ::JSON::ParserError
|
31
32
|
raise ::Swagcov::Errors::BadConfiguration, "Malformed openapi file (#{filepath})"
|
32
33
|
end
|
33
34
|
end
|
data/lib/swagcov/version.rb
CHANGED
data/lib/tasks/swagcov.rake
CHANGED