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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f8b15b82b2a87742868a94cd6964469cb4aff857259d3752fe258e595f0dcfc1
4
- data.tar.gz: cc35beef6a1b53c6f418337d1a59b48ce7d5152e1abf9746a0847fda08721bfc
3
+ metadata.gz: 6982166b311ad4760552a4d9b867dd0933b08f67e27da868a5b679e3cf93e4f4
4
+ data.tar.gz: 27bf743505dd26ce0180e1cfb47cdaba3b08690b746a5577b47e9e3e0f821026
5
5
  SHA512:
6
- metadata.gz: 4c1c0133c991c4dea09e0120aa54eab71b59746c5a9ec4e1718a2fc21d86802dec7b51039bfde1638fd9055932d1fc93a958285400fa9cb777378e5c02e91851
7
- data.tar.gz: 00c4c6b3508b19cb0f2c89debfc920c6aa234a4e9ec5142a11cc5995fed34d255eb70000e482d47c50a7d4f88ab026b27592b7cd1f143add31d777c48898533a
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` | Install required `.swagcov.yml` config file |
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 `openapi` yml files (**required**):
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 files
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 = @openapi_paths.keys.grep(regex).first
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Swagcov
4
4
  module Version
5
- STRING = "0.8.1"
5
+ STRING = "0.9.0"
6
6
  end
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :swagcov do
4
- desc "generate todo config file"
4
+ desc "Generate optional .swagcov_todo.yml config file acting as a TODO list"
5
5
  task generate_todo: :environment do
6
6
  exit Swagcov::Command::GenerateTodoFile.new.run
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  namespace :swagcov do
4
- desc "create config file"
4
+ desc "Generate required .swagcov.yml config file"
5
5
  task install: :environment do
6
6
  exit Swagcov::Command::GenerateDotfile.new.run
7
7
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- desc "check documentation coverage for endpoints"
3
+ desc "Check OpenAPI documentation coverage for Rails Route endpoints"
4
4
  task swagcov: :environment do
5
5
  exit Swagcov::Command::ReportCoverage.new.run
6
6
  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.8.1
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sarah Ridge