r2-oas 0.3.1 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +50 -0
- data/GEMSPEC.md +2 -2
- data/README.ja.md +54 -37
- data/README.md +55 -32
- data/lib/r2-oas.rb +4 -5
- data/lib/r2-oas/app_configuration.rb +17 -5
- data/lib/r2-oas/app_configuration/deprecation.rb +28 -0
- data/lib/r2-oas/configuration.rb +56 -0
- data/lib/r2-oas/deploy/client.rb +21 -6
- data/lib/r2-oas/{plugins/schema/v3/object → dynamic/schema/v3/object/from_routes}/hookable_base_object.rb +7 -7
- data/lib/r2-oas/errors.rb +5 -0
- data/lib/r2-oas/hooks/hook.rb +7 -5
- data/lib/r2-oas/lib/core_ext/all.rb +5 -0
- data/lib/r2-oas/lib/core_ext/string/filters.rb +29 -0
- data/lib/r2-oas/pluggable_configuration.rb +8 -5
- data/lib/r2-oas/plugin/base.rb +44 -0
- data/lib/r2-oas/plugin/executor.rb +148 -0
- data/lib/r2-oas/plugin/hookable.rb +42 -0
- data/lib/r2-oas/plugin/public.rb +3 -0
- data/lib/r2-oas/plugin/transform/transform.rb +10 -0
- data/lib/r2-oas/plugin/transform/v3/transform.rb +20 -0
- data/lib/r2-oas/plugin/transform/v3/visitable.rb +37 -0
- data/lib/r2-oas/public.rb +5 -0
- data/lib/r2-oas/schema/base.rb +1 -1
- data/lib/r2-oas/schema/builder.rb +1 -1
- data/lib/r2-oas/schema/editor.rb +8 -1
- data/lib/r2-oas/schema/v3/analyzer/path_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/builder.rb +1 -1
- data/lib/r2-oas/schema/v3/builder/base_builder.rb +14 -2
- data/lib/r2-oas/schema/v3/builder/doc_builder.rb +10 -2
- data/lib/r2-oas/schema/v3/generator/base_generator.rb +7 -2
- data/lib/r2-oas/schema/v3/generator/doc_generator.rb +1 -1
- data/lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb +3 -2
- data/lib/r2-oas/schema/v3/object/from_files/base_object.rb +62 -0
- data/lib/r2-oas/schema/v3/object/from_files/components/request_body_object.rb +103 -0
- data/lib/r2-oas/schema/v3/object/from_files/components/schema_object.rb +102 -0
- data/lib/r2-oas/schema/v3/object/from_files/components_object.rb +46 -0
- data/lib/r2-oas/schema/v3/object/from_files/external_document_object.rb +23 -0
- data/lib/r2-oas/schema/v3/object/from_files/info_object.rb +23 -0
- data/lib/r2-oas/schema/v3/object/from_files/openapi_object.rb +61 -0
- data/lib/r2-oas/schema/v3/object/from_files/path_item_object.rb +110 -0
- data/lib/r2-oas/schema/v3/object/from_files/paths_object.rb +33 -0
- data/lib/r2-oas/schema/v3/object/from_files/utils/all.rb +4 -0
- data/lib/r2-oas/schema/v3/object/from_files/utils/deep_methods.rb +27 -0
- data/lib/r2-oas/schema/v3/object/from_files/utils/refs.rb +151 -0
- data/lib/r2-oas/schema/v3/object/{base_object.rb → from_routes/base_object.rb} +11 -1
- data/lib/r2-oas/schema/v3/object/{components → from_routes/components}/request_body_object.rb +23 -19
- data/lib/r2-oas/schema/v3/object/{components → from_routes/components}/schema_object.rb +16 -12
- data/lib/r2-oas/schema/v3/object/{components_object.rb → from_routes/components_object.rb} +11 -11
- data/lib/r2-oas/schema/v3/object/from_routes/external_document_object.rb +28 -0
- data/lib/r2-oas/schema/v3/object/{info_object.rb → from_routes/info_object.rb} +11 -2
- data/lib/r2-oas/schema/v3/object/{openapi_object.rb → from_routes/openapi_object.rb} +12 -11
- data/lib/r2-oas/schema/v3/object/{path_item_object.rb → from_routes/path_item_object.rb} +6 -6
- data/lib/r2-oas/schema/v3/object/{paths_object.rb → from_routes/paths_object.rb} +11 -8
- data/lib/r2-oas/schema/v3/object/{public.rb → from_routes/public.rb} +0 -0
- data/lib/r2-oas/schema/v3/object/{server_object.rb → from_routes/server_object.rb} +0 -0
- data/lib/r2-oas/schema/v3/object/{tag_object.rb → from_routes/tag_object.rb} +2 -1
- data/lib/r2-oas/schema/v3/object/store.rb +54 -0
- data/lib/r2-oas/shared/all.rb +1 -0
- data/lib/r2-oas/shared/callable.rb +17 -0
- data/lib/r2-oas/store.rb +20 -16
- data/lib/r2-oas/support/deprecation.rb +26 -0
- data/lib/r2-oas/support/deprecation/behavior.rb +21 -0
- data/lib/r2-oas/support/deprecation/instance_delegator.rb +42 -0
- data/lib/r2-oas/support/deprecation/reporting.rb +91 -0
- data/lib/r2-oas/task.rb +1 -2
- data/lib/r2-oas/task_logging.rb +3 -7
- data/lib/r2-oas/tasks/common.rake +1 -2
- data/lib/r2-oas/tasks/main.rake +60 -9
- data/lib/r2-oas/version.rb +1 -1
- data/r2-oas.gemspec +1 -6
- metadata +51 -110
- data/.github/ISSUE_TEMPLATE.md +0 -12
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -10
- data/.rubocop_todo.yml +0 -291
- data/.travis.yml +0 -26
- data/Appraisals +0 -13
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -12
- data/Rakefile +0 -8
- data/bin/console +0 -12
- data/bin/setup +0 -8
- data/devscript/all_support_ruby.sh +0 -43
- data/devscript/bundle_for_all_support_ruby.sh +0 -31
- data/devscript/rspec_for_all_support_ruby.sh +0 -27
- data/docs/.nojekyll +0 -0
- data/docs/README.md +0 -173
- data/docs/_sidebar.md +0 -25
- data/docs/attention/if_clash.md +0 -17
- data/docs/index.html +0 -29
- data/docs/schema/3.0.0.md +0 -155
- data/docs/setting/COC.md +0 -14
- data/docs/setting/CORS.md +0 -22
- data/docs/setting/configure.md +0 -176
- data/docs/trableshouting/runtime_error.md +0 -44
- data/docs/usage/analyze_docs.md +0 -875
- data/docs/usage/clean_docs.md +0 -19
- data/docs/usage/deploy_docs.md +0 -839
- data/docs/usage/display_paths_list.md +0 -35
- data/docs/usage/display_paths_stats.md +0 -54
- data/docs/usage/edit_docs.md +0 -218
- data/docs/usage/generate_docs.md +0 -412
- data/docs/usage/monitor_docs.md +0 -219
- data/docs/usage/use_hook_methods.md +0 -236
- data/docs/usage/use_hook_to_generate_docs.md +0 -235
- data/docs/usage/use_schema_namespace.md +0 -181
- data/docs/usage/use_tag_namespace.md +0 -180
- data/docs/usage/view_docs.md +0 -262
- data/gemfiles/ruby_2.3.3.gemfile +0 -11
- data/gemfiles/ruby_2.4.2.gemfile +0 -11
- data/gemfiles/ruby_2.5.8.gemfile +0 -11
- data/gemfiles/ruby_2.6.6.gemfile +0 -11
- data/gemfiles/ruby_2.7.1.gemfile +0 -11
- data/lib/r2-oas/app_configuration/tool.rb +0 -31
- data/lib/r2-oas/app_configuration/tool/paths/stats.rb +0 -43
- 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/oauth2-redirect.html +0 -68
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js +0 -134
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js.map +0 -1
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js +0 -22
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js.map +0 -1
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css +0 -4
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css.map +0 -1
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js +0 -9
- data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js.map +0 -1
- data/lib/r2-oas/schema/v3/object/external_document_object.rb +0 -19
- data/lib/r2-oas/tasks/tool.rake +0 -76
- data/lib/r2-oas/tool/paths/ls.rb +0 -15
- data/lib/r2-oas/tool/paths/stats.rb +0 -84
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6ff37fb9f530ea30d7a06154dd6036ae63fdbd1358cab2d38bad3b2fd6334fc
|
4
|
+
data.tar.gz: 99f6574107d260c8961d645c1dfbc29b19143b19d5a903554e4576be39280f9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 964aefff2e439e5d0eab907fc0c1301826dd81bdefa23f07d8ec822b054a4eb31c689b8e927e0ed28b4c790a26013c8d14d65d5706205fec5a02207fee661ec3
|
7
|
+
data.tar.gz: 484e127af388c3b633a5a7683f8493fa95fa2d1a6ef4981d227e37ce2676d7022170c18d708eb6ecb23eacfa9c48ac39865fe9e746e7d6fd94073e224c673047
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,55 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## v0.4.1
|
4
|
+
|
5
|
+
2020-8-24
|
6
|
+
|
7
|
+
- [`Breaking`] Remove `tool` tasks because it is infrequently used, it costs ([#162](https://github.com/yukihirop/r2-oas/pull/162))
|
8
|
+
- `routes:oas:paths_ls`
|
9
|
+
- `routes:oas:paths_stats`
|
10
|
+
- [`Feature`] Add `SKIP_PLUGIN` enviroment variables ([#160](https://github.com/yukihirop/r2-oas/pull/160))
|
11
|
+
|
12
|
+
Please see milestone [v0.4.1](https://github.com/yukihirop/r2-oas/milestone/6?closed=1)
|
13
|
+
|
14
|
+
## v0.4.0
|
15
|
+
|
16
|
+
2020-07-22
|
17
|
+
|
18
|
+
- [`BigFeature`] 🎯 Implement plugin ([#154](https://github.com/yukihirop/r2-oas/pull/154))
|
19
|
+
- Please see [use plugins docs](https://yukihirop.github.io/r2-oas/#/usage/use_plugins)
|
20
|
+
- [`Feature`] Implement `routes:oas:init`([#154](https://github.com/yukihirop/r2-oas/pull/154))
|
21
|
+
- Please see [initialize docs](https://yukihirop.github.io/r2-oas/#/usage/initialize)
|
22
|
+
- [`Breaking`] Rename from `routes:oas:dist` to `routes:oas:build` ([#154](https://github.com/yukihirop/r2-oas/pull/154))
|
23
|
+
- [`Feature`] Allowed definition of custom rake tasks ([#152](https://github.com/yukihirop/r2-oas/pull/152))
|
24
|
+
- Please see [define tasks docs](https://yukihirop.github.io/r2-oas/#/usage/define_tasks)
|
25
|
+
- [`Deprecated`] Deprecated use of `R2OAS.use_object_classes=` ([#155](https://github.com/yukihirop/r2-oas/pull/155))
|
26
|
+
|
27
|
+
Please see milestone [v0.4.0](https://github.com/yukihirop/r2-oas/milestone/4?closed=1)
|
28
|
+
|
29
|
+
## v0.3.4
|
30
|
+
|
31
|
+
2020-07-11
|
32
|
+
|
33
|
+
- [`Other`] Modify gemspec `files` fields ([#147](https://github.com/yukihirop/r2-oas/pull/147))
|
34
|
+
- Add `r2-oas.gemspec` into gemspec `files`
|
35
|
+
|
36
|
+
## v0.3.3
|
37
|
+
|
38
|
+
2020-07-11
|
39
|
+
|
40
|
+
- [`FixBugs`] A cute pet store syndrome 🐈 ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
|
41
|
+
- [`FixBugs`] R2OAS.logger.level does not work ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
|
42
|
+
- [`Breaking`] Change default namespace type from `:underbar` to `:dot` ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
|
43
|
+
- [`Other`] Modify gemspec `files` fields ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
|
44
|
+
|
45
|
+
Please see milestone [v0.3.3](https://github.com/yukihirop/r2-oas/milestone/3?closed=1)
|
46
|
+
|
47
|
+
## v0.3.2
|
48
|
+
|
49
|
+
2020-07-05
|
50
|
+
|
51
|
+
- [`Feature`] The file size at the time of gem install was reduced by about 10MB. ([dbdbce9 ](https://github.com/yukihirop/r2-oas/pull/138))
|
52
|
+
|
3
53
|
## v0.3.1
|
4
54
|
|
5
55
|
2020-06-07
|
data/GEMSPEC.md
CHANGED
@@ -6,12 +6,12 @@ Generate api docment(OpenAPI) side only from `Rails` routing.
|
|
6
6
|
|
7
7
|
Provide rake tasks to management API Docment (OpenAPI) 🎉
|
8
8
|
|
9
|
-
|
9
|
+
$ bundle exec rake routes:oas:init
|
10
10
|
$ bundle exec rake routes:oas:docs
|
11
11
|
$ bundle exec rake routes:oas:ui
|
12
12
|
$ bundle exec rake routes:oas:editor
|
13
13
|
$ bundle exec rake routes:oas:monitor
|
14
|
-
$ bundle exec rake routes:oas:
|
14
|
+
$ bundle exec rake routes:oas:build
|
15
15
|
$ bundle exec rake routes:oas:clean
|
16
16
|
$ bundle exec rake routes:oas:analyze
|
17
17
|
$ bundle exec rake routes:oas:deploy
|
data/README.ja.md
CHANGED
@@ -8,11 +8,12 @@
|
|
8
8
|
Railsのルーティング情報からOpenAPI形式のドキュメントを生成し、閲覧・編集・管理するためのrakeタスクの提供をします。
|
9
9
|
|
10
10
|
```bash
|
11
|
+
bundle exec rake routes:oas:init # 初期化
|
11
12
|
bundle exec rake routes:oas:docs # ドキュメント生成
|
12
13
|
bundle exec rake routes:oas:ui # ドキュメント閲覧
|
13
14
|
bundle exec rake routes:oas:editor # ドキュメント編集
|
14
15
|
bundle exec rake routes:oas:monitor # ドキュメント監視
|
15
|
-
bundle exec rake routes:oas:
|
16
|
+
bundle exec rake routes:oas:build # ドキュメントビルド
|
16
17
|
bundle exec rake routes:oas:clean # ドキュメント清掃
|
17
18
|
bundle exec rake routes:oas:analyze # ドキュメント分解・分析
|
18
19
|
bundle exec rake routes:oas:deploy # ドキュメントデプロイ
|
@@ -68,39 +69,62 @@ bundle exec routes:oas:editor
|
|
68
69
|
|
69
70
|
## 📖 Usage
|
70
71
|
|
71
|
-
|
72
|
+
|
73
|
+
railsプロジェクトのルートディレクトリで以下のコマンドが実行可能です。
|
74
|
+
一般的なコマンドの使用例を示します。
|
75
|
+
|
76
|
+
### Initialize
|
77
|
+
|
78
|
+
`r2-oas`の初期化
|
72
79
|
|
73
80
|
```bash
|
74
|
-
$
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
$ bundle exec rake routes:oas:
|
83
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:
|
84
|
-
$ # テキストエディタでドキュメント編集(初期設定時、git管理しないoas_docs/oas_doc.ymlを監視)
|
85
|
-
$ bundle exec rake routes:oas:monitor
|
86
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:monitor # pathsファイルを指定してドキュメント監視
|
87
|
-
|
88
|
-
$ # ドキュメントを分解・分析
|
89
|
-
$ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
|
90
|
-
$ # どこからも参照されてないcomponents/schemas(requestBodies, ...)を削除
|
91
|
-
$ bundle exec rake routes:oas:clean
|
92
|
-
$ # githubにホスティング
|
93
|
-
$ bundle exec rake routes:oas:deploy
|
94
|
-
$ # ドキュメントを配布(初期設定時、配布ファイルは、oas_docs/oas_doc.yml)
|
95
|
-
$ bundle exec rake routes:oas:dist
|
96
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:dist # pathsファイルを指定してドキュメント配布
|
97
|
-
|
98
|
-
# pathsファイルのリスト取得
|
99
|
-
$ bundle exec rake routes:oas:paths_ls
|
100
|
-
# pathsファイルの編集履歴表示
|
101
|
-
$ bundle exec rake routes:oas:paths_stats
|
81
|
+
$ bundle exec rake routes:oas:init
|
82
|
+
```
|
83
|
+
|
84
|
+
### Generate
|
85
|
+
|
86
|
+
ドキュメントの生成
|
87
|
+
|
88
|
+
```bash
|
89
|
+
$ bundle exec rake routes:oas:docs # Generate docs
|
90
|
+
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:docs # Generate docs by specify unit paths
|
102
91
|
```
|
103
92
|
|
93
|
+
### Editor
|
94
|
+
|
95
|
+
SwaggerEditorの起動
|
96
|
+
|
97
|
+
```bash
|
98
|
+
$ bundle exec rake routes:oas:editor # Start swagger editor
|
99
|
+
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:editor # Start swagger editor by specify unit paths
|
100
|
+
```
|
101
|
+
|
102
|
+
### UI
|
103
|
+
|
104
|
+
SwaggerUIの起動
|
105
|
+
|
106
|
+
```bash
|
107
|
+
$ bundle exec rake routes:oas:ui # Start swagger ui
|
108
|
+
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:ui # Start swagger ui by specify unit paths
|
109
|
+
```
|
110
|
+
|
111
|
+
### Build
|
112
|
+
|
113
|
+
ドキュメントのビルド
|
114
|
+
※プラグインが適用されます。
|
115
|
+
|
116
|
+
```bash
|
117
|
+
$ bundle exec rake routes:oas:build
|
118
|
+
```
|
119
|
+
|
120
|
+
### Analyze
|
121
|
+
|
122
|
+
ドキュメントの分割
|
123
|
+
OpenAPI形式のドキュメントを読み取り、それをいくつかの部分に分割してソースファイルを生成します
|
124
|
+
|
125
|
+
```bash
|
126
|
+
$ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
|
127
|
+
```
|
104
128
|
|
105
129
|
## ⚾️ sample
|
106
130
|
|
@@ -151,13 +175,6 @@ OpenAPIの3.0.0をサポートしてます。
|
|
151
175
|
|
152
176
|
公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/setting/configure
|
153
177
|
|
154
|
-
## 💊 Life Cycle Methods (Hook Metohds)
|
155
|
-
|
156
|
-
ドキュメント生成時に、フックを可能にするメソッドを用意しております。
|
157
|
-
|
158
|
-
公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/usage/use_hook_methods
|
159
|
-
|
160
|
-
|
161
178
|
## Bundle and Rspec with multiple ruby versions
|
162
179
|
|
163
180
|
#### Bundle
|
data/README.md
CHANGED
@@ -10,11 +10,12 @@ Generate api docment(OpenAPI) side only from `Rails` routing.
|
|
10
10
|
Provides a rake command to help `generate` , `view` , and `edit` OpenAPI documents.
|
11
11
|
|
12
12
|
```bash
|
13
|
+
bunlde exec rake routes:oas:init # initialize
|
13
14
|
bundle exec rake routes:oas:docs # generate
|
14
15
|
bundle exec rake routes:oas:ui # view
|
15
16
|
bundle exec rake routes:oas:editor # edit
|
16
17
|
bundle exec rake routes:oas:monitor # monitor
|
17
|
-
bundle exec rake routes:oas:
|
18
|
+
bundle exec rake routes:oas:build # build
|
18
19
|
bundle exec rake routes:oas:clean # clean
|
19
20
|
bundle exec rake routes:oas:analyze # analyze
|
20
21
|
bundle exec rake routes:oas:deploy # deploy
|
@@ -56,7 +57,11 @@ $ brew cask install chromedriver
|
|
56
57
|
|
57
58
|
## 🚀 Tutorial
|
58
59
|
|
59
|
-
After requiring a gem
|
60
|
+
After requiring a gem and Configure `Rakefile` in your rails project
|
61
|
+
|
62
|
+
```rb
|
63
|
+
R2OAS.load_tasks
|
64
|
+
```
|
60
65
|
|
61
66
|
```bash
|
62
67
|
bundle exec routes:oas:docs
|
@@ -74,38 +79,62 @@ bundle exec routes:oas:editor
|
|
74
79
|
|
75
80
|
## Usage
|
76
81
|
|
77
|
-
You can execute the following command in the root directory of rails.
|
82
|
+
You can execute the following command in the root directory of rails.
|
83
|
+
The following are examples of typical command usage.
|
84
|
+
|
85
|
+
Full docs are available at https://yukihirop.github.io/r2-oas
|
86
|
+
|
87
|
+
### Initialize
|
88
|
+
|
89
|
+
Initialize r2-oas.
|
90
|
+
|
91
|
+
```bash
|
92
|
+
$ bundle exec rake routes:oas:init
|
93
|
+
```
|
94
|
+
|
95
|
+
### Generate
|
96
|
+
|
97
|
+
Generate docs.
|
78
98
|
|
79
99
|
```bash
|
80
|
-
$ # Generate docs
|
81
|
-
$ bundle exec rake routes:oas:docs # Generate docs
|
100
|
+
$ bundle exec rake routes:oas:docs # Generate docs
|
82
101
|
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:docs # Generate docs by specify unit paths
|
102
|
+
```
|
83
103
|
|
84
|
-
|
85
|
-
|
104
|
+
### Editor
|
105
|
+
|
106
|
+
Start swagger editor.
|
107
|
+
|
108
|
+
```bash
|
109
|
+
$ bundle exec rake routes:oas:editor # Start swagger editor
|
86
110
|
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:editor # Start swagger editor by specify unit paths
|
87
|
-
|
88
|
-
|
111
|
+
```
|
112
|
+
|
113
|
+
### UI
|
114
|
+
|
115
|
+
Start swagger ui.
|
116
|
+
|
117
|
+
```bash
|
118
|
+
$ bundle exec rake routes:oas:ui # Start swagger ui
|
89
119
|
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:ui # Start swagger ui by specify unit paths
|
90
|
-
|
91
|
-
|
92
|
-
|
120
|
+
```
|
121
|
+
|
122
|
+
### Build
|
123
|
+
|
124
|
+
Build docs.
|
125
|
+
`Plugin is applied`
|
126
|
+
|
127
|
+
```bash
|
128
|
+
$ bundle exec rake routes:oas:build
|
129
|
+
```
|
130
|
+
|
131
|
+
### Analyze
|
132
|
+
|
133
|
+
Analyze docs.
|
134
|
+
Reads OpenAPI format document and divides it into several parts to generate a source file
|
93
135
|
|
94
|
-
|
136
|
+
```bash
|
95
137
|
$ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
|
96
|
-
$ # Clean docs
|
97
|
-
$ bundle exec rake routes:oas:clean
|
98
|
-
$ # Deploy docs
|
99
|
-
$ bundle exec rake routes:oas:deploy
|
100
|
-
$ # Distribute swagger document
|
101
|
-
$ bundle exec rake routes:oas:dist
|
102
|
-
$ # Distribute swagger document
|
103
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:dist # Distribute swagger document by specify unit paths
|
104
|
-
|
105
|
-
# Display paths list
|
106
|
-
$ bundle exec rake routes:oas:paths_ls
|
107
|
-
# Display paths stats
|
108
|
-
$ bundle exec rake routes:oas:paths_stats
|
109
138
|
```
|
110
139
|
|
111
140
|
## 📚 Documents
|
@@ -150,12 +179,6 @@ All settings are `optional`
|
|
150
179
|
|
151
180
|
Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configure
|
152
181
|
|
153
|
-
## 💊 Life Cycle Methods (Hook Metohds)
|
154
|
-
|
155
|
-
Supported hook(life cycle methods) is like this:
|
156
|
-
|
157
|
-
Full docs are available at https://yukihirop.github.io/r2-oas/#/usage/use_hook_methods
|
158
|
-
|
159
182
|
## Bundle and Rspec with multiple ruby versions
|
160
183
|
|
161
184
|
#### Bundle
|
data/lib/r2-oas.rb
CHANGED
@@ -1,9 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'r2-oas/version'
|
4
|
-
require 'r2-oas/
|
5
|
-
require 'r2-oas/errors'
|
6
|
-
require 'r2-oas/schema/v3/object/public'
|
4
|
+
require 'r2-oas/public'
|
7
5
|
|
8
6
|
module R2OAS
|
9
7
|
if !defined?(::Rails)
|
@@ -12,14 +10,15 @@ module R2OAS
|
|
12
10
|
elsif ::Rails::VERSION::STRING >= '4.2.5.1'
|
13
11
|
extend Configuration
|
14
12
|
require 'r2-oas/task'
|
15
|
-
require 'r2-oas/
|
16
|
-
require 'r2-oas/lib/core_ext/
|
13
|
+
require 'r2-oas/plugin/public'
|
14
|
+
require 'r2-oas/lib/core_ext/all'
|
17
15
|
|
18
16
|
autoload :Base, 'r2-oas/base'
|
19
17
|
autoload :NoImplementError, 'r2-oas/errors'
|
20
18
|
autoload :NoFileExistsError, 'r2-oas/errors'
|
21
19
|
autoload :NoSupportError, 'r2-oas/errors'
|
22
20
|
autoload :Sortable, 'r2-oas/shared/all'
|
21
|
+
autoload :Deprecation, 'r2-oas/support/deprecation'
|
23
22
|
|
24
23
|
module Schema
|
25
24
|
autoload :Base, 'r2-oas/schema/base'
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require_relative 'app_configuration/server'
|
4
4
|
require_relative 'app_configuration/swagger'
|
5
|
-
require_relative 'app_configuration/
|
5
|
+
require_relative 'app_configuration/deprecation'
|
6
6
|
|
7
7
|
module R2OAS
|
8
8
|
module AppConfiguration
|
@@ -42,10 +42,14 @@ module R2OAS
|
|
42
42
|
DEFAULT_HTTP_METHODS_WHEN_GENERATE_REQUEST_BODY = %w[post patch put]
|
43
43
|
DEFAULT_IGNORED_HTTP_STATUSES_WHEN_GENERATE_COMPONENT_SCHEMA = %w[204 404]
|
44
44
|
# rubocop:enable Style/MutableConstant
|
45
|
-
DEFAULT_TOOL = Tool.new
|
46
45
|
# :dot or :underbar
|
47
|
-
DEFAULT_NAMESPACE_TYPE = :
|
46
|
+
DEFAULT_NAMESPACE_TYPE = :dot
|
48
47
|
DEFAULT_DEPLOY_DIR_PATH = './deploy_docs'
|
48
|
+
EDFAULT_PLUGINS = [].freeze
|
49
|
+
DEFAULT_LOCAL_PLUGINS_DIR_NAME = 'plugins'
|
50
|
+
DEFAULT_LOCAL_TASKS_DIR_NAME = 'tasks'
|
51
|
+
DEFAULT_OUTPUT_PATH = './oas_docs/dist/oas_doc.yml'
|
52
|
+
DEFAULT_DEPRECATION = Deprecation.new
|
49
53
|
|
50
54
|
PUBLIC_VALID_OPTIONS_KEYS = %i[
|
51
55
|
version
|
@@ -61,9 +65,13 @@ module R2OAS
|
|
61
65
|
http_statuses_when_http_method
|
62
66
|
http_methods_when_generate_request_body
|
63
67
|
ignored_http_statuses_when_generate_component_schema
|
64
|
-
tool
|
65
68
|
namespace_type
|
66
69
|
deploy_dir_path
|
70
|
+
plugins
|
71
|
+
local_plugins_dir_name
|
72
|
+
local_tasks_dir_name
|
73
|
+
output_path
|
74
|
+
deprecation
|
67
75
|
].freeze
|
68
76
|
|
69
77
|
UNPUBLIC_VALID_OPTIONS_KEYS = %i[
|
@@ -95,11 +103,15 @@ module R2OAS
|
|
95
103
|
target.interval_to_save_edited_tmp_schema = DEFAULT_INTERVAL_TO_SAVE_EDITED_TMP_SCHEMA
|
96
104
|
target.swagger = DEFAULT_SWAGGER
|
97
105
|
target.http_statuses_when_http_method = DEFAULT_HTTP_STATUSES_WHEN_HTTP_METHOD
|
98
|
-
target.tool = DEFAULT_TOOL
|
99
106
|
target.http_methods_when_generate_request_body = DEFAULT_HTTP_METHODS_WHEN_GENERATE_REQUEST_BODY
|
100
107
|
target.ignored_http_statuses_when_generate_component_schema = DEFAULT_IGNORED_HTTP_STATUSES_WHEN_GENERATE_COMPONENT_SCHEMA
|
101
108
|
target.namespace_type = DEFAULT_NAMESPACE_TYPE
|
102
109
|
target.deploy_dir_path = DEFAULT_DEPLOY_DIR_PATH
|
110
|
+
target.plugins = EDFAULT_PLUGINS
|
111
|
+
target.local_plugins_dir_name = DEFAULT_LOCAL_PLUGINS_DIR_NAME
|
112
|
+
target.local_tasks_dir_name = DEFAULT_LOCAL_TASKS_DIR_NAME
|
113
|
+
target.output_path = DEFAULT_OUTPUT_PATH
|
114
|
+
target.deprecation = DEFAULT_DEPRECATION
|
103
115
|
end
|
104
116
|
end
|
105
117
|
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'r2-oas/support/deprecation'
|
4
|
+
|
5
|
+
module R2OAS
|
6
|
+
module AppConfiguration
|
7
|
+
class Deprecation
|
8
|
+
DEFAULT_SILENCED = ::R2OAS::Deprecation.silenced
|
9
|
+
|
10
|
+
attr_reader :silenced
|
11
|
+
|
12
|
+
def silenced=(value)
|
13
|
+
@silenced = !!value
|
14
|
+
::R2OAS::Deprecation.silenced = !!value
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize
|
18
|
+
set_default
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def set_default
|
24
|
+
self.silenced = DEFAULT_SILENCED
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/r2-oas/configuration.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'fileutils'
|
4
|
+
|
3
5
|
require_relative 'app_configuration'
|
4
6
|
require_relative 'pluggable_configuration'
|
5
7
|
require_relative 'configuration/paths_config'
|
6
8
|
require_relative 'logger/stdout_logger'
|
9
|
+
require_relative 'support/deprecation'
|
7
10
|
|
8
11
|
module R2OAS
|
9
12
|
module Configuration
|
@@ -21,6 +24,15 @@ module R2OAS
|
|
21
24
|
|
22
25
|
attr_accessor *PUBLIC_VALID_OPTIONS_KEYS
|
23
26
|
|
27
|
+
# MEMO: override because deprecated
|
28
|
+
def use_object_classes=(data)
|
29
|
+
::R2OAS::Deprecation.will_remove(<<-MSG.squish)
|
30
|
+
Using a R2OAS.use_object_classes= in configuration is deprecated and
|
31
|
+
will be removed in r2-oas (v0.4.2).
|
32
|
+
MSG
|
33
|
+
@use_object_classes = data
|
34
|
+
end
|
35
|
+
|
24
36
|
def self.extended(base)
|
25
37
|
base.send :set_default_for_configuration, base
|
26
38
|
base.send :set_default_for_pluggable, base
|
@@ -28,6 +40,7 @@ module R2OAS
|
|
28
40
|
|
29
41
|
def configure
|
30
42
|
yield self if block_given?
|
43
|
+
load_local_plugins
|
31
44
|
end
|
32
45
|
|
33
46
|
def options
|
@@ -56,8 +69,51 @@ module R2OAS
|
|
56
69
|
end
|
57
70
|
end
|
58
71
|
|
72
|
+
def load_tasks
|
73
|
+
load_local_tasks
|
74
|
+
end
|
75
|
+
|
76
|
+
def init
|
77
|
+
plugins_path = File.expand_path("#{root_dir_path}/#{local_plugins_dir_name}")
|
78
|
+
plugins_helpers_path = "#{plugins_path}/helpers"
|
79
|
+
tasks_path = File.expand_path("#{root_dir_path}/#{local_tasks_dir_name}")
|
80
|
+
tasks_helpers_path = "#{tasks_path}/helpers"
|
81
|
+
|
82
|
+
gitkeep_plugins_path = "#{plugins_path}/.gitkeep"
|
83
|
+
gitkeep_plugins_helpers_path = "#{plugins_helpers_path}/.gitkeep"
|
84
|
+
gitkeep_tasks_path = "#{tasks_path}/.gitkeep"
|
85
|
+
gitkeep_tasks_helpers_path = "#{tasks_helpers_path}/.gitkeep"
|
86
|
+
|
87
|
+
FileUtils.mkdir_p(plugins_helpers_path) unless FileTest.exists?(plugins_helpers_path)
|
88
|
+
FileUtils.mkdir_p(tasks_helpers_path) unless FileTest.exists?(tasks_helpers_path)
|
89
|
+
|
90
|
+
File.write(gitkeep_plugins_path, '') unless FileTest.exists?(gitkeep_plugins_path)
|
91
|
+
File.write(gitkeep_plugins_helpers_path, '') unless FileTest.exists?(gitkeep_plugins_helpers_path)
|
92
|
+
File.write(gitkeep_tasks_path, '') unless FileTest.exists?(gitkeep_tasks_path)
|
93
|
+
File.write(gitkeep_tasks_helpers_path, '') unless FileTest.exists?(gitkeep_tasks_helpers_path)
|
94
|
+
paths_config.create_dot_paths
|
95
|
+
end
|
96
|
+
|
97
|
+
def output_dir_path
|
98
|
+
output_path.to_s.split('/').slice(0..-2).join('/')
|
99
|
+
end
|
100
|
+
|
59
101
|
private
|
60
102
|
|
103
|
+
def load_local_tasks
|
104
|
+
tasks_path = File.expand_path("#{root_dir_path}/#{local_tasks_dir_name}")
|
105
|
+
Dir.glob("#{tasks_path}/**/*.rake").sort.each do |file|
|
106
|
+
load file if FileTest.exists?(file)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def load_local_plugins
|
111
|
+
plugins_path = File.expand_path("#{root_dir_path}/#{local_plugins_dir_name}")
|
112
|
+
Dir.glob("#{plugins_path}/**/*.rb").sort.each do |file|
|
113
|
+
require file if FileTest.exists?(file)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
61
117
|
def set_default_for_configuration(target)
|
62
118
|
AppConfiguration.set_default(target)
|
63
119
|
end
|