r2-oas 0.4.1 → 0.6.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 +21 -1
- data/README.ja.md +115 -37
- data/README.md +120 -44
- data/lib/r2-oas/app_configuration.rb +1 -1
- data/lib/r2-oas/configuration/paths_config.rb +7 -4
- data/lib/r2-oas/configuration.rb +24 -34
- data/lib/r2-oas/deploy/client.rb +74 -18
- data/lib/r2-oas/deploy/swagger-ui/dist/favicon-16x16.png +0 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/favicon-32x32.png +0 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/index.css +16 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/index.html +19 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.html +6 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.js +1 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-initializer.js +20 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js +2 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-es-bundle-core.js +3 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-es-bundle.js +2 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js +2 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css +3 -0
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js +2 -0
- data/lib/r2-oas/helpers/file_helper.rb +68 -0
- data/lib/r2-oas/hooks/hook.rb +2 -2
- data/lib/r2-oas/plugin/base.rb +4 -4
- data/lib/r2-oas/plugin/executor.rb +6 -6
- data/lib/r2-oas/plugin/hookable.rb +7 -2
- data/lib/r2-oas/plugin/transform/transform.rb +2 -2
- data/lib/r2-oas/public.rb +0 -2
- data/lib/r2-oas/routing/components/path_component.rb +3 -3
- data/lib/r2-oas/schema/editor.rb +116 -48
- data/lib/r2-oas/schema/monitor.rb +37 -19
- data/lib/r2-oas/schema/ui.rb +29 -18
- data/lib/r2-oas/schema/v3/analyzer/base_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/builder/base_builder.rb +1 -1
- data/lib/r2-oas/schema/v3/generator/base_generator.rb +3 -3
- data/lib/r2-oas/schema/v3/generator/doc_generator.rb +1 -1
- data/lib/r2-oas/schema/v3/generator/schema_generator.rb +1 -1
- data/lib/r2-oas/schema/v3/manager/diff/base_hash_diff_manager.rb +1 -1
- data/lib/r2-oas/schema/v3/manager/file/base_file_manager.rb +3 -3
- data/lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb +5 -5
- data/lib/r2-oas/schema/v3/object/from_files/base_object.rb +2 -2
- data/lib/r2-oas/schema/v3/object/from_files/components/request_body_object.rb +2 -2
- data/lib/r2-oas/schema/v3/object/from_files/components/schema_object.rb +2 -2
- data/lib/r2-oas/schema/v3/object/from_files/path_item_object.rb +3 -3
- data/lib/r2-oas/schema/v3/object/from_files/utils/deep_methods.rb +2 -2
- data/lib/r2-oas/schema/v3/object/from_routes/base_object.rb +4 -38
- data/lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb +6 -19
- data/lib/r2-oas/schema/v3/object/from_routes/components/schema_object.rb +4 -12
- data/lib/r2-oas/schema/v3/object/from_routes/components_object.rb +13 -7
- data/lib/r2-oas/schema/v3/object/from_routes/external_document_object.rb +2 -4
- data/lib/r2-oas/schema/v3/object/from_routes/info_object.rb +2 -4
- data/lib/r2-oas/schema/v3/object/from_routes/openapi_object.rb +9 -5
- data/lib/r2-oas/schema/v3/object/from_routes/path_item_object.rb +7 -6
- data/lib/r2-oas/schema/v3/object/from_routes/paths_object.rb +10 -30
- data/lib/r2-oas/schema/v3/object/from_routes/server_object.rb +2 -2
- data/lib/r2-oas/shared/sortable.rb +1 -1
- data/lib/r2-oas/support/deprecation/reporting.rb +3 -3
- data/lib/r2-oas/task_logging.rb +2 -2
- data/lib/r2-oas/tasks/main.rake +3 -4
- data/lib/r2-oas/version.rb +1 -1
- data/lib/r2-oas.rb +2 -1
- data/r2-oas.gemspec +6 -15
- metadata +50 -143
- data/lib/r2-oas/dynamic/schema/v3/object/from_routes/hookable_base_object.rb +0 -100
- data/lib/r2-oas/pluggable_configuration.rb +0 -36
- /data/lib/r2-oas/schema/v3/object/from_routes/{public.rb → all.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2e9fd7edc6de218fe86bcde7dfa51d219d541b52cb8a6ee75f9bb37ed85761d9
|
|
4
|
+
data.tar.gz: af082eb9c7a450aa13414046eb1a7be19ebd2140a03b499368019d6a5ef17c3a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 6599b3911308383a080da4b8ef78ffc046ebfc621a78c878afaa96d32241c60163c9a4c305cf9b23bac06d1e681dbc18a418e881b2264454b7a0de9dac40d2e2
|
|
7
|
+
data.tar.gz: 22f6aa0517f3315acfa779305884382e5291873696066ae7d81868fdcc9d2610fca2483a405616bfdf99ff14f2edaf637d23c1645127cab8eba57780c090742b
|
data/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,24 @@
|
|
|
1
|
-
#
|
|
1
|
+
# CHANGELOG
|
|
2
|
+
|
|
3
|
+
## v0.6.0
|
|
4
|
+
|
|
5
|
+
2025-11-01
|
|
6
|
+
|
|
7
|
+
- [`EOL`] EOL Ruby `2.x` and Support over Ruby `3.x` ([#184](https://github.com/yukihirop/r2-oas/pull/184))
|
|
8
|
+
- [`EOL`] EOL Rails `6.x ↓` and Support over Rails `7.2.2.2` and Rails `8.x` ([#186](https://github.com/yukihirop/r2-oas/pull/186))
|
|
9
|
+
- [`Feature`] add `rbs` and configure `steep` ([#187](https://github.com/yukihirop/r2-oas/pull/187))
|
|
10
|
+
|
|
11
|
+
Please see mileston [v0.6.0](https://github.com/yukihirop/r2-oas/milestone/8)
|
|
12
|
+
|
|
13
|
+
## v0.5.0
|
|
14
|
+
|
|
15
|
+
2020-01-29
|
|
16
|
+
|
|
17
|
+
- [`Breaking`] Remove `use_object_classes` option ([#171](https://github.com/yukihirop/r2-oas/pull/171))
|
|
18
|
+
- [`Feature`] Upgrade init command ([#176](https://github.com/yukihirop/r2-oas/pull/176))
|
|
19
|
+
- [`EOL`] EOL Ruby `2.3` and Support over Ruby `2.5.0` ([#170](https://github.com/yukihirop/r2-oas/pull/170))
|
|
20
|
+
|
|
21
|
+
Please see mileston [v0.5.0](https://github.com/yukihirop/r2-oas/milestone/5?closed=1)
|
|
2
22
|
|
|
3
23
|
## v0.4.1
|
|
4
24
|
|
data/README.ja.md
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
|
-
# R2-OAS
|
|
2
|
-
|
|
3
1
|
[](https://badge.fury.io/rb/r2-oas)
|
|
4
2
|
[](https://travis-ci.org/yukihirop/r2-oas)
|
|
5
3
|
[](https://coveralls.io/github/yukihirop/r2-oas)
|
|
6
4
|
[](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
|
|
7
5
|
|
|
6
|
+
|
|
7
|
+
<p align="center">
|
|
8
|
+
<img alt="logo" width="196" src="https://raw.githubusercontent.com/yukihirop/r2-oas/master/docs/assets/logo.png">
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<h1 align="center" style="font-family: sans-serif; font-size: 50px; font-weight: 700; background: -webkit-linear-gradient(90deg, #CC342D 20%, #E63D36 60%, #FF5C55 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;">R2-OAS</h1>
|
|
12
|
+
|
|
13
|
+
<p align="center">
|
|
14
|
+
<a href="https://yukihirop.github.io/r2-oas/" target="_blank">📚 Documentation</a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
|
|
8
18
|
Railsのルーティング情報からOpenAPI形式のドキュメントを生成し、閲覧・編集・管理するためのrakeタスクの提供をします。
|
|
9
19
|
|
|
10
20
|
```bash
|
|
11
|
-
bundle exec rake routes:oas:init #
|
|
12
|
-
bundle exec rake routes:oas:docs #
|
|
13
|
-
bundle exec rake routes:oas:ui #
|
|
14
|
-
bundle exec rake routes:oas:editor #
|
|
15
|
-
bundle exec rake routes:oas:monitor #
|
|
16
|
-
bundle exec rake routes:oas:build #
|
|
17
|
-
bundle exec rake routes:oas:clean #
|
|
18
|
-
bundle exec rake routes:oas:analyze #
|
|
19
|
-
bundle exec rake routes:oas:deploy #
|
|
21
|
+
bundle exec rake routes:oas:init # r2-oasを初期化
|
|
22
|
+
bundle exec rake routes:oas:docs # oas_docsを生成
|
|
23
|
+
bundle exec rake routes:oas:ui # swagger uiで閲覧
|
|
24
|
+
bundle exec rake routes:oas:editor # swagger editorで編集
|
|
25
|
+
bundle exec rake routes:oas:monitor # oas_docsを監視・分析
|
|
26
|
+
bundle exec rake routes:oas:build # srcからoas_docsをビルド
|
|
27
|
+
bundle exec rake routes:oas:clean # 未使用コンポーネントを削除
|
|
28
|
+
bundle exec rake routes:oas:analyze # oas_docsを分析・srcを生成
|
|
29
|
+
bundle exec rake routes:oas:deploy # oas_docsをdeploy_docsにデプロイ
|
|
20
30
|
```
|
|
21
31
|
|
|
22
32
|
## 💎 Installation
|
|
@@ -42,7 +52,7 @@ end
|
|
|
42
52
|
```
|
|
43
53
|
$ docker pull swaggerapi/swagger-editor:latest
|
|
44
54
|
$ docker pull swaggerapi/swagger-ui:latest
|
|
45
|
-
$ brew
|
|
55
|
+
$ brew install chromedriver
|
|
46
56
|
```
|
|
47
57
|
|
|
48
58
|
## 🚀 Tutorial
|
|
@@ -50,18 +60,30 @@ $ brew cask install chromedriver
|
|
|
50
60
|
gemをrequire後、以下のrakeタスクを実行するだけです。
|
|
51
61
|
|
|
52
62
|
```bash
|
|
53
|
-
bundle exec routes:oas:
|
|
54
|
-
|
|
63
|
+
$ bundle exec rake routes:oas:init
|
|
64
|
+
create oas_docs
|
|
65
|
+
create oas_docs/.paths
|
|
66
|
+
create oas_docs/plugins/helpers
|
|
67
|
+
create oas_docs/tasks/helpers
|
|
68
|
+
create oas_docs/plugins/.gitkeep
|
|
69
|
+
create oas_docs/plugins/helpers/.gitkeep
|
|
70
|
+
create oas_docs/tasks/.gitkeep
|
|
71
|
+
create oas_docs/tasks/helpers/.gitkeep
|
|
72
|
+
$ bundle exec rake routes:oas:docs
|
|
73
|
+
$ bundle exec rake routes:oas:editor
|
|
55
74
|
```
|
|
56
75
|
|
|
57
76
|
#### Generate docs
|
|
58
77
|
|
|
59
|
-
|
|
60
|
-
|
|
78
|
+
<p align="center">
|
|
79
|
+
<img alt="r2-oas docs demo" width="800" src="https://raw.githubusercontent.com/yukihirop/r2-oas/master/demo/oas_docs.mp4">
|
|
80
|
+
</p>
|
|
61
81
|
|
|
62
82
|
#### Edit docs
|
|
63
83
|
|
|
64
|
-
|
|
84
|
+
<p align="center">
|
|
85
|
+
<img alt="r2-oas editor demo" width="800" src="https://raw.githubusercontent.com/yukihirop/r2-oas/master/demo/oas_editor.mp4">
|
|
86
|
+
</p>
|
|
65
87
|
|
|
66
88
|
## 📚 Documents
|
|
67
89
|
|
|
@@ -79,6 +101,14 @@ railsプロジェクトのルートディレクトリで以下のコマンドが
|
|
|
79
101
|
|
|
80
102
|
```bash
|
|
81
103
|
$ bundle exec rake routes:oas:init
|
|
104
|
+
create oas_docs
|
|
105
|
+
create oas_docs/.paths
|
|
106
|
+
create oas_docs/plugins/helpers
|
|
107
|
+
create oas_docs/tasks/helpers
|
|
108
|
+
create oas_docs/plugins/.gitkeep
|
|
109
|
+
create oas_docs/plugins/helpers/.gitkeep
|
|
110
|
+
create oas_docs/tasks/.gitkeep
|
|
111
|
+
create oas_docs/tasks/helpers/.gitkeep
|
|
82
112
|
```
|
|
83
113
|
|
|
84
114
|
### Generate
|
|
@@ -137,11 +167,14 @@ $ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
|
|
|
137
167
|
|
|
138
168
|
## ❤️ Support Rails Version
|
|
139
169
|
|
|
140
|
-
- Rails
|
|
170
|
+
- Rails 7.2.2.2
|
|
171
|
+
- Rails (>= 8.x)
|
|
141
172
|
|
|
142
173
|
## ❤️ Support Ruby Version
|
|
143
174
|
|
|
144
|
-
- Ruby
|
|
175
|
+
- Ruby 3.2.6
|
|
176
|
+
- Ruby 3.3.6
|
|
177
|
+
- Ruby (>= 3.4.x)
|
|
145
178
|
|
|
146
179
|
## ❤️ Support Rouging
|
|
147
180
|
|
|
@@ -175,6 +208,55 @@ OpenAPIの3.0.0をサポートしてます。
|
|
|
175
208
|
|
|
176
209
|
公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/setting/configure
|
|
177
210
|
|
|
211
|
+
## RBS, Steep
|
|
212
|
+
|
|
213
|
+
```bash
|
|
214
|
+
# エラーが出ていたら、エディタでhoverしても型の表示がされない原因になる
|
|
215
|
+
bundle exec steep stats
|
|
216
|
+
# エラーの内容は、こちらのコマンドで知ることができる
|
|
217
|
+
bundle exec steep check
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
#### steep rake task
|
|
221
|
+
|
|
222
|
+
```bash
|
|
223
|
+
bundle exec rake steep:ignore:dig | pbcopy
|
|
224
|
+
# =>
|
|
225
|
+
#
|
|
226
|
+
# ignore 'RBS::DuplicatedMethodDefinition'
|
|
227
|
+
# ignore 'Ruby::ArgumentTypeMismatch'
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
```bash
|
|
231
|
+
bundle exec rake steep:ignore:file | pbcopy
|
|
232
|
+
# =>
|
|
233
|
+
#
|
|
234
|
+
# ignore 'lib/r2-oas.rb'
|
|
235
|
+
# ignore 'lib/r2-oas/app_configuration.rb'
|
|
236
|
+
# ignore 'lib/r2-oas/app_configuration/deprecation.rb'
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
```bash
|
|
240
|
+
bundle exec rake steep:ignore:preview
|
|
241
|
+
# =>
|
|
242
|
+
# 📄 lib/r2-oas/schema/monitor.rb
|
|
243
|
+
# Line 50: if current_time - last_check_time >= interval_to_save_edited_tmp_schema
|
|
244
|
+
# → if current_time - last_check_time >= interval_to_save_edited_tmp_schema # steep:ignore Ruby::NoMethod
|
|
245
|
+
# Line 62: analyzer.analyze_docs
|
|
246
|
+
# → analyzer.analyze_docs # steep:ignore Ruby::NoMethod
|
|
247
|
+
# Line 66: YAML.load_file(doc_save_file_path) || @after_schema_data
|
|
248
|
+
# → YAML.load_file(doc_save_file_path) || @after_schema_data # steep:ignore Ruby::UnknownConstant
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
bundle exec rake steep:ignore:auto
|
|
253
|
+
# =>
|
|
254
|
+
# Analyzing steep check errors...
|
|
255
|
+
# ✅ Modified: lib/r2-oas/app_configuration/deprecation.rb (2 lines)
|
|
256
|
+
# ✅ Modified: lib/r2-oas/plugin/base.rb (3 lines)
|
|
257
|
+
# ✅ Modified: lib/r2-oas/schema/squeezer.rb (2 lines)
|
|
258
|
+
```
|
|
259
|
+
|
|
178
260
|
## Bundle and Rspec with multiple ruby versions
|
|
179
261
|
|
|
180
262
|
#### Bundle
|
|
@@ -185,24 +267,22 @@ OpenAPIの3.0.0をサポートしてます。
|
|
|
185
267
|
.
|
|
186
268
|
.
|
|
187
269
|
===== Bundle install for All Support Ruby Result =====
|
|
188
|
-
ruby-2.
|
|
189
|
-
ruby-
|
|
190
|
-
ruby-
|
|
191
|
-
ruby-2.6.6: 0
|
|
192
|
-
ruby-2.7.1: 0
|
|
270
|
+
ruby-3.2.6: 0
|
|
271
|
+
ruby-3.3.6: 0
|
|
272
|
+
ruby-3.4.7: 0
|
|
193
273
|
======================================================
|
|
194
274
|
```
|
|
195
275
|
|
|
196
|
-
rubyのバージョンを `2.6
|
|
276
|
+
rubyのバージョンを `3.2.6` と `3.3.6` に指定する場合
|
|
197
277
|
|
|
198
278
|
```bash
|
|
199
|
-
/bin/bash devscript/all_support_ruby.sh bundle 2.6
|
|
279
|
+
/bin/bash devscript/all_support_ruby.sh bundle 3.2.6 3.3.6
|
|
200
280
|
.
|
|
201
281
|
.
|
|
202
282
|
.
|
|
203
283
|
===== Bundle install for All Support Ruby Result =====
|
|
204
|
-
ruby-2.6
|
|
205
|
-
ruby-
|
|
284
|
+
ruby-3.2.6: 0
|
|
285
|
+
ruby-3.3.6: 0
|
|
206
286
|
======================================================
|
|
207
287
|
```
|
|
208
288
|
|
|
@@ -214,24 +294,22 @@ ruby-2.7.1: 0
|
|
|
214
294
|
.
|
|
215
295
|
.
|
|
216
296
|
===== Rspec for All Support Ruby Result =====
|
|
217
|
-
ruby-2.
|
|
218
|
-
ruby-
|
|
219
|
-
ruby-
|
|
220
|
-
ruby-2.6.6: 0
|
|
221
|
-
ruby-2.7.1: 0
|
|
297
|
+
ruby-3.2.6: 0
|
|
298
|
+
ruby-3.3.6: 0
|
|
299
|
+
ruby-3.4.7: 0
|
|
222
300
|
=============================================
|
|
223
301
|
```
|
|
224
302
|
|
|
225
|
-
rubyのバージョンを `2.6
|
|
303
|
+
rubyのバージョンを `3.2.6` と `3.3.6` に指定する場合
|
|
226
304
|
|
|
227
305
|
```bash
|
|
228
|
-
/bin/bash devscript/all_support_ruby.sh rspec 2.6
|
|
306
|
+
/bin/bash devscript/all_support_ruby.sh rspec 3.2.6 3.3.6
|
|
229
307
|
.
|
|
230
308
|
.
|
|
231
309
|
.
|
|
232
310
|
===== Rspec for All Support Ruby Result =====
|
|
233
|
-
ruby-2.6
|
|
234
|
-
ruby-
|
|
311
|
+
ruby-3.2.6: 0
|
|
312
|
+
ruby-3.3.6: 0
|
|
235
313
|
=============================================
|
|
236
314
|
```
|
|
237
315
|
|
data/README.md
CHANGED
|
@@ -1,24 +1,32 @@
|
|
|
1
|
-
# R2-OAS
|
|
2
|
-
|
|
3
1
|
[](https://badge.fury.io/rb/r2-oas)
|
|
4
2
|
[](https://travis-ci.org/yukihirop/r2-oas)
|
|
5
3
|
[](https://coveralls.io/github/yukihirop/r2-oas)
|
|
6
4
|
[](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
|
|
7
5
|
|
|
8
|
-
|
|
6
|
+
<p align="center">
|
|
7
|
+
<img alt="logo" width="196" src="https://raw.githubusercontent.com/yukihirop/r2-oas/master/docs/assets/logo.png">
|
|
8
|
+
</p>
|
|
9
|
+
|
|
10
|
+
<h1 align="center" style="font-family: sans-serif; font-size: 50px; font-weight: 700; background: -webkit-linear-gradient(90deg, #CC342D 20%, #E63D36 60%, #FF5C55 100%); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent;">R2-OAS</h1>
|
|
11
|
+
|
|
12
|
+
<p align="center">
|
|
13
|
+
<a href="https://yukihirop.github.io/r2-oas/" target="_blank">📚 Documentation</a>
|
|
14
|
+
</p>
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
Generate api document (OpenAPI) side only from `Rails` routing.
|
|
17
|
+
|
|
18
|
+
Provides a rake command to help `generate`, `view`, and `edit` OpenAPI documents.
|
|
11
19
|
|
|
12
20
|
```bash
|
|
13
|
-
|
|
14
|
-
bundle exec rake routes:oas:docs # generate
|
|
15
|
-
bundle exec rake routes:oas:ui # view
|
|
16
|
-
bundle exec rake routes:oas:editor # edit
|
|
17
|
-
bundle exec rake routes:oas:monitor # monitor
|
|
18
|
-
bundle exec rake routes:oas:build # build
|
|
19
|
-
bundle exec rake routes:oas:clean # clean
|
|
20
|
-
bundle exec rake routes:oas:analyze # analyze
|
|
21
|
-
bundle exec rake routes:oas:deploy # deploy
|
|
21
|
+
bundle exec rake routes:oas:init # r2-oas initialize
|
|
22
|
+
bundle exec rake routes:oas:docs # generate oas_docs
|
|
23
|
+
bundle exec rake routes:oas:ui # view at swagger ui
|
|
24
|
+
bundle exec rake routes:oas:editor # edit at swagger editor
|
|
25
|
+
bundle exec rake routes:oas:monitor # monitor oas_docs and analyze
|
|
26
|
+
bundle exec rake routes:oas:build # build oas_docs from src
|
|
27
|
+
bundle exec rake routes:oas:clean # clean unused components
|
|
28
|
+
bundle exec rake routes:oas:analyze # analyze oas_docs and generae src
|
|
29
|
+
bundle exec rake routes:oas:deploy # deploy oas_docs to deploy_docs
|
|
22
30
|
```
|
|
23
31
|
|
|
24
32
|
## 💎 Installation
|
|
@@ -52,7 +60,7 @@ If you do not have it download as below.
|
|
|
52
60
|
```
|
|
53
61
|
$ docker pull swaggerapi/swagger-editor:latest
|
|
54
62
|
$ docker pull swaggerapi/swagger-ui:latest
|
|
55
|
-
$ brew
|
|
63
|
+
$ brew install chromedriver
|
|
56
64
|
```
|
|
57
65
|
|
|
58
66
|
## 🚀 Tutorial
|
|
@@ -64,18 +72,30 @@ R2OAS.load_tasks
|
|
|
64
72
|
```
|
|
65
73
|
|
|
66
74
|
```bash
|
|
67
|
-
bundle exec routes:oas:
|
|
68
|
-
|
|
75
|
+
$ bundle exec rake routes:oas:init
|
|
76
|
+
create oas_docs
|
|
77
|
+
create oas_docs/.paths
|
|
78
|
+
create oas_docs/plugins/helpers
|
|
79
|
+
create oas_docs/tasks/helpers
|
|
80
|
+
create oas_docs/plugins/.gitkeep
|
|
81
|
+
create oas_docs/plugins/helpers/.gitkeep
|
|
82
|
+
create oas_docs/tasks/.gitkeep
|
|
83
|
+
create oas_docs/tasks/helpers/.gitkeep
|
|
84
|
+
$ bundle exec rake routes:oas:docs
|
|
85
|
+
$ bundle exec rake routes:oas:editor
|
|
69
86
|
```
|
|
70
87
|
|
|
71
88
|
#### Generate docs
|
|
72
89
|
|
|
73
|
-
|
|
74
|
-
|
|
90
|
+
<p align="center">
|
|
91
|
+
<img alt="r2-oas docs demo" width="800" src="https://raw.githubusercontent.com/yukihirop/r2-oas/master/demo/oas_docs.mp4">
|
|
92
|
+
</p>
|
|
75
93
|
|
|
76
94
|
#### Edit docs
|
|
77
95
|
|
|
78
|
-
|
|
96
|
+
<p align="center">
|
|
97
|
+
<img alt="r2-oas editor demo" width="800" src="https://raw.githubusercontent.com/yukihirop/r2-oas/master/demo/oas_editor.mp4">
|
|
98
|
+
</p>
|
|
79
99
|
|
|
80
100
|
## Usage
|
|
81
101
|
|
|
@@ -90,6 +110,14 @@ Initialize r2-oas.
|
|
|
90
110
|
|
|
91
111
|
```bash
|
|
92
112
|
$ bundle exec rake routes:oas:init
|
|
113
|
+
create oas_docs
|
|
114
|
+
create oas_docs/.paths
|
|
115
|
+
create oas_docs/plugins/helpers
|
|
116
|
+
create oas_docs/tasks/helpers
|
|
117
|
+
create oas_docs/plugins/.gitkeep
|
|
118
|
+
create oas_docs/plugins/helpers/.gitkeep
|
|
119
|
+
create oas_docs/tasks/.gitkeep
|
|
120
|
+
create oas_docs/tasks/helpers/.gitkeep
|
|
93
121
|
```
|
|
94
122
|
|
|
95
123
|
### Generate
|
|
@@ -103,7 +131,7 @@ $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas
|
|
|
103
131
|
|
|
104
132
|
### Editor
|
|
105
133
|
|
|
106
|
-
Start
|
|
134
|
+
Start Swagger editor.
|
|
107
135
|
|
|
108
136
|
```bash
|
|
109
137
|
$ bundle exec rake routes:oas:editor # Start swagger editor
|
|
@@ -143,11 +171,14 @@ Full docs are available at https://yukihirop.github.io/r2-oas
|
|
|
143
171
|
|
|
144
172
|
## ❤️ Support Rails Version
|
|
145
173
|
|
|
146
|
-
- Rails
|
|
174
|
+
- Rails 7.2.2.2
|
|
175
|
+
- Rails (>= 8.x)
|
|
147
176
|
|
|
148
177
|
## ❤️ Support Ruby Version
|
|
149
178
|
|
|
150
|
-
- Ruby
|
|
179
|
+
- Ruby 3.2.6
|
|
180
|
+
- Ruby 3.3.6
|
|
181
|
+
- Ruby (>= 3.4.x)
|
|
151
182
|
|
|
152
183
|
## ❤️ Support Rouging
|
|
153
184
|
|
|
@@ -160,15 +191,15 @@ Full docs are available at https://yukihirop.github.io/r2-oas/#/schema/3.0.0
|
|
|
160
191
|
|
|
161
192
|
## ❗️ Convention over Configuration (CoC)
|
|
162
193
|
|
|
163
|
-
- `tag name` represents `controller name` and
|
|
164
|
-
- For example, If `controller name` is `Api::V1::UsersController`, `tag_name` is `api/v1/user
|
|
194
|
+
- `tag name` represents `controller name` and determines `paths file name`.
|
|
195
|
+
- For example, If `controller name` is `Api::V1::UsersController`, `tag_name` is `api/v1/user`, then `paths file name` is `api/v1/user.yml`
|
|
165
196
|
|
|
166
197
|
- `_` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
|
|
167
198
|
- For example, If `components/schemas name` is `Api_V1_User`, `components/schemas file name` is `api/v1/user.yml`.
|
|
168
199
|
- `_` is supposed to be used to express `namespace`.
|
|
169
200
|
- format is `Namespace1_Namespace2_Model`.
|
|
170
201
|
|
|
171
|
-
- `.` of `components/{schemas,requestBodies, ...} name` convert `/` when
|
|
202
|
+
- `.` of `components/{schemas,requestBodies, ...} name` convert `/` when saving the file.
|
|
172
203
|
- For example, If `components/schemas name` is `api.v1.User`, `components/schemas file name` is `api/v1/user.yml`.
|
|
173
204
|
- `.` is supposed to be used to express `namespace`.
|
|
174
205
|
- format is `namespace1.namespace2.Model`.
|
|
@@ -179,6 +210,55 @@ All settings are `optional`
|
|
|
179
210
|
|
|
180
211
|
Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configure
|
|
181
212
|
|
|
213
|
+
## RBS, Steep
|
|
214
|
+
|
|
215
|
+
```bash
|
|
216
|
+
# Errors here can prevent type information from showing when hovering in the editor
|
|
217
|
+
bundle exec steep stats
|
|
218
|
+
# You can check the error details with this command
|
|
219
|
+
bundle exec steep check
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
#### steep rake task
|
|
223
|
+
|
|
224
|
+
```bash
|
|
225
|
+
bundle exec rake steep:ignore:dig | pbcopy
|
|
226
|
+
# =>
|
|
227
|
+
#
|
|
228
|
+
# ignore 'RBS::DuplicatedMethodDefinition'
|
|
229
|
+
# ignore 'Ruby::ArgumentTypeMismatch'
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
bundle exec rake steep:ignore:file | pbcopy
|
|
234
|
+
# =>
|
|
235
|
+
#
|
|
236
|
+
# ignore 'lib/r2-oas.rb'
|
|
237
|
+
# ignore 'lib/r2-oas/app_configuration.rb'
|
|
238
|
+
# ignore 'lib/r2-oas/app_configuration/deprecation.rb'
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
bundle exec rake steep:ignore:preview
|
|
243
|
+
# =>
|
|
244
|
+
# 📄 lib/r2-oas/schema/monitor.rb
|
|
245
|
+
# Line 50: if current_time - last_check_time >= interval_to_save_edited_tmp_schema
|
|
246
|
+
# → if current_time - last_check_time >= interval_to_save_edited_tmp_schema # steep:ignore Ruby::NoMethod
|
|
247
|
+
# Line 62: analyzer.analyze_docs
|
|
248
|
+
# → analyzer.analyze_docs # steep:ignore Ruby::NoMethod
|
|
249
|
+
# Line 66: YAML.load_file(doc_save_file_path) || @after_schema_data
|
|
250
|
+
# → YAML.load_file(doc_save_file_path) || @after_schema_data # steep:ignore Ruby::UnknownConstant
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
```bash
|
|
254
|
+
bundle exec rake steep:ignore:auto
|
|
255
|
+
# =>
|
|
256
|
+
# Analyzing steep check errors...
|
|
257
|
+
# ✅ Modified: lib/r2-oas/app_configuration/deprecation.rb (2 lines)
|
|
258
|
+
# ✅ Modified: lib/r2-oas/plugin/base.rb (3 lines)
|
|
259
|
+
# ✅ Modified: lib/r2-oas/schema/squeezer.rb (2 lines)
|
|
260
|
+
```
|
|
261
|
+
|
|
182
262
|
## Bundle and Rspec with multiple ruby versions
|
|
183
263
|
|
|
184
264
|
#### Bundle
|
|
@@ -189,24 +269,22 @@ Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configur
|
|
|
189
269
|
.
|
|
190
270
|
.
|
|
191
271
|
===== Bundle install for All Support Ruby Result =====
|
|
192
|
-
ruby-2.
|
|
193
|
-
ruby-
|
|
194
|
-
ruby-
|
|
195
|
-
ruby-2.6.6: 0
|
|
196
|
-
ruby-2.7.1: 0
|
|
272
|
+
ruby-3.2.6: 0
|
|
273
|
+
ruby-3.3.6: 0
|
|
274
|
+
ruby-3.4.7: 0
|
|
197
275
|
======================================================
|
|
198
276
|
```
|
|
199
277
|
|
|
200
|
-
If specify ruby version `2.6
|
|
278
|
+
If specify ruby version `3.2.6` and `3.3.6`
|
|
201
279
|
|
|
202
280
|
```bash
|
|
203
|
-
/bin/bash devscript/all_support_ruby.sh bundle 2.6
|
|
281
|
+
/bin/bash devscript/all_support_ruby.sh bundle 3.2.6 3.3.6
|
|
204
282
|
.
|
|
205
283
|
.
|
|
206
284
|
.
|
|
207
285
|
===== Bundle install for All Support Ruby Result =====
|
|
208
|
-
ruby-2.6
|
|
209
|
-
ruby-
|
|
286
|
+
ruby-3.2.6: 0
|
|
287
|
+
ruby-3.3.6: 0
|
|
210
288
|
======================================================
|
|
211
289
|
```
|
|
212
290
|
|
|
@@ -218,24 +296,22 @@ ruby-2.7.1: 0
|
|
|
218
296
|
.
|
|
219
297
|
.
|
|
220
298
|
===== Rspec for All Support Ruby Result =====
|
|
221
|
-
ruby-2.
|
|
222
|
-
ruby-
|
|
223
|
-
ruby-
|
|
224
|
-
ruby-2.6.6: 0
|
|
225
|
-
ruby-2.7.1: 0
|
|
299
|
+
ruby-3.2.6: 0
|
|
300
|
+
ruby-3.3.6: 0
|
|
301
|
+
ruby-3.4.7: 0
|
|
226
302
|
=============================================
|
|
227
303
|
```
|
|
228
304
|
|
|
229
|
-
If specify ruby version `2.6
|
|
305
|
+
If specify ruby version `3.2.6` and `3.3.6`
|
|
230
306
|
|
|
231
307
|
```bash
|
|
232
|
-
/bin/bash devscript/all_support_ruby.sh rspec 2.6
|
|
308
|
+
/bin/bash devscript/all_support_ruby.sh rspec 3.2.6 3.3.6
|
|
233
309
|
.
|
|
234
310
|
.
|
|
235
311
|
.
|
|
236
312
|
===== Rspec for All Support Ruby Result =====
|
|
237
|
-
ruby-2.6
|
|
238
|
-
ruby-
|
|
313
|
+
ruby-3.2.6: 0
|
|
314
|
+
ruby-3.3.6: 0
|
|
239
315
|
=============================================
|
|
240
316
|
```
|
|
241
317
|
|
|
@@ -253,7 +329,7 @@ use Rack::Cors do
|
|
|
253
329
|
end
|
|
254
330
|
```
|
|
255
331
|
|
|
256
|
-
Alternatively you can set CORS headers in a `before` block.
|
|
332
|
+
Alternatively, you can set CORS headers in a `before` block.
|
|
257
333
|
|
|
258
334
|
```ruby
|
|
259
335
|
before do
|
|
@@ -14,7 +14,7 @@ module R2OAS
|
|
|
14
14
|
DEFAULT_USE_TAG_NAMESPACE = true
|
|
15
15
|
DEFAULT_USE_SCHEMA_NAMESPACE = true
|
|
16
16
|
DEFAULT_SERVER = Server.new
|
|
17
|
-
DEFAULT_INTERVAL_TO_SAVE_EDITED_TMP_SCHEMA =
|
|
17
|
+
DEFAULT_INTERVAL_TO_SAVE_EDITED_TMP_SCHEMA = 0.5
|
|
18
18
|
DEFAULT_SWAGGER = Swagger.new
|
|
19
19
|
# rubocop:disable Style/MutableConstant
|
|
20
20
|
DEFAULT_HTTP_STATUSES_WHEN_HTTP_METHOD = {
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'r2-oas/schema/manager/file/path_item_file_manager'
|
|
4
|
+
require 'r2-oas/helpers/file_helper'
|
|
4
5
|
|
|
5
6
|
module R2OAS
|
|
6
7
|
module Configuration
|
|
7
8
|
class PathsConfig
|
|
9
|
+
include Helpers::FileHelper
|
|
10
|
+
|
|
8
11
|
def initialize(root_dir_path, schema_save_dir_name)
|
|
9
12
|
@root_dir_path = root_dir_path
|
|
10
13
|
@schema_save_dir_path = "#{root_dir_path}/#{schema_save_dir_name}"
|
|
@@ -21,15 +24,15 @@ module R2OAS
|
|
|
21
24
|
def many_paths_file_paths
|
|
22
25
|
@many_paths_file_paths ||= File.read(abs_paths_path).split("\n").each_with_object([]) do |relative_path, result|
|
|
23
26
|
abs_path = File.expand_path("#{@schema_save_dir_path}/paths/#{relative_path}")
|
|
24
|
-
result.push(abs_path) if FileTest.
|
|
27
|
+
result.push(abs_path) if FileTest.exist?(abs_path) && FileTest.file?(abs_path)
|
|
25
28
|
end.uniq.compact.reject(&:empty?)
|
|
26
29
|
end
|
|
27
30
|
|
|
28
|
-
def create_dot_paths
|
|
31
|
+
def create_dot_paths(silent = true)
|
|
29
32
|
abs_root_path = File.expand_path(@root_dir_path)
|
|
30
33
|
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
mkdir_p_dir_or_skip(abs_root_path, silent)
|
|
35
|
+
write_file_or_skip(abs_paths_path, '', silent)
|
|
33
36
|
end
|
|
34
37
|
|
|
35
38
|
def many_components_file_paths
|