reqcord 0.1.2 → 0.1.3

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: 71c23f11e62a357bbc63bc7479cd77d65da3245062b9c0594e4b3d3dc0421fd2
4
- data.tar.gz: d20cfd0db3a617adc966f2641da79c155be232baad7fb94b47db235820da3a2d
3
+ metadata.gz: 5b5479eb9ebc313b6b16250eb40692a664c4d7f56eba83a5875a061153714941
4
+ data.tar.gz: 61a8fa46ddcef53e0e318589d94fd485e25f7666a3042d2050d05138350db83b
5
5
  SHA512:
6
- metadata.gz: a5c2d1ebe2463d5c3647e843d4f70b04114fe3d225a8059b5e6e09d9461945305203c5bbfe4189039a8b48edc713cf39a3d0e5cafadefb6648f62f70aaff4595
7
- data.tar.gz: 98406f42d54d21b3d7854a4b36960be53cfe0293be738ca1d1e64194215920b4194c30649a730662e078d4b9558298c1ec9a13d15096207bb4a99257733d4b1f
6
+ metadata.gz: 3794123441aba25e1aa5a0fd5560ef280cda236ce4eee98b939f684d2cb40a6833b82358331cdf5a609b18076112901b7b9cefa623bea10145350a5d6f729205
7
+ data.tar.gz: 5b416b598625d8f76df50cdce032eafddd6102f0a00f364231f334c7d3939041b2e5d622adb801ee3e04ef00d61936ab0c75b1850c3018445954e78ea8236869
data/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.2] - Unreleased
3
+ ## [0.1.3] - Unreleased
4
+
5
+ ### Added
6
+
7
+ * `routes.prefix` accepts a list (`[/v1, /v2, /partner]`) for APIs whose
8
+ versions or audiences do not share a root.
9
+
10
+ ### Changed
11
+
12
+ * The `reqcord:init` template now names test directories (`test.paths`)
13
+ instead of running the whole suite, and documents every key inline.
14
+
15
+ ## [0.1.2] - 2026-09-16
4
16
 
5
17
  ### Added
6
18
 
@@ -146,6 +146,20 @@ routes:
146
146
  prefix: /api/v2
