r2-oas 0.3.4 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +16 -1
- data/GEMSPEC.md +2 -2
- data/README.ja.md +54 -37
- data/README.md +50 -31
- data/lib/r2-oas.rb +3 -3
- data/lib/r2-oas/app_configuration.rb +16 -0
- data/lib/r2-oas/app_configuration/deprecation.rb +28 -0
- data/lib/r2-oas/configuration.rb +52 -0
- data/lib/r2-oas/deploy/client.rb +1 -1
- 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/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/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 +24 -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_logging.rb +3 -3
- data/lib/r2-oas/tasks/common.rake +1 -1
- data/lib/r2-oas/tasks/main.rake +31 -9
- data/lib/r2-oas/tasks/tool.rake +7 -4
- data/lib/r2-oas/version.rb +1 -1
- metadata +49 -22
- data/lib/r2-oas/schema/v3/object/external_document_object.rb +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b365f9c68dd7df3c642a3b6d067d4a63f8e112806ee68711f949c76a244652e2
|
4
|
+
data.tar.gz: c3c3ef2eca59de1d9db5889d1191ae480b8c96e09ac58cf8ef9036bb932c3781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24fd75460c287ff115e05b9fb86fb8f5e253a99e0c368943d54ee4b5142425ce90086857220fa158e998b3325bc7ff40f5f0af87f9adf27a9d899e3d4a4747b5
|
7
|
+
data.tar.gz: 6a8b41ccaad2f0a4fc38b4af4fbb7a569042b76623a859ec8a9d4c42072805c5d7d0b037129ce7d82c6d50637fd493e7a08e0f2b7fa64773fe8218c3b7eadd7b
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## v0.4.0
|
4
|
+
|
5
|
+
2020-07-22
|
6
|
+
|
7
|
+
- [`BigFeature`] 🎯 Implement plugin ([#154](https://github.com/yukihirop/r2-oas/pull/154))
|
8
|
+
- Please see [use plugins docs](https://yukihirop.github.io/r2-oas/#/usage/use_plugins)
|
9
|
+
- [`Feature`] Implement `routes:oas:init`([#154](https://github.com/yukihirop/r2-oas/pull/154))
|
10
|
+
- Please see [initialize docs](https://yukihirop.github.io/r2-oas/#/usage/initialize)
|
11
|
+
- [`Breaking`] Rename from `routes:oas:dist` to `routes:oas:build` ([#154](https://github.com/yukihirop/r2-oas/pull/154))
|
12
|
+
- [`Feature`] Allowed definition of custom rake tasks ([#152](https://github.com/yukihirop/r2-oas/pull/152))
|
13
|
+
- Please see [define tasks docs](https://yukihirop.github.io/r2-oas/#/usage/define_tasks)
|
14
|
+
- [`Deprecated`] Deprecated use of `R2OAS.use_object_classes=` ([#155](https://github.com/yukihirop/r2-oas/pull/155))
|
15
|
+
|
16
|
+
Please see milestone [v0.4.0](https://github.com/yukihirop/r2-oas/milestone/4?closed=1)
|
17
|
+
|
3
18
|
## v0.3.4
|
4
19
|
|
5
20
|
2020-07-11
|
@@ -16,7 +31,7 @@
|
|
16
31
|
- [`Breaking`] Change default namespace type from `:underbar` to `:dot` ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
|
17
32
|
- [`Other`] Modify gemspec `files` fields ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
|
18
33
|
|
19
|
-
|
34
|
+
Please see milestone [v0.3.3](https://github.com/yukihirop/r2-oas/milestone/3?closed=1)
|
20
35
|
|
21
36
|
## v0.3.2
|
22
37
|
|
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
|
@@ -74,38 +75,62 @@ bundle exec routes:oas:editor
|
|
74
75
|
|
75
76
|
## Usage
|
76
77
|
|
77
|
-
You can execute the following command in the root directory of rails.
|
78
|
+
You can execute the following command in the root directory of rails.
|
79
|
+
The following are examples of typical command usage.
|
80
|
+
|
81
|
+
Full docs are available at https://yukihirop.github.io/r2-oas
|
82
|
+
|
83
|
+
### Initialize
|
84
|
+
|
85
|
+
Initialize r2-oas.
|
78
86
|
|
79
87
|
```bash
|
80
|
-
$
|
81
|
-
|
88
|
+
$ bundle exec rake routes:oas:init
|
89
|
+
```
|
90
|
+
|
91
|
+
### Generate
|
92
|
+
|
93
|
+
Generate docs.
|
94
|
+
|
95
|
+
```bash
|
96
|
+
$ bundle exec rake routes:oas:docs # Generate docs
|
82
97
|
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:docs # Generate docs by specify unit paths
|
98
|
+
```
|
99
|
+
|
100
|
+
### Editor
|
101
|
+
|
102
|
+
Start swagger editor.
|
83
103
|
|
84
|
-
|
85
|
-
$ bundle exec rake routes:oas:editor
|
104
|
+
```bash
|
105
|
+
$ bundle exec rake routes:oas:editor # Start swagger editor
|
86
106
|
$ 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
|
-
|
107
|
+
```
|
108
|
+
|
109
|
+
### UI
|
110
|
+
|
111
|
+
Start swagger ui.
|
112
|
+
|
113
|
+
```bash
|
114
|
+
$ bundle exec rake routes:oas:ui # Start swagger ui
|
89
115
|
$ 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
|
-
$ bundle exec rake routes:oas:monitor # Monitor swagger document
|
92
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:monitor # Monitor swagger by specify unit paths
|
116
|
+
```
|
93
117
|
|
94
|
-
|
118
|
+
### Build
|
119
|
+
|
120
|
+
Build docs.
|
121
|
+
`Plugin is applied`
|
122
|
+
|
123
|
+
```bash
|
124
|
+
$ bundle exec rake routes:oas:build
|
125
|
+
```
|
126
|
+
|
127
|
+
### Analyze
|
128
|
+
|
129
|
+
Analyze docs.
|
130
|
+
Reads OpenAPI format document and divides it into several parts to generate a source file
|
131
|
+
|
132
|
+
```bash
|
95
133
|
$ 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
134
|
```
|
110
135
|
|
111
136
|
## 📚 Documents
|
@@ -150,12 +175,6 @@ All settings are `optional`
|
|
150
175
|
|
151
176
|
Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configure
|
152
177
|
|
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
178
|
## Bundle and Rspec with multiple ruby versions
|
160
179
|
|
161
180
|
#### 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,6 +10,7 @@ module R2OAS
|
|
12
10
|
elsif ::Rails::VERSION::STRING >= '4.2.5.1'
|
13
11
|
extend Configuration
|
14
12
|
require 'r2-oas/task'
|
13
|
+
require 'r2-oas/plugin/public'
|
15
14
|
require 'r2-oas/lib/core_ext/hash/deep_merge'
|
16
15
|
require 'r2-oas/lib/core_ext/object/blank'
|
17
16
|
|
@@ -20,6 +19,7 @@ module R2OAS
|
|
20
19
|
autoload :NoFileExistsError, 'r2-oas/errors'
|
21
20
|
autoload :NoSupportError, 'r2-oas/errors'
|
22
21
|
autoload :Sortable, 'r2-oas/shared/all'
|
22
|
+
autoload :Deprecation, 'r2-oas/support/deprecation'
|
23
23
|
|
24
24
|
module Schema
|
25
25
|
autoload :Base, 'r2-oas/schema/base'
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require_relative 'app_configuration/server'
|
4
4
|
require_relative 'app_configuration/swagger'
|
5
5
|
require_relative 'app_configuration/tool'
|
6
|
+
require_relative 'app_configuration/deprecation'
|
6
7
|
|
7
8
|
module R2OAS
|
8
9
|
module AppConfiguration
|
@@ -46,6 +47,11 @@ module R2OAS
|
|
46
47
|
# :dot or :underbar
|
47
48
|
DEFAULT_NAMESPACE_TYPE = :dot
|
48
49
|
DEFAULT_DEPLOY_DIR_PATH = './deploy_docs'
|
50
|
+
EDFAULT_PLUGINS = [].freeze
|
51
|
+
DEFAULT_LOCAL_PLUGINS_DIR_NAME = 'plugins'
|
52
|
+
DEFAULT_LOCAL_TASKS_DIR_NAME = 'tasks'
|
53
|
+
DEFAULT_OUTPUT_PATH = './oas_docs/dist/oas_doc.yml'
|
54
|
+
DEFAULT_DEPRECATION = Deprecation.new
|
49
55
|
|
50
56
|
PUBLIC_VALID_OPTIONS_KEYS = %i[
|
51
57
|
version
|
@@ -64,6 +70,11 @@ module R2OAS
|
|
64
70
|
tool
|
65
71
|
namespace_type
|
66
72
|
deploy_dir_path
|
73
|
+
plugins
|
74
|
+
local_plugins_dir_name
|
75
|
+
local_tasks_dir_name
|
76
|
+
output_path
|
77
|
+
deprecation
|
67
78
|
].freeze
|
68
79
|
|
69
80
|
UNPUBLIC_VALID_OPTIONS_KEYS = %i[
|
@@ -100,6 +111,11 @@ module R2OAS
|
|
100
111
|
target.ignored_http_statuses_when_generate_component_schema = DEFAULT_IGNORED_HTTP_STATUSES_WHEN_GENERATE_COMPONENT_SCHEMA
|
101
112
|
target.namespace_type = DEFAULT_NAMESPACE_TYPE
|
102
113
|
target.deploy_dir_path = DEFAULT_DEPLOY_DIR_PATH
|
114
|
+
target.plugins = EDFAULT_PLUGINS
|
115
|
+
target.local_plugins_dir_name = DEFAULT_LOCAL_PLUGINS_DIR_NAME
|
116
|
+
target.local_tasks_dir_name = DEFAULT_LOCAL_TASKS_DIR_NAME
|
117
|
+
target.output_path = DEFAULT_OUTPUT_PATH
|
118
|
+
target.deprecation = DEFAULT_DEPRECATION
|
103
119
|
end
|
104
120
|
end
|
105
121
|
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,47 @@ module R2OAS
|
|
56
69
|
end
|
57
70
|
end
|
58
71
|
|
72
|
+
def load_tasks
|
73
|
+
tasks_path = File.expand_path("#{root_dir_path}/#{local_tasks_dir_name}")
|
74
|
+
Dir.glob("#{tasks_path}/**/*.rake").sort.each do |file|
|
75
|
+
load file if FileTest.exists?(file)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def init
|
80
|
+
plugins_path = File.expand_path("#{root_dir_path}/#{local_plugins_dir_name}")
|
81
|
+
plugins_helpers_path = "#{plugins_path}/helpers"
|
82
|
+
tasks_path = File.expand_path("#{root_dir_path}/#{local_tasks_dir_name}")
|
83
|
+
tasks_helpers_path = "#{tasks_path}/helpers"
|
84
|
+
|
85
|
+
gitkeep_plugins_path = "#{plugins_path}/.gitkeep"
|
86
|
+
gitkeep_plugins_helpers_path = "#{plugins_helpers_path}/.gitkeep"
|
87
|
+
gitkeep_tasks_path = "#{tasks_path}/.gitkeep"
|
88
|
+
gitkeep_tasks_helpers_path = "#{tasks_helpers_path}/.gitkeep"
|
89
|
+
|
90
|
+
FileUtils.mkdir_p(plugins_helpers_path) unless FileTest.exists?(plugins_helpers_path)
|
91
|
+
FileUtils.mkdir_p(tasks_helpers_path) unless FileTest.exists?(tasks_helpers_path)
|
92
|
+
|
93
|
+
File.write(gitkeep_plugins_path, '') unless FileTest.exists?(gitkeep_plugins_path)
|
94
|
+
File.write(gitkeep_plugins_helpers_path, '') unless FileTest.exists?(gitkeep_plugins_helpers_path)
|
95
|
+
File.write(gitkeep_tasks_path, '') unless FileTest.exists?(gitkeep_tasks_path)
|
96
|
+
File.write(gitkeep_tasks_helpers_path, '') unless FileTest.exists?(gitkeep_tasks_helpers_path)
|
97
|
+
paths_config.create_dot_paths
|
98
|
+
end
|
99
|
+
|
100
|
+
def output_dir_path
|
101
|
+
output_path.to_s.split('/').slice(0..-2).join('/')
|
102
|
+
end
|
103
|
+
|
59
104
|
private
|
60
105
|
|
106
|
+
def load_local_plugins
|
107
|
+
plugins_path = File.expand_path("#{root_dir_path}/#{local_plugins_dir_name}")
|
108
|
+
Dir.glob("#{plugins_path}/**/*.rb").sort.each do |file|
|
109
|
+
require file if FileTest.exists?(file)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
61
113
|
def set_default_for_configuration(target)
|
62
114
|
AppConfiguration.set_default(target)
|
63
115
|
end
|