r2-oas 0.5.0 → 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.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -0
  3. data/README.ja.md +96 -31
  4. data/README.md +101 -38
  5. data/lib/r2-oas/app_configuration.rb +1 -1
  6. data/lib/r2-oas/configuration/paths_config.rb +1 -1
  7. data/lib/r2-oas/configuration.rb +6 -6
  8. data/lib/r2-oas/deploy/client.rb +74 -18
  9. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-16x16.png +0 -0
  10. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-32x32.png +0 -0
  11. data/lib/r2-oas/deploy/swagger-ui/dist/index.css +16 -0
  12. data/lib/r2-oas/deploy/swagger-ui/dist/index.html +19 -0
  13. data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.html +6 -0
  14. data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.js +1 -0
  15. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-initializer.js +20 -0
  16. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js +2 -0
  17. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-es-bundle-core.js +3 -0
  18. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-es-bundle.js +2 -0
  19. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js +2 -0
  20. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css +3 -0
  21. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js +2 -0
  22. data/lib/r2-oas/helpers/file_helper.rb +2 -2
  23. data/lib/r2-oas/hooks/hook.rb +2 -2
  24. data/lib/r2-oas/plugin/base.rb +4 -4
  25. data/lib/r2-oas/plugin/executor.rb +6 -6
  26. data/lib/r2-oas/plugin/transform/transform.rb +2 -2
  27. data/lib/r2-oas/routing/components/path_component.rb +3 -3
  28. data/lib/r2-oas/schema/editor.rb +116 -48
  29. data/lib/r2-oas/schema/monitor.rb +37 -19
  30. data/lib/r2-oas/schema/ui.rb +29 -18
  31. data/lib/r2-oas/schema/v3/analyzer/base_analyzer.rb +1 -1
  32. data/lib/r2-oas/schema/v3/builder/base_builder.rb +1 -1
  33. data/lib/r2-oas/schema/v3/generator/base_generator.rb +3 -3
  34. data/lib/r2-oas/schema/v3/generator/doc_generator.rb +1 -1
  35. data/lib/r2-oas/schema/v3/generator/schema_generator.rb +1 -1
  36. data/lib/r2-oas/schema/v3/manager/diff/base_hash_diff_manager.rb +1 -1
  37. data/lib/r2-oas/schema/v3/manager/file/base_file_manager.rb +3 -3
  38. data/lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb +5 -5
  39. data/lib/r2-oas/schema/v3/object/from_files/base_object.rb +2 -2
  40. data/lib/r2-oas/schema/v3/object/from_files/components/request_body_object.rb +2 -2
  41. data/lib/r2-oas/schema/v3/object/from_files/components/schema_object.rb +2 -2
  42. data/lib/r2-oas/schema/v3/object/from_files/path_item_object.rb +3 -3
  43. data/lib/r2-oas/schema/v3/object/from_files/utils/deep_methods.rb +2 -2
  44. data/lib/r2-oas/schema/v3/object/from_routes/path_item_object.rb +1 -0
  45. data/lib/r2-oas/schema/v3/object/from_routes/server_object.rb +2 -2
  46. data/lib/r2-oas/shared/sortable.rb +1 -1
  47. data/lib/r2-oas/support/deprecation/reporting.rb +3 -3
  48. data/lib/r2-oas/task_logging.rb +2 -2
  49. data/lib/r2-oas/tasks/main.rake +2 -2
  50. data/lib/r2-oas/version.rb +1 -1
  51. data/lib/r2-oas.rb +2 -1
  52. data/r2-oas.gemspec +6 -15
  53. metadata +48 -140
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7a8548f2c821fe7b76548b748dbe733ce0f11386d76ae046cc047b0fe0eb017b
4
- data.tar.gz: ee6ebb9740a854142b929195a57206cf8cedfeb1f965e4217e048152effc03a0
3
+ metadata.gz: 2e9fd7edc6de218fe86bcde7dfa51d219d541b52cb8a6ee75f9bb37ed85761d9
4
+ data.tar.gz: af082eb9c7a450aa13414046eb1a7be19ebd2140a03b499368019d6a5ef17c3a
5
5
  SHA512:
