rpdoc 0.2.6 → 0.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/.gitlab-ci.yml +15 -2
- data/.rubocop.yml +42 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +82 -62
- data/README.md +6 -0
- data/SECURITY.md +59 -0
- data/VERSION.md +1 -1
- data/bin/console +5 -4
- data/lib/generators/rpdoc/install_generator.rb +4 -4
- data/lib/generators/templates/initializer.rb +0 -1
- data/lib/rpdoc/configuration.rb +14 -13
- data/lib/rpdoc/helper.rb +9 -7
- data/lib/rpdoc/postman_collection.rb +35 -25
- data/lib/rpdoc/postman_response.rb +45 -29
- data/lib/rpdoc/railtie.rb +5 -3
- data/lib/rpdoc/rpdoc.rake +2 -2
- data/lib/rpdoc.rb +8 -11
- data/rpdoc.gemspec +3 -8
- metadata +3 -70
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e84bf7f80289a316f0b6c7f6b2de7c9fb6892aef65e359a248a087a63258e721
|
|
4
|
+
data.tar.gz: b9428134ee02bc3917aa1c3801194dd598dc25605cb331b098b1e67d4216ff96
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1a87a786d45263ebb13743d0ed17703f45ea2d9fc0c73b88bc53eebbf7139aa8b20df421b81f94f213f9aee5c88b8f6a882180223e96c3e588faa04e79b9ef1d
|
|
7
|
+
data.tar.gz: 48749aea15bd52f4c676330fd3fe2e4e7d2e3046e9d5647a56efad301af90182528d11fae38401963bb34a624e3e726d5b48ca3bebc4f1767154bc9e9bdab51d
|
data/.gitlab-ci.yml
CHANGED
|
@@ -6,9 +6,22 @@ include:
|
|
|
6
6
|
stages:
|
|
7
7
|
- test
|
|
8
8
|
- sast_upload
|
|
9
|
+
- lint
|
|
9
10
|
- rspec
|
|
10
11
|
- publish
|
|
11
12
|
|
|
13
|
+
rubocop:
|
|
14
|
+
stage: lint
|
|
15
|
+
image: ruby:3.4.8
|
|
16
|
+
tags:
|
|
17
|
+
- arm64
|
|
18
|
+
script:
|
|
19
|
+
- bundle install
|
|
20
|
+
- bundle exec rubocop
|
|
21
|
+
rules:
|
|
22
|
+
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
|
|
23
|
+
- if: $CI_COMMIT_BRANCH == "master"
|
|
24
|
+
|
|
12
25
|
rspec:
|
|
13
26
|
stage: rspec
|
|
14
27
|
image: ruby:3.4.8
|
|
@@ -35,5 +48,5 @@ to_gem:
|
|
|
35
48
|
- GEM_NAME=rpdoc-$RELEASE_VERSION.gem
|
|
36
49
|
- gem build rpdoc.gemspec
|
|
37
50
|
- gem push $GEM_NAME
|
|
38
|
-
|
|
39
|
-
-
|
|
51
|
+
rules:
|
|
52
|
+
- if: '$CI_COMMIT_TAG =~ /^release-\d+\.\d+\.\d+(\.\d+)?$/'
|
data/.rubocop.yml
CHANGED
|
@@ -1,13 +1,51 @@
|
|
|
1
1
|
AllCops:
|
|
2
|
-
|
|
2
|
+
NewCops: enable
|
|
3
|
+
TargetRubyVersion: 3.0
|
|
3
4
|
|
|
4
5
|
Style/StringLiterals:
|
|
5
6
|
Enabled: true
|
|
6
|
-
EnforcedStyle:
|
|
7
|
+
EnforcedStyle: single_quotes
|
|
7
8
|
|
|
8
9
|
Style/StringLiteralsInInterpolation:
|
|
10
|
+
Enabled: false
|
|
11
|
+
|
|
12
|
+
Style/WordArray:
|
|
13
|
+
Enabled: false
|
|
14
|
+
|
|
15
|
+
Style/SymbolArray:
|
|
16
|
+
Enabled: false
|
|
17
|
+
|
|
18
|
+
Layout/LineLength:
|
|
19
|
+
Max: 200
|
|
20
|
+
|
|
21
|
+
Style/Documentation:
|
|
22
|
+
Enabled: false
|
|
23
|
+
|
|
24
|
+
Style/StringLiterals:
|
|
9
25
|
Enabled: true
|
|
10
26
|
EnforcedStyle: double_quotes
|
|
11
27
|
|
|
12
|
-
|
|
13
|
-
Max:
|
|
28
|
+
Metrics/MethodLength:
|
|
29
|
+
Max: 30
|
|
30
|
+
|
|
31
|
+
Metrics/AbcSize:
|
|
32
|
+
Enabled: false
|
|
33
|
+
|
|
34
|
+
Metrics/ClassLength:
|
|
35
|
+
Max: 200
|
|
36
|
+
|
|
37
|
+
Metrics/CyclomaticComplexity:
|
|
38
|
+
Max: 15
|
|
39
|
+
|
|
40
|
+
Metrics/PerceivedComplexity:
|
|
41
|
+
Max: 15
|
|
42
|
+
|
|
43
|
+
Metrics/BlockLength:
|
|
44
|
+
Exclude:
|
|
45
|
+
- 'spec/**/*'
|
|
46
|
+
|
|
47
|
+
Metrics/ParameterLists:
|
|
48
|
+
Max: 10
|
|
49
|
+
|
|
50
|
+
Gemspec/RequireMFA:
|
|
51
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [0.3.0] - 2026-03-20
|
|
2
|
+
- Bump gem version to `0.3.0` and raise the required Ruby version to `>= 3.0.0`.
|
|
3
|
+
- Add `SECURITY.md`, document the project's security policy, and link it from `README.md`.
|
|
4
|
+
- Update the supported security maintenance policy to only cover the latest release line.
|
|
5
|
+
- Move development dependencies from `rpdoc.gemspec` to `Gemfile` and refresh development tooling versions.
|
|
6
|
+
- Update `json` to version `2.19.2` for `CVE-2026-33210` format string injection vulnerability mitigation.
|
|
7
|
+
- Update `json_requester` to `2.0.7` and refresh locked dependency versions.
|
|
8
|
+
- Adjust the GitLab release job to use `rules` for tag-based gem publishing.
|
|
9
|
+
- Align RuboCop configuration with the current codebase and fix multiple lint and style issues across the gem implementation.
|
|
10
|
+
|
|
1
11
|
## [0.2.6] - 2026-02-10
|
|
2
12
|
- Update CI to use Ruby 3.4.8.
|
|
3
13
|
- Update gemspec dependencies to avoid open-ended version constraints warnings.
|
data/Gemfile
CHANGED
|
@@ -4,3 +4,11 @@ source "https://rubygems.org"
|
|
|
4
4
|
|
|
5
5
|
# Specify your gem's dependencies in rpdoc.gemspec
|
|
6
6
|
gemspec
|
|
7
|
+
|
|
8
|
+
group :development, :test do
|
|
9
|
+
gem "pry", "~> 0.16.0"
|
|
10
|
+
gem "railties", ">= 7.1", "< 9.0"
|
|
11
|
+
gem "rspec", "~> 3.13.2"
|
|
12
|
+
gem "rubocop", "~> 1.85.1"
|
|
13
|
+
gem "rubocop-performance", "~> 1.26.1"
|
|
14
|
+
end
|
data/Gemfile.lock
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
rpdoc (0.
|
|
4
|
+
rpdoc (0.3.0)
|
|
5
5
|
activesupport (>= 7.1, < 9.0)
|
|
6
6
|
json_requester (~> 2.0, >= 2.0.1)
|
|
7
7
|
|
|
8
8
|
GEM
|
|
9
9
|
remote: https://rubygems.org/
|
|
10
10
|
specs:
|
|
11
|
-
actionpack (8.
|
|
12
|
-
actionview (= 8.
|
|
13
|
-
activesupport (= 8.
|
|
11
|
+
actionpack (8.1.2)
|
|
12
|
+
actionview (= 8.1.2)
|
|
13
|
+
activesupport (= 8.1.2)
|
|
14
14
|
nokogiri (>= 1.8.5)
|
|
15
15
|
rack (>= 2.2.4)
|
|
16
16
|
rack-session (>= 1.0.1)
|
|
@@ -18,38 +18,39 @@ GEM
|
|
|
18
18
|
rails-dom-testing (~> 2.2)
|
|
19
19
|
rails-html-sanitizer (~> 1.6)
|
|
20
20
|
useragent (~> 0.16)
|
|
21
|
-
actionview (8.
|
|
22
|
-
activesupport (= 8.
|
|
21
|
+
actionview (8.1.2)
|
|
22
|
+
activesupport (= 8.1.2)
|
|
23
23
|
builder (~> 3.1)
|
|
24
24
|
erubi (~> 1.11)
|
|
25
25
|
rails-dom-testing (~> 2.2)
|
|
26
26
|
rails-html-sanitizer (~> 1.6)
|
|
27
|
-
activesupport (8.
|
|
27
|
+
activesupport (8.1.2)
|
|
28
28
|
base64
|
|
29
|
-
benchmark (>= 0.3)
|
|
30
29
|
bigdecimal
|
|
31
30
|
concurrent-ruby (~> 1.0, >= 1.3.1)
|
|
32
31
|
connection_pool (>= 2.2.5)
|
|
33
32
|
drb
|
|
34
33
|
i18n (>= 1.6, < 2)
|
|
34
|
+
json
|
|
35
35
|
logger (>= 1.4.2)
|
|
36
36
|
minitest (>= 5.1)
|
|
37
37
|
securerandom (>= 0.3)
|
|
38
38
|
tzinfo (~> 2.0, >= 2.0.5)
|
|
39
39
|
uri (>= 0.13.1)
|
|
40
|
+
addressable (2.8.9)
|
|
41
|
+
public_suffix (>= 2.0.2, < 8.0)
|
|
40
42
|
ast (2.4.3)
|
|
41
43
|
base64 (0.3.0)
|
|
42
|
-
|
|
43
|
-
bigdecimal (3.2.2)
|
|
44
|
+
bigdecimal (4.0.1)
|
|
44
45
|
builder (3.3.0)
|
|
45
46
|
coderay (1.1.3)
|
|
46
|
-
concurrent-ruby (1.3.
|
|
47
|
-
connection_pool (
|
|
47
|
+
concurrent-ruby (1.3.6)
|
|
48
|
+
connection_pool (3.0.2)
|
|
48
49
|
crass (1.0.6)
|
|
49
|
-
date (3.
|
|
50
|
+
date (3.5.1)
|
|
50
51
|
diff-lcs (1.6.2)
|
|
51
52
|
drb (2.2.3)
|
|
52
|
-
erb (
|
|
53
|
+
erb (6.0.2)
|
|
53
54
|
erubi (1.13.1)
|
|
54
55
|
faraday (2.14.1)
|
|
55
56
|
faraday-net_http (>= 2.0, < 3.5)
|
|
@@ -59,129 +60,147 @@ GEM
|
|
|
59
60
|
multipart-post (~> 2.0)
|
|
60
61
|
faraday-net_http (3.4.2)
|
|
61
62
|
net-http (~> 0.5)
|
|
62
|
-
i18n (1.14.
|
|
63
|
+
i18n (1.14.8)
|
|
63
64
|
concurrent-ruby (~> 1.0)
|
|
64
|
-
io-console (0.8.
|
|
65
|
-
irb (1.
|
|
65
|
+
io-console (0.8.2)
|
|
66
|
+
irb (1.17.0)
|
|
66
67
|
pp (>= 0.6.0)
|
|
68
|
+
prism (>= 1.3.0)
|
|
67
69
|
rdoc (>= 4.0.0)
|
|
68
70
|
reline (>= 0.4.2)
|
|
69
|
-
json (2.
|
|
70
|
-
|
|
71
|
+
json (2.19.2)
|
|
72
|
+
json-schema (6.2.0)
|
|
73
|
+
addressable (~> 2.8)
|
|
74
|
+
bigdecimal (>= 3.1, < 5)
|
|
75
|
+
json_requester (2.0.7)
|
|
71
76
|
faraday (~> 2.0, >= 2.0.1)
|
|
72
77
|
faraday-multipart (~> 1.2.0)
|
|
73
78
|
language_server-protocol (3.17.0.5)
|
|
74
79
|
lint_roller (1.1.0)
|
|
75
80
|
logger (1.7.0)
|
|
76
|
-
loofah (2.
|
|
81
|
+
loofah (2.25.1)
|
|
77
82
|
crass (~> 1.0.2)
|
|
78
83
|
nokogiri (>= 1.12.0)
|
|
84
|
+
mcp (0.9.2)
|
|
85
|
+
json-schema (>= 4.1)
|
|
79
86
|
method_source (1.1.0)
|
|
80
|
-
minitest (
|
|
87
|
+
minitest (6.0.2)
|
|
88
|
+
drb (~> 2.0)
|
|
89
|
+
prism (~> 1.5)
|
|
81
90
|
multipart-post (2.4.1)
|
|
82
91
|
net-http (0.9.1)
|
|
83
92
|
uri (>= 0.11.1)
|
|
84
|
-
nokogiri (1.
|
|
93
|
+
nokogiri (1.19.2-aarch64-linux-gnu)
|
|
85
94
|
racc (~> 1.4)
|
|
86
|
-
nokogiri (1.
|
|
95
|
+
nokogiri (1.19.2-aarch64-linux-musl)
|
|
87
96
|
racc (~> 1.4)
|
|
88
|
-
nokogiri (1.
|
|
97
|
+
nokogiri (1.19.2-arm-linux-gnu)
|
|
89
98
|
racc (~> 1.4)
|
|
90
|
-
nokogiri (1.
|
|
99
|
+
nokogiri (1.19.2-arm-linux-musl)
|
|
91
100
|
racc (~> 1.4)
|
|
92
|
-
nokogiri (1.
|
|
101
|
+
nokogiri (1.19.2-arm64-darwin)
|
|
93
102
|
racc (~> 1.4)
|
|
94
|
-
nokogiri (1.
|
|
103
|
+
nokogiri (1.19.2-x86_64-darwin)
|
|
95
104
|
racc (~> 1.4)
|
|
96
|
-
nokogiri (1.
|
|
105
|
+
nokogiri (1.19.2-x86_64-linux-gnu)
|
|
97
106
|
racc (~> 1.4)
|
|
98
|
-
nokogiri (1.
|
|
107
|
+
nokogiri (1.19.2-x86_64-linux-musl)
|
|
99
108
|
racc (~> 1.4)
|
|
100
109
|
parallel (1.27.0)
|
|
101
|
-
parser (3.3.
|
|
110
|
+
parser (3.3.10.2)
|
|
102
111
|
ast (~> 2.4.1)
|
|
103
112
|
racc
|
|
104
|
-
pp (0.6.
|
|
113
|
+
pp (0.6.3)
|
|
105
114
|
prettyprint
|
|
106
115
|
prettyprint (0.2.0)
|
|
107
|
-
prism (1.
|
|
108
|
-
pry (0.
|
|
116
|
+
prism (1.9.0)
|
|
117
|
+
pry (0.16.0)
|
|
109
118
|
coderay (~> 1.1)
|
|
110
119
|
method_source (~> 1.0)
|
|
111
|
-
|
|
120
|
+
reline (>= 0.6.0)
|
|
121
|
+
psych (5.3.1)
|
|
112
122
|
date
|
|
113
123
|
stringio
|
|
124
|
+
public_suffix (7.0.5)
|
|
114
125
|
racc (1.8.1)
|
|
115
|
-
rack (3.
|
|
126
|
+
rack (3.2.5)
|
|
116
127
|
rack-session (2.1.1)
|
|
117
128
|
base64 (>= 0.1.0)
|
|
118
129
|
rack (>= 3.0.0)
|
|
119
130
|
rack-test (2.2.0)
|
|
120
131
|
rack (>= 1.3)
|
|
121
|
-
rackup (2.
|
|
132
|
+
rackup (2.3.1)
|
|
122
133
|
rack (>= 3)
|
|
123
134
|
rails-dom-testing (2.3.0)
|
|
124
135
|
activesupport (>= 5.0.0)
|
|
125
136
|
minitest
|
|
126
137
|
nokogiri (>= 1.6)
|
|
127
|
-
rails-html-sanitizer (1.
|
|
128
|
-
loofah (~> 2.
|
|
138
|
+
rails-html-sanitizer (1.7.0)
|
|
139
|
+
loofah (~> 2.25)
|
|
129
140
|
nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0)
|
|
130
|
-
railties (8.
|
|
131
|
-
actionpack (= 8.
|
|
132
|
-
activesupport (= 8.
|
|
141
|
+
railties (8.1.2)
|
|
142
|
+
actionpack (= 8.1.2)
|
|
143
|
+
activesupport (= 8.1.2)
|
|
133
144
|
irb (~> 1.13)
|
|
134
145
|
rackup (>= 1.0.0)
|
|
135
146
|
rake (>= 12.2)
|
|
136
147
|
thor (~> 1.0, >= 1.2.2)
|
|
148
|
+
tsort (>= 0.2)
|
|
137
149
|
zeitwerk (~> 2.6)
|
|
138
150
|
rainbow (3.1.1)
|
|
139
|
-
rake (13.3.
|
|
140
|
-
rdoc (
|
|
151
|
+
rake (13.3.1)
|
|
152
|
+
rdoc (7.2.0)
|
|
141
153
|
erb
|
|
142
154
|
psych (>= 4.0.0)
|
|
143
|
-
|
|
144
|
-
|
|
155
|
+
tsort
|
|
156
|
+
regexp_parser (2.11.3)
|
|
157
|
+
reline (0.6.3)
|
|
145
158
|
io-console (~> 0.5)
|
|
146
|
-
rspec (3.13.
|
|
159
|
+
rspec (3.13.2)
|
|
147
160
|
rspec-core (~> 3.13.0)
|
|
148
161
|
rspec-expectations (~> 3.13.0)
|
|
149
162
|
rspec-mocks (~> 3.13.0)
|
|
150
|
-
rspec-core (3.13.
|
|
163
|
+
rspec-core (3.13.6)
|
|
151
164
|
rspec-support (~> 3.13.0)
|
|
152
165
|
rspec-expectations (3.13.5)
|
|
153
166
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
154
167
|
rspec-support (~> 3.13.0)
|
|
155
|
-
rspec-mocks (3.13.
|
|
168
|
+
rspec-mocks (3.13.8)
|
|
156
169
|
diff-lcs (>= 1.2.0, < 2.0)
|
|
157
170
|
rspec-support (~> 3.13.0)
|
|
158
|
-
rspec-support (3.13.
|
|
159
|
-
rubocop (1.
|
|
171
|
+
rspec-support (3.13.7)
|
|
172
|
+
rubocop (1.85.1)
|
|
160
173
|
json (~> 2.3)
|
|
161
174
|
language_server-protocol (~> 3.17.0.2)
|
|
162
175
|
lint_roller (~> 1.1.0)
|
|
176
|
+
mcp (~> 0.6)
|
|
163
177
|
parallel (~> 1.10)
|
|
164
178
|
parser (>= 3.3.0.2)
|
|
165
179
|
rainbow (>= 2.2.2, < 4.0)
|
|
166
180
|
regexp_parser (>= 2.9.3, < 3.0)
|
|
167
|
-
rubocop-ast (>= 1.
|
|
181
|
+
rubocop-ast (>= 1.49.0, < 2.0)
|
|
168
182
|
ruby-progressbar (~> 1.7)
|
|
169
183
|
unicode-display_width (>= 2.4.0, < 4.0)
|
|
170
|
-
rubocop-ast (1.
|
|
184
|
+
rubocop-ast (1.49.1)
|
|
171
185
|
parser (>= 3.3.7.2)
|
|
172
|
-
prism (~> 1.
|
|
186
|
+
prism (~> 1.7)
|
|
187
|
+
rubocop-performance (1.26.1)
|
|
188
|
+
lint_roller (~> 1.1)
|
|
189
|
+
rubocop (>= 1.75.0, < 2.0)
|
|
190
|
+
rubocop-ast (>= 1.47.1, < 2.0)
|
|
173
191
|
ruby-progressbar (1.13.0)
|
|
174
192
|
securerandom (0.4.1)
|
|
175
|
-
stringio (3.
|
|
176
|
-
thor (1.
|
|
193
|
+
stringio (3.2.0)
|
|
194
|
+
thor (1.5.0)
|
|
195
|
+
tsort (0.2.0)
|
|
177
196
|
tzinfo (2.0.6)
|
|
178
197
|
concurrent-ruby (~> 1.0)
|
|
179
|
-
unicode-display_width (3.
|
|
180
|
-
unicode-emoji (~> 4.
|
|
181
|
-
unicode-emoji (4.0
|
|
198
|
+
unicode-display_width (3.2.0)
|
|
199
|
+
unicode-emoji (~> 4.1)
|
|
200
|
+
unicode-emoji (4.2.0)
|
|
182
201
|
uri (1.1.1)
|
|
183
202
|
useragent (0.16.11)
|
|
184
|
-
zeitwerk (2.7.
|
|
203
|
+
zeitwerk (2.7.5)
|
|
185
204
|
|
|
186
205
|
PLATFORMS
|
|
187
206
|
aarch64-linux-gnu
|
|
@@ -194,11 +213,12 @@ PLATFORMS
|
|
|
194
213
|
x86_64-linux-musl
|
|
195
214
|
|
|
196
215
|
DEPENDENCIES
|
|
197
|
-
pry (~> 0.
|
|
216
|
+
pry (~> 0.16.0)
|
|
198
217
|
railties (>= 7.1, < 9.0)
|
|
199
218
|
rpdoc!
|
|
200
|
-
rspec (~> 3.13)
|
|
201
|
-
rubocop (~> 1.
|
|
219
|
+
rspec (~> 3.13.2)
|
|
220
|
+
rubocop (~> 1.85.1)
|
|
221
|
+
rubocop-performance (~> 1.26.1)
|
|
202
222
|
|
|
203
223
|
BUNDLED WITH
|
|
204
224
|
2.7.2
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# Rpdoc
|
|
2
2
|
|
|
3
|
+
[](https://badge.fury.io/rb/rpdoc)
|
|
4
|
+
|
|
3
5
|
`Rpdoc` is a simple `Postman` API documentation tool, which transforms RSpec examples to Postman collection (with json files in Postman data format stored locally).
|
|
4
6
|
|
|
5
7
|
### Benefits
|
|
@@ -160,6 +162,10 @@ after(:each) do
|
|
|
160
162
|
end
|
|
161
163
|
```
|
|
162
164
|
|
|
165
|
+
## Security
|
|
166
|
+
|
|
167
|
+
If you discover a security issue, please review the project's [Security Policy](SECURITY.md) for reporting instructions.
|
|
168
|
+
|
|
163
169
|
## License
|
|
164
170
|
|
|
165
171
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/SECURITY.md
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Security Policy
|
|
2
|
+
|
|
3
|
+
## Scope
|
|
4
|
+
|
|
5
|
+
This policy applies to security vulnerabilities in the **rpdoc** gem itself.
|
|
6
|
+
|
|
7
|
+
`rpdoc` generates Postman collection data from RSpec request specs and can optionally push generated collections to the Postman API. Reports about security issues in your own application, infrastructure, test data, or secret management are out of scope unless the issue is caused by unsafe behavior in `rpdoc`.
|
|
8
|
+
|
|
9
|
+
## Supported Versions
|
|
10
|
+
|
|
11
|
+
Security fixes are generally provided for the latest maintained release line.
|
|
12
|
+
|
|
13
|
+
| Version | Supported |
|
|
14
|
+
| ------- | --------- |
|
|
15
|
+
| 0.3.x | Yes |
|
|
16
|
+
| < 0.3 | No |
|
|
17
|
+
|
|
18
|
+
If you are using an older version, please upgrade to the latest release before reporting behavior that may already be fixed.
|
|
19
|
+
|
|
20
|
+
## Reporting a Vulnerability
|
|
21
|
+
|
|
22
|
+
Please report suspected vulnerabilities privately. Do **not** open a public GitHub issue for undisclosed security problems.
|
|
23
|
+
|
|
24
|
+
Preferred contact:
|
|
25
|
+
|
|
26
|
+
- Email: [dev@kdanmobile.com](mailto:dev@kdanmobile.com)
|
|
27
|
+
|
|
28
|
+
When possible, include:
|
|
29
|
+
|
|
30
|
+
- A clear description of the issue
|
|
31
|
+
- The affected version(s)
|
|
32
|
+
- Steps to reproduce the problem
|
|
33
|
+
- The expected impact
|
|
34
|
+
- Any proof of concept, logs, or suggested remediation
|
|
35
|
+
|
|
36
|
+
## Response Process
|
|
37
|
+
|
|
38
|
+
We will make a reasonable effort to:
|
|
39
|
+
|
|
40
|
+
- Acknowledge receipt of the report within 5 business days
|
|
41
|
+
- Investigate and validate the issue
|
|
42
|
+
- Share remediation plans or timelines when possible
|
|
43
|
+
- Coordinate disclosure once a fix or mitigation is available
|
|
44
|
+
|
|
45
|
+
## Disclosure Policy
|
|
46
|
+
|
|
47
|
+
Please allow reasonable time for investigation and remediation before disclosing vulnerabilities publicly. Coordinated disclosure helps protect users of the gem.
|
|
48
|
+
|
|
49
|
+
## Recommendations for Users
|
|
50
|
+
|
|
51
|
+
To reduce risk when using `rpdoc`:
|
|
52
|
+
|
|
53
|
+
- Do not commit Postman API keys or other secrets to source control
|
|
54
|
+
- Review generated request and response artifacts before sharing them, since example data may contain sensitive information
|
|
55
|
+
- Avoid using production secrets or production-only data in request specs that may be transformed into documentation artifacts
|
|
56
|
+
|
|
57
|
+
## Security Updates
|
|
58
|
+
|
|
59
|
+
Security-related fixes will be documented in the project changelog and released in the normal gem release process unless there is a reason to limit disclosure until users have time to upgrade.
|
data/VERSION.md
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.3.0
|
data/bin/console
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
1
|
# frozen_string_literal: true
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
# !/usr/bin/env ruby
|
|
4
|
+
|
|
5
|
+
require 'bundler/setup'
|
|
6
|
+
require 'rpdoc'
|
|
6
7
|
|
|
7
8
|
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
9
|
# with your gem easier. You can also use a different console, if you like.
|
|
@@ -11,5 +12,5 @@ require "rpdoc"
|
|
|
11
12
|
# require "pry"
|
|
12
13
|
# Pry.start
|
|
13
14
|
|
|
14
|
-
require
|
|
15
|
+
require 'irb'
|
|
15
16
|
IRB.start(__FILE__)
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rails/generators"
|
|
4
4
|
|
|
5
5
|
module Rpdoc
|
|
6
6
|
module Generators
|
|
7
7
|
class InstallGenerator < Rails::Generators::Base
|
|
8
|
-
source_root File.expand_path(
|
|
9
|
-
desc
|
|
8
|
+
source_root File.expand_path("../templates", __dir__)
|
|
9
|
+
desc "Creates an initializer file at config/initializers."
|
|
10
10
|
|
|
11
11
|
def copy_initializer_file
|
|
12
12
|
copy_file "initializer.rb", "#{Rails.root}/config/initializers/rpdoc.rb"
|
|
13
13
|
end
|
|
14
14
|
end
|
|
15
15
|
end
|
|
16
|
-
end
|
|
16
|
+
end
|
data/lib/rpdoc/configuration.rb
CHANGED
|
@@ -33,27 +33,27 @@ module Rpdoc
|
|
|
33
33
|
RPDOC_AUTO_PUSH_STRATEGIES = [:push_and_create, :push_and_update].freeze
|
|
34
34
|
|
|
35
35
|
def initialize
|
|
36
|
-
@rpdoc_enable = ENV[
|
|
36
|
+
@rpdoc_enable = ENV["RPDOC_ENABLE"] != "false"
|
|
37
37
|
|
|
38
|
-
@postman_host =
|
|
38
|
+
@postman_host = "https://api.getpostman.com"
|
|
39
39
|
@postman_collection_path = "/collections"
|
|
40
40
|
@postman_apikey = nil
|
|
41
41
|
|
|
42
42
|
@collection_workspace = nil
|
|
43
43
|
@collection_uid = nil
|
|
44
|
-
@collection_name =
|
|
45
|
-
@collection_schema =
|
|
44
|
+
@collection_name = "Rpdoc"
|
|
45
|
+
@collection_schema = "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
46
46
|
|
|
47
|
-
@rspec_root =
|
|
48
|
-
@rspec_server_host =
|
|
49
|
-
@rspec_request_allow_headers = [
|
|
50
|
-
@rspec_response_allow_headers = [
|
|
47
|
+
@rspec_root = "spec"
|
|
48
|
+
@rspec_server_host = "{{server_host}}"
|
|
49
|
+
@rspec_request_allow_headers = ["User-Agent", "Content-Type", "Authorization"]
|
|
50
|
+
@rspec_response_allow_headers = ["Content-Type", "Content-Length", "Location"]
|
|
51
51
|
@rspec_response_identifier = :rspec_location
|
|
52
52
|
|
|
53
|
-
@rpdoc_root =
|
|
54
|
-
@rpdoc_request_filename =
|
|
55
|
-
@rpdoc_description_filename =
|
|
56
|
-
@rpdoc_collection_filename =
|
|
53
|
+
@rpdoc_root = "rpdoc"
|
|
54
|
+
@rpdoc_request_filename = "request.json"
|
|
55
|
+
@rpdoc_description_filename = "description.md"
|
|
56
|
+
@rpdoc_collection_filename = "collection.json"
|
|
57
57
|
|
|
58
58
|
@rpdoc_clean_empty_folders = true
|
|
59
59
|
@rpdoc_clean_empty_folders_except = []
|
|
@@ -62,7 +62,7 @@ module Rpdoc
|
|
|
62
62
|
@rpdoc_auto_push = false
|
|
63
63
|
@rpdoc_auto_push_strategy = :push_and_create
|
|
64
64
|
end
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
def valid?
|
|
67
67
|
return true unless @rpdoc_enable && @rpdoc_auto_push
|
|
68
68
|
return false if @postman_apikey.nil?
|
|
@@ -70,6 +70,7 @@ module Rpdoc
|
|
|
70
70
|
return false unless RPDOC_AUTO_PUSH_STRATEGIES.include?(@rpdoc_auto_push_strategy.to_sym)
|
|
71
71
|
return false if @rpdoc_auto_push_strategy == :push_and_update && @collection_uid.nil?
|
|
72
72
|
return false if @rpdoc_folder_ordering.present? && (RPDOC_FOLDER_ORDERING.exclude?(@rpdoc_folder_ordering) || !@rpdoc_folder_ordering.is_a?(Array))
|
|
73
|
+
|
|
73
74
|
true
|
|
74
75
|
end
|
|
75
76
|
end
|
data/lib/rpdoc/helper.rb
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
|
-
|
|
2
|
+
|
|
3
|
+
require "rspec/rails" if defined?(RSpec::Rails)
|
|
3
4
|
|
|
4
5
|
RSpec.configure do |config|
|
|
5
6
|
config.before(:suite) do
|
|
6
7
|
root = Rpdoc.configuration.rpdoc_root
|
|
7
8
|
if Rpdoc.configuration.rpdoc_enable
|
|
8
|
-
raise StandardError
|
|
9
|
-
|
|
9
|
+
raise StandardError, "Configuration Invalid" unless Rpdoc.configuration.valid?
|
|
10
|
+
|
|
11
|
+
FileUtils.mkdir_p(root)
|
|
10
12
|
Dir.glob("#{root}/**/*.json") do |filename|
|
|
11
13
|
File.delete(filename)
|
|
12
14
|
end
|
|
@@ -21,8 +23,8 @@ RSpec.configure do |config|
|
|
|
21
23
|
end
|
|
22
24
|
end
|
|
23
25
|
end
|
|
24
|
-
|
|
25
|
-
RSpec.shared_context
|
|
26
|
+
|
|
27
|
+
RSpec.shared_context "rpdoc" do
|
|
26
28
|
after(:each) do |example|
|
|
27
29
|
example.metadata[:rpdoc_skip] ||= false
|
|
28
30
|
|
|
@@ -36,8 +38,8 @@ RSpec.shared_context 'rpdoc' do
|
|
|
36
38
|
example.metadata[:rpdoc_action_name] ||= controller.action_name
|
|
37
39
|
example.metadata[:rpdoc_example_key] ||= example.metadata[:description].underscore
|
|
38
40
|
example.metadata[:rpdoc_example_name] ||= example.metadata[:description]
|
|
39
|
-
example.metadata[:rpdoc_example_folders] ||= controller.class.controller_path.split(
|
|
40
|
-
|
|
41
|
+
example.metadata[:rpdoc_example_folders] ||= controller.class.controller_path.split("/")
|
|
42
|
+
|
|
41
43
|
postman_response = Rpdoc::PostmanResponse.new(example, request, response)
|
|
42
44
|
postman_response.save
|
|
43
45
|
end
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
3
|
+
require "json_requester"
|
|
4
|
+
require "active_support"
|
|
5
|
+
require "active_support/core_ext"
|
|
6
6
|
|
|
7
7
|
module Rpdoc
|
|
8
8
|
class PostmanCollection
|
|
@@ -13,8 +13,8 @@ module Rpdoc
|
|
|
13
13
|
@requester = JsonRequester.new(@configuration.postman_host)
|
|
14
14
|
@data = data&.deep_symbolize_keys || generated_collection_data
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
clean_empty_folders!
|
|
17
|
+
reordering!
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
def push
|
|
@@ -24,7 +24,7 @@ module Rpdoc
|
|
|
24
24
|
def push_and_create
|
|
25
25
|
path = "#{@configuration.postman_collection_path}?workspace=#{@configuration.collection_workspace}"
|
|
26
26
|
headers = {
|
|
27
|
-
|
|
27
|
+
"X-Api-Key": @configuration.postman_apikey
|
|
28
28
|
}
|
|
29
29
|
@requester.http_send(:post, path, @data, headers)
|
|
30
30
|
end
|
|
@@ -32,10 +32,10 @@ module Rpdoc
|
|
|
32
32
|
def push_and_update
|
|
33
33
|
path = "#{@configuration.postman_collection_path}/#{@configuration.collection_uid}"
|
|
34
34
|
headers = {
|
|
35
|
-
|
|
35
|
+
"X-Api-Key": @configuration.postman_apikey
|
|
36
36
|
}
|
|
37
37
|
remote_collection_data = @requester.http_send(:get, path, {}, headers)
|
|
38
|
-
remote_collection_data = remote_collection_data[
|
|
38
|
+
remote_collection_data = remote_collection_data["status"] == 200 ? remote_collection_data.deep_symbolize_keys.slice(:collection) : nil
|
|
39
39
|
remote_collection = PostmanCollection.new(data: remote_collection_data)
|
|
40
40
|
remote_collection.clean_generated_responses!
|
|
41
41
|
remote_collection.merge!(self)
|
|
@@ -44,9 +44,7 @@ module Rpdoc
|
|
|
44
44
|
|
|
45
45
|
def save(path: nil)
|
|
46
46
|
path ||= "#{@configuration.rpdoc_root}/#{@configuration.rpdoc_collection_filename}"
|
|
47
|
-
File.
|
|
48
|
-
f.write(JSON.pretty_generate(@data))
|
|
49
|
-
end
|
|
47
|
+
File.write(path, JSON.pretty_generate(@data))
|
|
50
48
|
end
|
|
51
49
|
|
|
52
50
|
def merge!(other_collection)
|
|
@@ -84,18 +82,26 @@ module Rpdoc
|
|
|
84
82
|
end
|
|
85
83
|
|
|
86
84
|
def description(folder)
|
|
87
|
-
File.read("#{folder}/#{@configuration.rpdoc_description_filename}")
|
|
85
|
+
File.read("#{folder}/#{@configuration.rpdoc_description_filename}")
|
|
86
|
+
rescue StandardError
|
|
87
|
+
""
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
def items(folder)
|
|
91
91
|
data = []
|
|
92
92
|
Dir.glob("#{folder}/*") do |filename|
|
|
93
93
|
next unless File.directory?(filename)
|
|
94
|
-
|
|
94
|
+
|
|
95
|
+
request_file = begin
|
|
96
|
+
File.read("#{filename}/#{@configuration.rpdoc_request_filename}")
|
|
97
|
+
rescue StandardError
|
|
98
|
+
nil
|
|
99
|
+
end
|
|
95
100
|
request_data = JSON.parse(request_file).deep_symbolize_keys if request_file.present?
|
|
96
101
|
if request_data.present?
|
|
97
102
|
Dir.glob("#{filename}/*") do |response_filename|
|
|
98
103
|
next unless response_filename.match?(/.json$/) && response_filename != "#{filename}/#{@configuration.rpdoc_request_filename}"
|
|
104
|
+
|
|
99
105
|
response_data = JSON.parse(File.read(response_filename)).deep_symbolize_keys
|
|
100
106
|
request_data[:response] << response_data
|
|
101
107
|
end
|
|
@@ -103,7 +109,7 @@ module Rpdoc
|
|
|
103
109
|
data << request_data
|
|
104
110
|
else
|
|
105
111
|
data << {
|
|
106
|
-
name: filename.split(
|
|
112
|
+
name: filename.split("/").last.camelize,
|
|
107
113
|
description: description(filename),
|
|
108
114
|
item: items(filename)
|
|
109
115
|
}
|
|
@@ -114,11 +120,11 @@ module Rpdoc
|
|
|
114
120
|
|
|
115
121
|
def clean_generated_responses_from(collection_items)
|
|
116
122
|
collection_items.each do |item|
|
|
117
|
-
if item.
|
|
123
|
+
if item.key?(:item)
|
|
118
124
|
clean_generated_responses_from(item[:item])
|
|
119
|
-
elsif item.
|
|
125
|
+
elsif item.key?(:response)
|
|
120
126
|
item[:response].reject! do |response|
|
|
121
|
-
@configuration.rspec_response_identifier.present? ? response
|
|
127
|
+
@configuration.rspec_response_identifier.present? ? response[:header]&.pluck(:key)&.include?("RSpec-Location") : true
|
|
122
128
|
end
|
|
123
129
|
end
|
|
124
130
|
end
|
|
@@ -139,11 +145,11 @@ module Rpdoc
|
|
|
139
145
|
# insert generated responses and replace description into corresponding items based on item[:name]
|
|
140
146
|
from_collection_items.each do |from_item|
|
|
141
147
|
from_item_name = from_item[:name]
|
|
142
|
-
if item_hash.
|
|
143
|
-
if from_item.
|
|
148
|
+
if item_hash.key?(from_item_name)
|
|
149
|
+
if from_item.key?(:item) && item_hash[from_item_name].key?(:item)
|
|
144
150
|
item_hash[from_item_name][:description] = from_item[:description]
|
|
145
151
|
insert_generated_responses_into(item_hash[from_item_name][:item], from_collection_items: from_item[:item].to_a)
|
|
146
|
-
elsif from_item.
|
|
152
|
+
elsif from_item.key?(:response) && item_hash[from_item_name].key?(:response)
|
|
147
153
|
item_hash[from_item_name][:request] = from_item[:request].deep_dup
|
|
148
154
|
item_hash[from_item_name][:response] += from_item[:response].deep_dup
|
|
149
155
|
else
|
|
@@ -158,9 +164,11 @@ module Rpdoc
|
|
|
158
164
|
|
|
159
165
|
def clean_empty_folders_from(collection_items)
|
|
160
166
|
return unless @configuration.rpdoc_clean_empty_folders
|
|
167
|
+
|
|
161
168
|
collection_items&.reject! do |item|
|
|
162
|
-
next false if item.
|
|
169
|
+
next false if item.key?(:request)
|
|
163
170
|
next false if @configuration.rpdoc_clean_empty_folders_except.include?(item[:name])
|
|
171
|
+
|
|
164
172
|
clean_empty_folders_from(item[:item]) if item[:item].present?
|
|
165
173
|
item[:item].nil? || item[:item].empty?
|
|
166
174
|
end
|
|
@@ -168,11 +176,13 @@ module Rpdoc
|
|
|
168
176
|
|
|
169
177
|
def sort_folders_from(collection_items)
|
|
170
178
|
return unless @configuration.rpdoc_folder_ordering.present?
|
|
171
|
-
|
|
179
|
+
|
|
180
|
+
case @configuration.rpdoc_folder_ordering
|
|
181
|
+
when :asc
|
|
172
182
|
collection_items&.sort_by! { |item| item[:name] }
|
|
173
|
-
|
|
174
|
-
collection_items&.sort_by! { |item| item[:name] }
|
|
175
|
-
|
|
183
|
+
when :desc
|
|
184
|
+
collection_items&.sort_by! { |item| item[:name] }&.reverse!
|
|
185
|
+
when Array
|
|
176
186
|
# sort by array and then sort by asc
|
|
177
187
|
collection_items&.sort_by! { |item| [@configuration.rpdoc_folder_ordering.index(item[:name]) || Float::INFINITY, item[:name]] }
|
|
178
188
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "cgi"
|
|
4
4
|
|
|
5
5
|
module Rpdoc
|
|
6
6
|
class PostmanResponse
|
|
@@ -18,13 +18,13 @@ module Rpdoc
|
|
|
18
18
|
def save
|
|
19
19
|
root_path ||= @configuration.rpdoc_root
|
|
20
20
|
folder_path = "#{root_path}/#{@rspec_example.metadata[:rpdoc_example_folders].join('/')}/#{@rspec_example.metadata[:rpdoc_action_key]}"
|
|
21
|
-
FileUtils.mkdir_p(folder_path)
|
|
21
|
+
FileUtils.mkdir_p(folder_path)
|
|
22
22
|
|
|
23
23
|
request_file_path = "#{folder_path}/#{@configuration.rpdoc_request_filename}"
|
|
24
|
-
File.
|
|
24
|
+
File.write(request_file_path, JSON.pretty_generate(request_data)) unless File.exist?(request_file_path)
|
|
25
25
|
|
|
26
26
|
response_file_path = "#{folder_path}/#{@rspec_example.metadata[:rpdoc_example_key]}.json"
|
|
27
|
-
File.
|
|
27
|
+
File.write(response_file_path, JSON.pretty_generate(response_data))
|
|
28
28
|
end
|
|
29
29
|
|
|
30
30
|
private
|
|
@@ -46,53 +46,56 @@ module Rpdoc
|
|
|
46
46
|
originalRequest: original_request_data,
|
|
47
47
|
status: @rspec_response.status.to_s,
|
|
48
48
|
code: @rspec_response.code.to_i,
|
|
49
|
-
header: headers
|
|
49
|
+
header: headers
|
|
50
50
|
}
|
|
51
|
-
if @rspec_response.headers[
|
|
52
|
-
data[:_postman_previewlanguage] =
|
|
53
|
-
data[:body] =
|
|
51
|
+
if @rspec_response.headers["Content-Type"]&.include?("application/json")
|
|
52
|
+
data[:_postman_previewlanguage] = "json"
|
|
53
|
+
data[:body] = pretty_json_or_nil(@rspec_response.body)
|
|
54
54
|
else
|
|
55
55
|
body = @rspec_response.body
|
|
56
|
-
data[:_postman_previewlanguage] =
|
|
57
|
-
data[:body] =
|
|
56
|
+
data[:_postman_previewlanguage] = "text"
|
|
57
|
+
data[:body] = utf8_body(body)
|
|
58
58
|
end
|
|
59
59
|
data
|
|
60
60
|
end
|
|
61
61
|
|
|
62
62
|
def rspec_response_identifier_header
|
|
63
63
|
{
|
|
64
|
-
key:
|
|
64
|
+
key: "RSpec-Location",
|
|
65
65
|
value: @rspec_example.metadata[:location]
|
|
66
66
|
}
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def original_request_data
|
|
70
70
|
return @original_request_data if @original_request_data.present?
|
|
71
|
+
|
|
71
72
|
filter_headers = @configuration.rspec_request_allow_headers.map do |header|
|
|
72
73
|
next unless @rspec_request.headers[header].present?
|
|
74
|
+
|
|
73
75
|
{
|
|
74
76
|
key: header,
|
|
75
77
|
value: @rspec_request.headers[header]
|
|
76
78
|
}
|
|
77
79
|
end.compact
|
|
78
|
-
query_string = @rspec_request.query_string.split(
|
|
79
|
-
key, value = string.split(
|
|
80
|
+
query_string = @rspec_request.query_string.split("&").map do |string|
|
|
81
|
+
key, value = string.split("=")
|
|
80
82
|
next if key.nil? || value.nil?
|
|
83
|
+
|
|
81
84
|
{
|
|
82
85
|
key: key,
|
|
83
86
|
value: CGI.unescape(value),
|
|
84
|
-
text:
|
|
87
|
+
text: "text"
|
|
85
88
|
}
|
|
86
89
|
end.compact
|
|
87
90
|
|
|
88
|
-
original_path = @rspec_request.original_fullpath.split(
|
|
91
|
+
original_path = @rspec_request.original_fullpath.split("?").first # use original_fullpath instead of path to avoid request being redirected
|
|
89
92
|
{
|
|
90
93
|
method: @rspec_request.method,
|
|
91
94
|
header: filter_headers,
|
|
92
95
|
url: {
|
|
93
96
|
raw: "#{@configuration.rspec_server_host}#{original_path}",
|
|
94
97
|
host: [@configuration.rspec_server_host],
|
|
95
|
-
path: original_path.split(
|
|
98
|
+
path: original_path.split("/"),
|
|
96
99
|
query: query_string
|
|
97
100
|
},
|
|
98
101
|
body: original_request_data_body
|
|
@@ -100,48 +103,61 @@ module Rpdoc
|
|
|
100
103
|
end
|
|
101
104
|
|
|
102
105
|
def original_request_data_body
|
|
103
|
-
if @rspec_request.headers[
|
|
104
|
-
json_body =
|
|
106
|
+
if @rspec_request.headers["RAW_POST_DATA"].present?
|
|
107
|
+
json_body = pretty_json_or_nil(@rspec_request.headers["RAW_POST_DATA"])
|
|
105
108
|
{
|
|
106
|
-
mode:
|
|
107
|
-
raw: json_body || @rspec_request.headers[
|
|
109
|
+
mode: "raw",
|
|
110
|
+
raw: json_body || @rspec_request.headers["RAW_POST_DATA"],
|
|
108
111
|
options: {
|
|
109
112
|
raw: {
|
|
110
|
-
language: json_body.present? ?
|
|
113
|
+
language: json_body.present? ? "json" : "text"
|
|
111
114
|
}
|
|
112
115
|
}
|
|
113
116
|
}
|
|
114
117
|
elsif @rspec_request.form_data?
|
|
115
118
|
{
|
|
116
|
-
mode:
|
|
119
|
+
mode: "formdata",
|
|
117
120
|
formdata: form_data_object_to_array(@rspec_request.request_parameters)
|
|
118
121
|
}
|
|
119
|
-
else
|
|
120
|
-
nil
|
|
121
122
|
end
|
|
122
123
|
end
|
|
123
124
|
|
|
125
|
+
def pretty_json_or_nil(body)
|
|
126
|
+
JSON.pretty_generate(JSON.parse(body))
|
|
127
|
+
rescue JSON::ParserError, TypeError
|
|
128
|
+
nil
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def utf8_body(body)
|
|
132
|
+
return body unless body.encoding == Encoding::BINARY
|
|
133
|
+
|
|
134
|
+
body.force_encoding(Encoding::ISO_8859_1).encode(Encoding::UTF_8)
|
|
135
|
+
rescue Encoding::UndefinedConversionError, Encoding::InvalidByteSequenceError
|
|
136
|
+
body
|
|
137
|
+
end
|
|
138
|
+
|
|
124
139
|
def form_data_object_to_array(form_data, prefix: nil)
|
|
125
140
|
array = []
|
|
126
141
|
form_data.each do |key, value|
|
|
127
142
|
key = "#{prefix}[#{key}]" if prefix.present?
|
|
128
|
-
|
|
143
|
+
case value
|
|
144
|
+
when Hash
|
|
129
145
|
array += form_data_object_to_array(value, prefix: key)
|
|
130
|
-
|
|
146
|
+
when Array
|
|
131
147
|
value.each do |item|
|
|
132
148
|
array += form_data_object_to_array(item, prefix: "#{key}[]")
|
|
133
149
|
end
|
|
134
|
-
|
|
150
|
+
when ActionDispatch::Http::UploadedFile
|
|
135
151
|
array << {
|
|
136
152
|
key: key,
|
|
137
153
|
src: value.original_filename,
|
|
138
|
-
type:
|
|
154
|
+
type: "file"
|
|
139
155
|
}
|
|
140
156
|
else
|
|
141
157
|
array << {
|
|
142
158
|
key: key,
|
|
143
159
|
value: value,
|
|
144
|
-
type:
|
|
160
|
+
type: "text"
|
|
145
161
|
}
|
|
146
162
|
end
|
|
147
163
|
end
|
data/lib/rpdoc/railtie.rb
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
# lib/railtie.rb
|
|
2
|
-
require
|
|
3
|
-
require
|
|
4
|
+
require "rpdoc"
|
|
5
|
+
require "rails"
|
|
4
6
|
|
|
5
7
|
module Rpdoc
|
|
6
8
|
class Railtie < Rails::Railtie
|
|
@@ -11,4 +13,4 @@ module Rpdoc
|
|
|
11
13
|
load "#{path}/rpdoc.rake"
|
|
12
14
|
end
|
|
13
15
|
end
|
|
14
|
-
end
|
|
16
|
+
end
|
data/lib/rpdoc/rpdoc.rake
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
3
|
+
require "rpdoc"
|
|
4
4
|
|
|
5
5
|
namespace :rpdoc do
|
|
6
|
-
desc
|
|
6
|
+
desc "push collection to the Postman server"
|
|
7
7
|
task :push do
|
|
8
8
|
postman_collection = Rpdoc::PostmanCollection.new
|
|
9
9
|
postman_collection.save
|
data/lib/rpdoc.rb
CHANGED
|
@@ -1,25 +1,22 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
5
|
-
require
|
|
6
|
-
require
|
|
7
|
-
require
|
|
8
|
-
require
|
|
9
|
-
|
|
3
|
+
require "rpdoc/version"
|
|
4
|
+
require "rpdoc/configuration"
|
|
5
|
+
require "rpdoc/postman_response"
|
|
6
|
+
require "rpdoc/postman_collection"
|
|
7
|
+
require "rpdoc/helper" if defined?(RSpec)
|
|
8
|
+
require "rpdoc/railtie" if defined?(Rails)
|
|
10
9
|
|
|
11
10
|
module Rpdoc
|
|
12
|
-
|
|
13
11
|
class << self
|
|
14
|
-
|
|
12
|
+
attr_writer :configuration
|
|
15
13
|
end
|
|
16
14
|
|
|
17
15
|
def self.configuration
|
|
18
16
|
@configuration ||= Configuration.new
|
|
19
17
|
end
|
|
20
18
|
|
|
21
|
-
def self.configure
|
|
19
|
+
def self.configure
|
|
22
20
|
yield(configuration)
|
|
23
21
|
end
|
|
24
|
-
|
|
25
22
|
end
|
data/rpdoc.gemspec
CHANGED
|
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
|
12
12
|
spec.description = "Rpdoc is a simple Postman API documentation tool, which transforms RSpec examples to Postman collection."
|
|
13
13
|
spec.homepage = "https://github.com/kdan-mobile-software-ltd/rpdoc"
|
|
14
14
|
spec.license = "MIT"
|
|
15
|
-
spec.required_ruby_version = Gem::Requirement.new(">=
|
|
15
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
|
|
16
16
|
spec.metadata = {
|
|
17
17
|
"source_code_uri" => "https://github.com/kdan-mobile-software-ltd/rpdoc",
|
|
18
18
|
"changelog_uri" => "https://github.com/kdan-mobile-software-ltd/rpdoc/blob/master/CHANGELOG.md"
|
|
@@ -27,11 +27,6 @@ Gem::Specification.new do |spec|
|
|
|
27
27
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
28
28
|
spec.require_paths = ["lib"]
|
|
29
29
|
|
|
30
|
-
spec.
|
|
31
|
-
spec.
|
|
32
|
-
|
|
33
|
-
spec.add_development_dependency "pry", "~> 0.14", ">= 0.14.1"
|
|
34
|
-
spec.add_development_dependency "railties", ">= 7.1", "< 9.0"
|
|
35
|
-
spec.add_development_dependency "rspec", "~> 3.13"
|
|
36
|
-
spec.add_development_dependency "rubocop", "~> 1.78"
|
|
30
|
+
spec.add_dependency "activesupport", ">= 7.1", "< 9.0"
|
|
31
|
+
spec.add_dependency "json_requester", "~> 2.0", ">= 2.0.1"
|
|
37
32
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rpdoc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- yuntai
|
|
@@ -49,74 +49,6 @@ dependencies:
|
|
|
49
49
|
- - ">="
|
|
50
50
|
- !ruby/object:Gem::Version
|
|
51
51
|
version: 2.0.1
|
|
52
|
-
- !ruby/object:Gem::Dependency
|
|
53
|
-
name: pry
|
|
54
|
-
requirement: !ruby/object:Gem::Requirement
|
|
55
|
-
requirements:
|
|
56
|
-
- - "~>"
|
|
57
|
-
- !ruby/object:Gem::Version
|
|
58
|
-
version: '0.14'
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: 0.14.1
|
|
62
|
-
type: :development
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - "~>"
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0.14'
|
|
69
|
-
- - ">="
|
|
70
|
-
- !ruby/object:Gem::Version
|
|
71
|
-
version: 0.14.1
|
|
72
|
-
- !ruby/object:Gem::Dependency
|
|
73
|
-
name: railties
|
|
74
|
-
requirement: !ruby/object:Gem::Requirement
|
|
75
|
-
requirements:
|
|
76
|
-
- - ">="
|
|
77
|
-
- !ruby/object:Gem::Version
|
|
78
|
-
version: '7.1'
|
|
79
|
-
- - "<"
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '9.0'
|
|
82
|
-
type: :development
|
|
83
|
-
prerelease: false
|
|
84
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - ">="
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: '7.1'
|
|
89
|
-
- - "<"
|
|
90
|
-
- !ruby/object:Gem::Version
|
|
91
|
-
version: '9.0'
|
|
92
|
-
- !ruby/object:Gem::Dependency
|
|
93
|
-
name: rspec
|
|
94
|
-
requirement: !ruby/object:Gem::Requirement
|
|
95
|
-
requirements:
|
|
96
|
-
- - "~>"
|
|
97
|
-
- !ruby/object:Gem::Version
|
|
98
|
-
version: '3.13'
|
|
99
|
-
type: :development
|
|
100
|
-
prerelease: false
|
|
101
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
102
|
-
requirements:
|
|
103
|
-
- - "~>"
|
|
104
|
-
- !ruby/object:Gem::Version
|
|
105
|
-
version: '3.13'
|
|
106
|
-
- !ruby/object:Gem::Dependency
|
|
107
|
-
name: rubocop
|
|
108
|
-
requirement: !ruby/object:Gem::Requirement
|
|
109
|
-
requirements:
|
|
110
|
-
- - "~>"
|
|
111
|
-
- !ruby/object:Gem::Version
|
|
112
|
-
version: '1.78'
|
|
113
|
-
type: :development
|
|
114
|
-
prerelease: false
|
|
115
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
116
|
-
requirements:
|
|
117
|
-
- - "~>"
|
|
118
|
-
- !ruby/object:Gem::Version
|
|
119
|
-
version: '1.78'
|
|
120
52
|
description: Rpdoc is a simple Postman API documentation tool, which transforms RSpec
|
|
121
53
|
examples to Postman collection.
|
|
122
54
|
email:
|
|
@@ -142,6 +74,7 @@ files:
|
|
|
142
74
|
- LICENSE
|
|
143
75
|
- README.md
|
|
144
76
|
- Rakefile
|
|
77
|
+
- SECURITY.md
|
|
145
78
|
- VERSION.md
|
|
146
79
|
- bin/console
|
|
147
80
|
- bin/setup
|
|
@@ -169,7 +102,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
169
102
|
requirements:
|
|
170
103
|
- - ">="
|
|
171
104
|
- !ruby/object:Gem::Version
|
|
172
|
-
version:
|
|
105
|
+
version: 3.0.0
|
|
173
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
107
|
requirements:
|
|
175
108
|
- - ">="
|