147
147
  ```
148
148
 
149
+ A list documents routes under any of the prefixes — for APIs whose versions
150
+ or audiences do not share a root:
151
+
152
+ ```yaml
153
+ routes:
154
+ prefix:
155
+ - /v1
156
+ - /v2
157
+ - /partner
158
+ ```
159
+
160
+ One prefix already covers every version beneath it (`/api` includes `/api/v1`
161
+ and `/api/v2`); use `VERSION=v2` to generate for one of them.
162
+
149
163
  Rails' own routes (`rails/…`, Active Storage, Action Mailbox, Turbo) are always
150
164
  left out. `redirect(...)` routes and plain Rack mounts cannot be documented from
151
165
  a test; they are counted as *skipped* in the report rather than dropped.
data/examples/reqcord.yml CHANGED
@@ -20,8 +20,10 @@ test:
20
20
  # command: bin/rails test test/integration test/api
21
21
 
22
22
  routes:
23
- # Only routes under this prefix are documented. Filter a single run with
24
- # RESOURCE=customers,cart or VERSION=v2 instead of editing this file.
23
+ # Only routes under this prefix are documented; a list works too:
24
+ # prefix: [/api, /partner]
25
+ # Filter a single run with RESOURCE=customers,cart or VERSION=v2 instead of
26
+ # editing this file.
25
27
  prefix: /api
26
28
 
27
29
  output:
@@ -123,8 +123,14 @@ module Reqcord
123
123
  Array(data.dig("test", "paths")).map(&:to_s)
124
124
  end
125
125
 
126
+ # `prefix: /api` or `prefix: [/v1, /v2]`; a route under any of them is
127
+ # documented. Empty means every route.
128
+ def route_prefixes
129
+ Array(data.dig("routes", "prefix")).map(&:to_s).reject(&:empty?)
130
+ end
131
+
126
132
  def route_prefix
127
- data.dig("routes", "prefix")
133
+ route_prefixes.first
128
134
  end
129
135
 
130
136
  def output_directory
@@ -187,7 +187,7 @@ module Reqcord
187
187
  collector = RouteCollector.new(
188
188
  resources: resources,
189
189
  version: version,
190
- prefix: configuration.route_prefix
190
+ prefix: configuration.route_prefixes
191
191
  )
192
192
 
193
193
  routes = collector.call
@@ -211,10 +211,12 @@ module Reqcord
211
211
  )
212
212
  end
213
213
 
214
+ # `prefix` is one string or a list; nothing configured means every route.
214
215
  def matches_prefix?(path)
215
- return true if prefix.nil? || prefix.empty?
216
+ prefixes = Array(prefix).map(&:to_s).reject(&:empty?)
217
+ return true if prefixes.empty?
216
218
 
217
- path.start_with?(prefix)
219
+ prefixes.any? { |candidate| path.start_with?(candidate) }
218
220
  end
219
221
 
220
222
  # `RESOURCE=customers`, `RESOURCE=cart` (a singular resource is served by
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Reqcord
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -11,31 +11,58 @@ namespace :reqcord do
11
11
  end
12
12
 
13
13
  content = <<~YAML
14
+ # Reqcord configuration. Every key is documented in the gem's
15
+ # docs/configuration.md. Precedence: environment > this file > defaults.
14
16
  version: 1
15
17
 
16
18
  test:
19
+ # minitest or rspec
17
20
  framework: minitest
18
- command: bin/rails test
21
+
22
+ # The tests that exercise your API. Reqcord runs `bin/rails test <paths>`
23
+ # (or `rspec <paths>`) with capture enabled; a directory is enough.
24
+ paths:
25
+ - test/integration
26
+
27
+ # Or spell the command out yourself; it wins over `paths`.
28
+ # command: bin/rails test test/integration test/api
19
29
 
20
30
  routes:
31
+ # Only routes under this prefix are documented; a list works too
32
+ # (`prefix: [/v1, /v2]`). Filter a single run with
33
+ # RESOURCE=customers,cart or VERSION=v2.
21
34
  prefix: /api
22
35
 
23
36
  output:
24
37
  directory: docs/api
38
+
39
+ # Routes no test reached with a 2xx are listed in the index either
40
+ # way; `true` also writes a page for each of them.
25
41
  include_uncovered: false
26
42
 
43
+ # markdown: pages under docs/api, curl: one runnable .sh per endpoint,
44
+ # postman: postman/collection.json (import into Postman or Hoppscotch).
27
45
  exporters:
28
46
  - curl
29
47
  - markdown
30
48
  - postman
31
49
 
32
50
  variables:
51
+ # Host of every generated cURL and the Postman `base_url` variable.
33
52
  base_url: http://localhost:3000
34
53
 
35
54
  sanitize:
55
+ # Header values are replaced verbatim. Authorization, Cookie and
56
+ # X-Api-Key are always redacted, configured here or not.
36
57
  headers:
37
58
  Authorization: "Bearer {{token}}"
38
59
  X-Api-Key: "{{api_key}}"
60
+
61
+ # Body keys, matched at any depth in requests and responses. password,
62
+ # token, access_token, api_key, secret are always redacted; add the
63
+ # fields your API exposes (a signed payment link, for example).
64
+ body:
65
+ password: "{{password}}"
39
66
  YAML
40
67
 
41
68
  File.write(path, content)
@@ -82,7 +109,7 @@ namespace :reqcord do
82
109
  Reqcord::RouteCollector.call(
83
110
  resources: ENV.fetch("RESOURCE", "").split(",").map(&:strip).reject(&:empty?),
84
111
  version: ENV["VERSION"],
85
- prefix: Reqcord.configuration.route_prefix
112
+ prefix: Reqcord.configuration.route_prefixes
86
113
  )
87
114
 
88
115
  if routes.empty?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reqcord
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmet Saridogan