6
- metadata.gz: fcdf6903f652e7109c137b05123d6d244aaec02e9bb2a1fd657bc710ae549c6d84bd887c281a2f881e070d757299f17334200273bb2b3f9e6b988d16578a246b
7
- data.tar.gz: 129cfd622a8bd4c5b55bd5415cb24f24d0b918ea7cd9781aec7127b41640c3fe116b5f7e4dfe20add9ec68993d075471d172bd4919fda957893dc8b747c48ce2
6
+ metadata.gz: 6599b3911308383a080da4b8ef78ffc046ebfc621a78c878afaa96d32241c60163c9a4c305cf9b23bac06d1e681dbc18a418e881b2264454b7a0de9dac40d2e2
7
+ data.tar.gz: 22f6aa0517f3315acfa779305884382e5291873696066ae7d81868fdcc9d2610fca2483a405616bfdf99ff14f2edaf637d23c1645127cab8eba57780c090742b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # CHANGELOG
2
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
+
3
13
  ## v0.5.0
4
14
 
5
15
  2020-01-29
data/README.ja.md CHANGED
@@ -1,22 +1,32 @@
1
- # R2-OAS
2
-
3
1
  [![Gem Version](https://badge.fury.io/rb/r2-oas.svg)](https://badge.fury.io/rb/r2-oas)
4
2
  [![Build Status](https://travis-ci.org/yukihirop/r2-oas.svg?branch=master)](https://travis-ci.org/yukihirop/r2-oas)
5
3
  [![Coverage Status](https://coveralls.io/repos/github/yukihirop/r2-oas/badge.svg)](https://coveralls.io/github/yukihirop/r2-oas)
6
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/f8c3846f350bb412fd63/maintainability)](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 cask install chromedriver
55
+ $ brew install chromedriver
46
56
  ```
47
57
 
48
58
  ## 🚀 Tutorial
@@ -65,12 +75,15 @@ $ bundle exec rake routes:oas:editor
65
75
 
66
76
  #### Generate docs
67
77
 
68
- ![oas_docs](https://user-images.githubusercontent.com/11146767/80856236-0b839a80-8c83-11ea-888f-d0e659e0c251.gif)
69
-
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>
70
81
 
71
82
  #### Edit docs
72
83
 
73
- ![oas_editor](https://user-images.githubusercontent.com/11146767/80856240-15a59900-8c83-11ea-9dbd-4382528944f2.gif)
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>
74
87
 
75
88
  ## 📚 Documents
76
89
 
@@ -154,11 +167,14 @@ $ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
154
167
 
155
168
  ## ❤️ Support Rails Version
156
169
 
157
- - Rails (>= 4.2.5.1)
170
+ - Rails 7.2.2.2
171
+ - Rails (>= 8.x)
158
172
 
159
173
  ## ❤️ Support Ruby Version
160
174
 
161
- - Ruby (>= 2.5.0)
175
+ - Ruby 3.2.6
176
+ - Ruby 3.3.6
177
+ - Ruby (>= 3.4.x)
162
178
 
163
179
  ## ❤️ Support Rouging
164
180
 
@@ -192,6 +208,55 @@ OpenAPIの3.0.0をサポートしてます。
192
208
 
193
209
  公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/setting/configure
194
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
+
195
260
  ## Bundle and Rspec with multiple ruby ​​versions
196
261
 
197
262
  #### Bundle
@@ -202,22 +267,22 @@ OpenAPIの3.0.0をサポートしてます。
202
267
  .
203
268
  .
204
269
  ===== Bundle install for All Support Ruby Result =====
205
- ruby-2.5.8: 0
206
- ruby-2.6.6: 0
207
- ruby-2.7.1: 0
270
+ ruby-3.2.6: 0
271
+ ruby-3.3.6: 0
272
+ ruby-3.4.7: 0
208
273
  ======================================================
209
274
  ```
210
275
 
211
- rubyのバージョンを `2.6.6` と `2.7.1` に指定する場合
276
+ rubyのバージョンを `3.2.6` と `3.3.6` に指定する場合
212
277
 
213
278
  ```bash
214
- /bin/bash devscript/all_support_ruby.sh bundle 2.6.6 2.7.1
279
+ /bin/bash devscript/all_support_ruby.sh bundle 3.2.6 3.3.6
215
280
  .
216
281
  .
217
282
  .
218
283
  ===== Bundle install for All Support Ruby Result =====
219
- ruby-2.6.6: 0
220
- ruby-2.7.1: 0
284
+ ruby-3.2.6: 0
285
+ ruby-3.3.6: 0
221
286
  ======================================================
222
287
  ```
223
288
 
@@ -229,22 +294,22 @@ ruby-2.7.1: 0
229
294
  .
230
295
  .
231
296
  ===== Rspec for All Support Ruby Result =====
232
- ruby-2.5.8: 0
233
- ruby-2.6.6: 0
234
- ruby-2.7.1: 0
297
+ ruby-3.2.6: 0
298
+ ruby-3.3.6: 0
299
+ ruby-3.4.7: 0
235
300
  =============================================
236
301
  ```
237
302
 
238
- rubyのバージョンを `2.6.6` と `2.7.1` に指定する場合
303
+ rubyのバージョンを `3.2.6` と `3.3.6` に指定する場合
239
304
 
240
305
  ```bash
241
- /bin/bash devscript/all_support_ruby.sh rspec 2.6.6 2.7.1
306
+ /bin/bash devscript/all_support_ruby.sh rspec 3.2.6 3.3.6
242
307
  .
243
308
  .
244
309
  .
245
310
  ===== Rspec for All Support Ruby Result =====
246
- ruby-2.6.6: 0
247
- ruby-2.7.1: 0
311
+ ruby-3.2.6: 0
312
+ ruby-3.3.6: 0
248
313
  =============================================
249
314
  ```
250
315
 
data/README.md CHANGED
@@ -1,24 +1,32 @@
1
- # R2-OAS
2
-
3
1
  [![Gem Version](https://badge.fury.io/rb/r2-oas.svg)](https://badge.fury.io/rb/r2-oas)
4
2
  [![Build Status](https://travis-ci.org/yukihirop/r2-oas.svg?branch=master)](https://travis-ci.org/yukihirop/r2-oas)
5
3
  [![Coverage Status](https://coveralls.io/repos/github/yukihirop/r2-oas/badge.svg)](https://coveralls.io/github/yukihirop/r2-oas)
6
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/f8c3846f350bb412fd63/maintainability)](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
7
5
 
8
- Generate api docment(OpenAPI) side only from `Rails` routing.
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
- Provides a rake command to help `generate` , `view` , and `edit` OpenAPI documents.
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
- bunlde exec rake routes:oas:init # initialize
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 cask install chromedriver
63
+ $ brew install chromedriver
56
64
  ```
57
65
 
58
66
  ## 🚀 Tutorial
@@ -79,12 +87,15 @@ $ bundle exec rake routes:oas:editor
79
87
 
80
88
  #### Generate docs
81
89
 
82
- ![oas_docs](https://user-images.githubusercontent.com/11146767/80856236-0b839a80-8c83-11ea-888f-d0e659e0c251.gif)
83
-
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>
84
93
 
85
94
  #### Edit docs
86
95
 
87
- ![oas_editor](https://user-images.githubusercontent.com/11146767/80856240-15a59900-8c83-11ea-9dbd-4382528944f2.gif)
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>
88
99
 
89
100
  ## Usage
90
101
 
@@ -120,7 +131,7 @@ $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas
120
131
 
121
132
  ### Editor
122
133
 
123
- Start swagger editor.
134
+ Start Swagger editor.
124
135
 
125
136
  ```bash
126
137
  $ bundle exec rake routes:oas:editor # Start swagger editor
@@ -160,11 +171,14 @@ Full docs are available at https://yukihirop.github.io/r2-oas
160
171
 
161
172
  ## ❤️ Support Rails Version
162
173
 
163
- - Rails (>= 4.2.5.1)
174
+ - Rails 7.2.2.2
175
+ - Rails (>= 8.x)
164
176
 
165
177
  ## ❤️ Support Ruby Version
166
178
 
167
- - Ruby (>= 2.5.0)
179
+ - Ruby 3.2.6
180
+ - Ruby 3.3.6
181
+ - Ruby (>= 3.4.x)
168
182
 
169
183
  ## ❤️ Support Rouging
170
184
 
@@ -177,15 +191,15 @@ Full docs are available at https://yukihirop.github.io/r2-oas/#/schema/3.0.0
177
191
 
178
192
  ## ❗️ Convention over Configuration (CoC)
179
193
 
180
- - `tag name` represents `controller name` and determine `paths file name`.
181
- - For example, If `controller name` is `Api::V1::UsersController`, `tag_name` is `api/v1/user`. and `paths file name` is `api/v1/user.yml`
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`
182
196
 
183
197
  - `_` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
184
198
  - For example, If `components/schemas name` is `Api_V1_User`, `components/schemas file name` is `api/v1/user.yml`.
185
199
  - `_` is supposed to be used to express `namespace`.
186
200
  - format is `Namespace1_Namespace2_Model`.
187
201
 
188
- - `.` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
202
+ - `.` of `components/{schemas,requestBodies, ...} name` convert `/` when saving the file.
189
203
  - For example, If `components/schemas name` is `api.v1.User`, `components/schemas file name` is `api/v1/user.yml`.
190
204
  - `.` is supposed to be used to express `namespace`.
191
205
  - format is `namespace1.namespace2.Model`.
@@ -196,6 +210,55 @@ All settings are `optional`
196
210
 
197
211
  Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configure
198
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
+
199
262
  ## Bundle and Rspec with multiple ruby ​​versions
200
263
 
201
264
  #### Bundle
@@ -206,22 +269,22 @@ Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configur
206
269
  .
207
270
  .
208
271
  ===== Bundle install for All Support Ruby Result =====
209
- ruby-2.5.8: 0
210
- ruby-2.6.6: 0
211
- ruby-2.7.1: 0
272
+ ruby-3.2.6: 0
273
+ ruby-3.3.6: 0
274
+ ruby-3.4.7: 0
212
275
  ======================================================
213
276
  ```
214
277
 
215
- If specify ruby version `2.6.6` and `2.7.1`
278
+ If specify ruby version `3.2.6` and `3.3.6`
216
279
 
217
280
  ```bash
218
- /bin/bash devscript/all_support_ruby.sh bundle 2.6.6 2.7.1
281
+ /bin/bash devscript/all_support_ruby.sh bundle 3.2.6 3.3.6
219
282
  .
220
283
  .
221
284
  .
222
285
  ===== Bundle install for All Support Ruby Result =====
223
- ruby-2.6.6: 0
224
- ruby-2.7.1: 0
286
+ ruby-3.2.6: 0
287
+ ruby-3.3.6: 0
225
288
  ======================================================
226
289
  ```
227
290
 
@@ -233,22 +296,22 @@ ruby-2.7.1: 0
233
296
  .
234
297
  .
235
298
  ===== Rspec for All Support Ruby Result =====
236
- ruby-2.5.8: 0
237
- ruby-2.6.6: 0
238
- ruby-2.7.1: 0
299
+ ruby-3.2.6: 0
300
+ ruby-3.3.6: 0
301
+ ruby-3.4.7: 0
239
302
  =============================================
240
303
  ```
241
304
 
242
- If specify ruby version `2.6.6` and `2.7.1`
305
+ If specify ruby version `3.2.6` and `3.3.6`
243
306
 
244
307
  ```bash
245
- /bin/bash devscript/all_support_ruby.sh rspec 2.6.6 2.7.1
308
+ /bin/bash devscript/all_support_ruby.sh rspec 3.2.6 3.3.6
246
309
  .
247
310
  .
248
311
  .
249
312
  ===== Rspec for All Support Ruby Result =====
250
- ruby-2.6.6: 0
251
- ruby-2.7.1: 0
313
+ ruby-3.2.6: 0
314
+ ruby-3.3.6: 0
252
315
  =============================================
253
316
  ```
254
317
 
@@ -266,7 +329,7 @@ use Rack::Cors do
266
329
  end
267
330
  ```
268
331
 
269
- Alternatively you can set CORS headers in a `before` block.
332
+ Alternatively, you can set CORS headers in a `before` block.
270
333
 
271
334
  ```ruby
272
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 = 15
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 = {
@@ -24,7 +24,7 @@ module R2OAS
24
24
  def many_paths_file_paths
25
25
  @many_paths_file_paths ||= File.read(abs_paths_path).split("\n").each_with_object([]) do |relative_path, result|
26
26
  abs_path = File.expand_path("#{@schema_save_dir_path}/paths/#{relative_path}")
27
- result.push(abs_path) if FileTest.exists?(abs_path) && FileTest.file?(abs_path)
27
+ result.push(abs_path) if FileTest.exist?(abs_path) && FileTest.file?(abs_path)
28
28
  end.uniq.compact.reject(&:empty?)
29
29
  end
30
30
 
@@ -80,9 +80,9 @@ module R2OAS
80
80
  write_file_or_skip(gitkeep_tasks_helpers_path, '')
81
81
 
82
82
  if $stdout.string.present?
83
- STDOUT.puts $stdout.string
83
+ $stdout.puts $stdout.string
84
84
  else
85
- STDOUT.puts "Already Initialized existing oas_docs in #{root_dir_path}"
85
+ $stdout.puts "Already Initialized existing oas_docs in #{root_dir_path}"
86
86
  end
87
87
 
88
88
  $stdout = old_stdout
@@ -96,15 +96,15 @@ module R2OAS
96
96
 
97
97
  def load_local_tasks
98
98
  tasks_path = File.expand_path("#{root_dir_path}/#{local_tasks_dir_name}")
99
- Dir.glob("#{tasks_path}/**/*.rake").sort.each do |file|
100
- load file if FileTest.exists?(file)
99
+ Dir.glob("#{tasks_path}/**/*.rake").each do |file|
100
+ load file if FileTest.exist?(file)
101
101
  end
102
102
  end
103
103
 
104
104
  def load_local_plugins
105
105
  plugins_path = File.expand_path("#{root_dir_path}/#{local_plugins_dir_name}")
106
- Dir.glob("#{plugins_path}/**/*.rb").sort.each do |file|
107
- require file if FileTest.exists?(file)
106
+ Dir.glob("#{plugins_path}/**/*.rb").each do |file|
107
+ require file if FileTest.exist?(file)
108
108
  end
109
109
  end
110
110
 
@@ -6,33 +6,94 @@ require 'fileutils'
6
6
  module R2OAS
7
7
  module Deploy
8
8
  class Client < Schema::Base
9
- SWAGGER_UI_DIST_URL = 'https://github.com/swagger-api/swagger-ui/trunk/dist'
9
+ # Get master branch tarball from GitHub API
10
+ SWAGGER_UI_TARBALL_URL = 'https://api.github.com/repos/swagger-api/swagger-ui/tarball/master'
11
+ FALLBACK_DIST_PATH = File.expand_path('swagger-ui/dist', __dir__).freeze
10
12
 
11
13
  def initialize(options = {})
12
- super(options)
13
- @download_dir = "#{SecureRandom.uuid[0..7]}/dist"
14
- @dist_path = File.expand_path(Rails.root.join(@download_dir), __FILE__)
14
+ super
15
+ @download_dir = SecureRandom.uuid[0..7]
16
+ @base_dir = File.expand_path(Rails.root.join(@download_dir), __FILE__)
17
+ @tar_path = File.expand_path(Rails.root.join(@download_dir, 'swagger-ui-master.tar.gz'), __FILE__)
18
+ @dist_path = nil
19
+ logger.info("[deploy] initialize: download_dir=#{@download_dir} base_dir=#{@base_dir} tar_path=#{@tar_path}")
15
20
  end
16
21
 
17
22
  def download_swagger_ui_dist
18
- system("svn export #{SWAGGER_UI_DIST_URL} #{@dist_path}")
23
+ logger.info("[deploy] download_swagger_ui_dist: base_dir=#{@base_dir}")
24
+ FileUtils.mkdir_p(@base_dir)
25
+
26
+ curl_ok = system("curl -fsSL -o #{@tar_path} #{SWAGGER_UI_TARBALL_URL}")
27
+ logger.info("[deploy] curl result: ok=#{curl_ok} url=#{SWAGGER_UI_TARBALL_URL} -> #{@tar_path}")
28
+ unless curl_ok
29
+ logger.warn("[deploy] failed to download swagger-ui. using fallback dist: #{FALLBACK_DIST_PATH}")
30
+ @dist_path = FALLBACK_DIST_PATH if Dir.exist?(FALLBACK_DIST_PATH)
31
+ return @dist_path && Dir.exist?(@dist_path)
32
+ end
33
+
34
+ tar_ok = system("tar -xzf #{@tar_path} -C #{@base_dir}")
35
+ logger.info("[deploy] tar extract result: ok=#{tar_ok} tar=#{@tar_path} dest=#{@base_dir}")
36
+ unless tar_ok
37
+ logger.warn("[deploy] failed to extract swagger-ui tarball. using fallback dist: #{FALLBACK_DIST_PATH}")
38
+ @dist_path = FALLBACK_DIST_PATH if Dir.exist?(FALLBACK_DIST_PATH)
39
+ return @dist_path && Dir.exist?(@dist_path)
40
+ end
41
+
42
+ # Find the actual dist directory after extraction
43
+ # GitHub tarball extracts to swagger-api-swagger-ui-<sha>/dist/
44
+ extracted_dirs = Dir.glob(File.join(@base_dir, 'swagger-api-swagger-ui-*'))
45
+ logger.info("[deploy] extracted_dirs: #{extracted_dirs}")
46
+
47
+ if extracted_dirs.empty?
48
+ # Fallback: check if dist exists directly
49
+ dist_path = File.join(@base_dir, 'dist')
50
+ logger.info("[deploy] check direct dist: #{dist_path} exists=#{Dir.exist?(dist_path)}")
51
+ else
52
+ dist_path = File.join(extracted_dirs.first, 'dist')
53
+ logger.info("[deploy] check versioned dist: #{dist_path} exists=#{Dir.exist?(dist_path)}")
54
+ end
55
+ @dist_path = File.expand_path(dist_path) if Dir.exist?(dist_path)
56
+
57
+ unless @dist_path && Dir.exist?(@dist_path)
58
+ logger.warn("[deploy] failed to find dist directory in extracted archive. using fallback dist: #{FALLBACK_DIST_PATH}")
59
+ @dist_path = FALLBACK_DIST_PATH if Dir.exist?(FALLBACK_DIST_PATH)
60
+ return @dist_path && Dir.exist?(@dist_path)
61
+ end
62
+
63
+ logger.info("[deploy] dist_path detected: #{@dist_path}")
64
+
65
+ true
19
66
  end
20
67
 
21
68
  def deploy
69
+ logger.info('[deploy] start deploy')
22
70
  copy_swagger_ui_dist
23
71
  copy_swagger_ui_index
24
72
  copy_oas_doc_file
25
73
  ensure
74
+ logger.info('[deploy] cleanup download artifacts')
26
75
  remove_download_dist
27
76
  end
28
77
 
29
78
  private
30
79
 
31
80
  def copy_swagger_ui_dist
81
+ # Use fallback dist if @dist_path is not set
82
+ unless @dist_path
83
+ if Dir.exist?(FALLBACK_DIST_PATH)
84
+ logger.warn("[deploy] @dist_path not set. using fallback dist: #{FALLBACK_DIST_PATH}")
85
+ @dist_path = FALLBACK_DIST_PATH
86
+ else
87
+ raise 'dist directory not found and fallback dist does not exist. Please call download_swagger_ui_dist first.'
88
+ end
89
+ end
90
+
32
91
  docs_path = File.expand_path(Rails.root.join(deploy_dir_path), __FILE__)
33
- FileUtils.mkdir_p(docs_path) unless FileTest.exists?(docs_path)
34
- FileUtils.mkdir_p(@dist_path) unless FileTest.exists?(@dist_path)
35
- FileUtils.cp_r(@dist_path, docs_path)
92
+ dist_dest_path = File.join(docs_path, 'dist')
93
+ logger.info("[deploy] copy dist: src=#{@dist_path} dest=#{dist_dest_path}")
94
+ FileUtils.mkdir_p(File.dirname(dist_dest_path))
95
+ FileUtils.rm_rf(dist_dest_path)
96
+ FileUtils.cp_r(@dist_path, dist_dest_path)
36
97
  end
37
98
 
38
99
  def copy_swagger_ui_index
@@ -41,29 +102,24 @@ module R2OAS
41
102
  template_path = File.expand_path('swagger-ui/index.html.erb', __dir__)
42
103
  template = File.read(template_path)
43
104
  index = make_index(template)
105
+ logger.info("[deploy] write index.html: path=#{index_path} schema_file=#{@schema_file_path}")
44
106
  File.write(index_path, index)
45
107
  end
46
108
 
47
109
  def copy_oas_doc_file
48
110
  swagger_file_path = File.expand_path(Rails.root.join(deploy_dir_path, doc_save_file_name), __FILE__)
49
111
  oas_doc_file_path = File.expand_path(output_path)
112
+ logger.info("[deploy] copy oas doc: src=#{oas_doc_file_path} dest=#{swagger_file_path}")
50
113
  FileUtils.cp_r(oas_doc_file_path, swagger_file_path)
51
114
  end
52
115
 
53
116
  def remove_download_dist
54
- FileUtils.rm_rf(File.expand_path('..', @dist_path))
117
+ logger.info("[deploy] remove temp: base_dir=#{@base_dir}")
118
+ FileUtils.rm_rf(@base_dir) if @base_dir && Dir.exist?(@base_dir)
55
119
  end
56
120
 
57
- # [ref]
58
- # https://www.rubydoc.info/gems/rubocop/RuboCop/Cop/Lint/ErbNewArguments
59
121
  def make_index(template)
60
- if RUBY_VERSION >= '2.6'
61
- ERB.new(template, trim_mode: '%').result(binding)
62
- else
63
- # rubocop:disable Lint/ErbNewArguments
64
- ERB.new(template, nil, trim_mode: '%').result(binding)
65
- # rubocop:enable Lint/ErbNewArguments
66
- end
122
+ ERB.new(template, trim_mode: '%').result(binding)
67
123
  end
68
124
  end
69
125
  end