r2-oas 0.3.0 → 0.4.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 (129) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/GEMSPEC.md +4 -3
  4. data/README.ja.md +54 -37
  5. data/README.md +50 -31
  6. data/lib/r2-oas.rb +5 -7
  7. data/lib/r2-oas/app_configuration.rb +17 -1
  8. data/lib/r2-oas/app_configuration/deprecation.rb +28 -0
  9. data/lib/r2-oas/configuration.rb +52 -0
  10. data/lib/r2-oas/deploy/client.rb +21 -6
  11. data/lib/r2-oas/{plugins/schema/v3/object → dynamic/schema/v3/object/from_routes}/hookable_base_object.rb +7 -7
  12. data/lib/r2-oas/errors.rb +5 -0
  13. data/lib/r2-oas/hooks/hook.rb +7 -5
  14. data/lib/r2-oas/lib/core_ext/hash/deep_merge.rb +44 -0
  15. data/lib/r2-oas/lib/core_ext/object/blank.rb +135 -0
  16. data/lib/r2-oas/pluggable_configuration.rb +8 -5
  17. data/lib/r2-oas/plugin/base.rb +44 -0
  18. data/lib/r2-oas/plugin/executor.rb +148 -0
  19. data/lib/r2-oas/plugin/hookable.rb +42 -0
  20. data/lib/r2-oas/plugin/public.rb +3 -0
  21. data/lib/r2-oas/plugin/transform/transform.rb +10 -0
  22. data/lib/r2-oas/plugin/transform/v3/transform.rb +20 -0
  23. data/lib/r2-oas/plugin/transform/v3/visitable.rb +37 -0
  24. data/lib/r2-oas/public.rb +5 -0
  25. data/lib/r2-oas/schema/base.rb +1 -1
  26. data/lib/r2-oas/schema/builder.rb +1 -1
  27. data/lib/r2-oas/schema/editor.rb +8 -1
  28. data/lib/r2-oas/schema/v3/analyzer/path_analyzer.rb +1 -1
  29. data/lib/r2-oas/schema/v3/builder.rb +1 -1
  30. data/lib/r2-oas/schema/v3/builder/base_builder.rb +14 -2
  31. data/lib/r2-oas/schema/v3/builder/doc_builder.rb +10 -2
  32. data/lib/r2-oas/schema/v3/generator/base_generator.rb +7 -2
  33. data/lib/r2-oas/schema/v3/generator/doc_generator.rb +1 -1
  34. data/lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb +3 -2
  35. data/lib/r2-oas/schema/v3/object/from_files/base_object.rb +62 -0
  36. data/lib/r2-oas/schema/v3/object/from_files/components/request_body_object.rb +103 -0
  37. data/lib/r2-oas/schema/v3/object/from_files/components/schema_object.rb +102 -0
  38. data/lib/r2-oas/schema/v3/object/from_files/components_object.rb +46 -0
  39. data/lib/r2-oas/schema/v3/object/from_files/external_document_object.rb +23 -0
  40. data/lib/r2-oas/schema/v3/object/from_files/info_object.rb +23 -0
  41. data/lib/r2-oas/schema/v3/object/from_files/openapi_object.rb +61 -0
  42. data/lib/r2-oas/schema/v3/object/from_files/path_item_object.rb +110 -0
  43. data/lib/r2-oas/schema/v3/object/from_files/paths_object.rb +33 -0
  44. data/lib/r2-oas/schema/v3/object/from_files/utils/all.rb +4 -0
  45. data/lib/r2-oas/schema/v3/object/from_files/utils/deep_methods.rb +27 -0
  46. data/lib/r2-oas/schema/v3/object/from_files/utils/refs.rb +151 -0
  47. data/lib/r2-oas/schema/v3/object/{base_object.rb → from_routes/base_object.rb} +11 -1
  48. data/lib/r2-oas/schema/v3/object/{components → from_routes/components}/request_body_object.rb +23 -19
  49. data/lib/r2-oas/schema/v3/object/{components → from_routes/components}/schema_object.rb +16 -12
  50. data/lib/r2-oas/schema/v3/object/{components_object.rb → from_routes/components_object.rb} +11 -11
  51. data/lib/r2-oas/schema/v3/object/from_routes/external_document_object.rb +28 -0
  52. data/lib/r2-oas/schema/v3/object/{info_object.rb → from_routes/info_object.rb} +11 -2
  53. data/lib/r2-oas/schema/v3/object/{openapi_object.rb → from_routes/openapi_object.rb} +12 -11
  54. data/lib/r2-oas/schema/v3/object/{path_item_object.rb → from_routes/path_item_object.rb} +6 -6
  55. data/lib/r2-oas/schema/v3/object/{paths_object.rb → from_routes/paths_object.rb} +11 -8
  56. data/lib/r2-oas/schema/v3/object/{public.rb → from_routes/public.rb} +0 -0
  57. data/lib/r2-oas/schema/v3/object/{server_object.rb → from_routes/server_object.rb} +0 -0
  58. data/lib/r2-oas/schema/v3/object/{tag_object.rb → from_routes/tag_object.rb} +2 -1
  59. data/lib/r2-oas/schema/v3/object/store.rb +54 -0
  60. data/lib/r2-oas/shared/all.rb +1 -0
  61. data/lib/r2-oas/shared/callable.rb +17 -0
  62. data/lib/r2-oas/store.rb +20 -16
  63. data/lib/r2-oas/support/deprecation.rb +24 -0
  64. data/lib/r2-oas/support/deprecation/behavior.rb +21 -0
  65. data/lib/r2-oas/support/deprecation/instance_delegator.rb +42 -0
  66. data/lib/r2-oas/support/deprecation/reporting.rb +91 -0
  67. data/lib/r2-oas/task_logging.rb +3 -7
  68. data/lib/r2-oas/tasks/common.rake +1 -2
  69. data/lib/r2-oas/tasks/main.rake +31 -9
  70. data/lib/r2-oas/tasks/tool.rake +16 -6
  71. data/lib/r2-oas/version.rb +1 -1
  72. data/r2-oas.gemspec +3 -5
  73. metadata +70 -81
  74. data/.github/ISSUE_TEMPLATE.md +0 -12
  75. data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
  76. data/.gitignore +0 -16
  77. data/.rspec +0 -3
  78. data/.rubocop.yml +0 -10
  79. data/.rubocop_todo.yml +0 -282
  80. data/.travis.yml +0 -26
  81. data/Appraisals +0 -13
  82. data/CODE_OF_CONDUCT.md +0 -74
  83. data/Gemfile +0 -12
  84. data/Rakefile +0 -8
  85. data/bin/console +0 -12
  86. data/bin/setup +0 -8
  87. data/devscript/all_support_ruby.sh +0 -43
  88. data/devscript/bundle_for_all_support_ruby.sh +0 -31
  89. data/devscript/rspec_for_all_support_ruby.sh +0 -27
  90. data/docs/.nojekyll +0 -0
  91. data/docs/README.md +0 -173
  92. data/docs/_sidebar.md +0 -25
  93. data/docs/attention/if_clash.md +0 -17
  94. data/docs/index.html +0 -29
  95. data/docs/schema/3.0.0.md +0 -155
  96. data/docs/setting/COC.md +0 -14
  97. data/docs/setting/CORS.md +0 -22
  98. data/docs/setting/configure.md +0 -176
  99. data/docs/trableshouting/runtime_error.md +0 -44
  100. data/docs/usage/analyze_docs.md +0 -875
  101. data/docs/usage/clean_docs.md +0 -19
  102. data/docs/usage/deploy_docs.md +0 -839
  103. data/docs/usage/display_paths_list.md +0 -35
  104. data/docs/usage/display_paths_stats.md +0 -54
  105. data/docs/usage/edit_docs.md +0 -218
  106. data/docs/usage/generate_docs.md +0 -412
  107. data/docs/usage/monitor_docs.md +0 -219
  108. data/docs/usage/use_hook_methods.md +0 -236
  109. data/docs/usage/use_hook_to_generate_docs.md +0 -235
  110. data/docs/usage/use_schema_namespace.md +0 -181
  111. data/docs/usage/use_tag_namespace.md +0 -180
  112. data/docs/usage/view_docs.md +0 -262
  113. data/gemfiles/ruby_2.3.3.gemfile +0 -11
  114. data/gemfiles/ruby_2.4.2.gemfile +0 -11
  115. data/gemfiles/ruby_2.5.8.gemfile +0 -11
  116. data/gemfiles/ruby_2.6.6.gemfile +0 -11
  117. data/gemfiles/ruby_2.7.1.gemfile +0 -11
  118. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-16x16.png +0 -0
  119. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-32x32.png +0 -0
  120. data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.html +0 -68
  121. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js +0 -134
  122. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js.map +0 -1
  123. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js +0 -22
  124. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js.map +0 -1
  125. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css +0 -4
  126. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css.map +0 -1
  127. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js +0 -9
  128. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js.map +0 -1
  129. 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: ba83d46ef3c82522c969cdde703651d661245da9df0d232b5a1be7b709ac5a7c
4
- data.tar.gz: f93c520a94b994941cdcf8ad958482bfd69657f7f39dd1af2da5f3f03f0d89af
3
+ metadata.gz: b365f9c68dd7df3c642a3b6d067d4a63f8e112806ee68711f949c76a244652e2
4
+ data.tar.gz: c3c3ef2eca59de1d9db5889d1191ae480b8c96e09ac58cf8ef9036bb932c3781
5
5
  SHA512:
6
- metadata.gz: c0f096c893cfab491f15ef307bf731437f0790a3dc9d4ebb7c3f06ae4a77f6cfee4bc56914eb145a0c997ccd11b7d6ddc2bce707fbe8ffd0e3cca32f8c0f927c
7
- data.tar.gz: 163f8f551d87826b60a712fd9c0d6ff8011a6cf553d9e279e9bc224a431a8527ab3b27ac9534bc7ac83075bcc9eb756785b560e49db80df99d61a1a31ecb5056
6
+ metadata.gz: 24fd75460c287ff115e05b9fb86fb8f5e253a99e0c368943d54ee4b5142425ce90086857220fa158e998b3325bc7ff40f5f0af87f9adf27a9d899e3d4a4747b5
7
+ data.tar.gz: 6a8b41ccaad2f0a4fc38b4af4fbb7a569042b76623a859ec8a9d4c42072805c5d7d0b037129ce7d82c6d50637fd493e7a08e0f2b7fa64773fe8218c3b7eadd7b
@@ -1,5 +1,50 @@
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
+
18
+ ## v0.3.4
19
+
20
+ 2020-07-11
21
+
22
+ - [`Other`] Modify gemspec `files` fields ([#147](https://github.com/yukihirop/r2-oas/pull/147))
23
+ - Add `r2-oas.gemspec` into gemspec `files`
24
+
25
+ ## v0.3.3
26
+
27
+ 2020-07-11
28
+
29
+ - [`FixBugs`] A cute pet store syndrome 🐈 ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
30
+ - [`FixBugs`] R2OAS.logger.level does not work ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
31
+ - [`Breaking`] Change default namespace type from `:underbar` to `:dot` ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
32
+ - [`Other`] Modify gemspec `files` fields ([f3f4c30](https://github.com/yukihirop/r2-oas/pull/144))
33
+
34
+ Please see milestone [v0.3.3](https://github.com/yukihirop/r2-oas/milestone/3?closed=1)
35
+
36
+ ## v0.3.2
37
+
38
+ 2020-07-05
39
+
40
+ - [`Feature`] The file size at the time of gem install was reduced by about 10MB. ([dbdbce9 ](https://github.com/yukihirop/r2-oas/pull/138))
41
+
42
+ ## v0.3.1
43
+
44
+ 2020-06-07
45
+
46
+ - [`Breaking`] Remove unnecessary runtime dependencies ([384ea1a](https://github.com/yukihirop/r2-oas/pull/132))
47
+
3
48
  ## v0.3.0
4
49
 
5
50
  2020-05-30
data/GEMSPEC.md CHANGED
@@ -1,16 +1,17 @@
1
1
  Configureless and no DSL. 👍 But you can also configure.
2
+ Manage with yaml file instead of Ruby code.
2
3
  Loosely coupled to your Rails project. 👍
3
- So If it doesn't, you can always stop easily. 😢
4
+ So if you want to use another tool, you can port it right away. 😢
4
5
  Generate api docment(OpenAPI) side only from `Rails` routing.
5
6
 
6
7
  Provide rake tasks to management API Docment (OpenAPI) 🎉
7
8
 
8
-
9
+ $ bundle exec rake routes:oas:init
9
10
  $ bundle exec rake routes:oas:docs
10
11
  $ bundle exec rake routes:oas:ui
11
12
  $ bundle exec rake routes:oas:editor
12
13
  $ bundle exec rake routes:oas:monitor
13
- $ bundle exec rake routes:oas:dist
14
+ $ bundle exec rake routes:oas:build
14
15
  $ bundle exec rake routes:oas:clean
15
16
  $ bundle exec rake routes:oas:analyze
16
17
  $ bundle exec rake routes:oas:deploy
@@ -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:dist # ドキュメント配布
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
- railsプロジェクトのルートディレクトリで以下のコマンドが実行可能です。
72
+
73
+ railsプロジェクトのルートディレクトリで以下のコマンドが実行可能です。
74
+ 一般的なコマンドの使用例を示します。
75
+
76
+ ### Initialize
77
+
78
+ `r2-oas`の初期化
72
79
 
73
80
  ```bash
74
- $ # ドキュメント生成
75
- $ bundle exec rake routes:oas:docs
76
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:docs # pathsファイルを指定してドキュメント生成
77
-
78
- $ # SwaggerEditorでドキュメント編集
79
- $ bundle exec rake routes:oas:editor
80
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:editor # pathsファイルを指定してドキュメント編集
81
- $ # SwaggerUIでドキュメント閲覧
82
- $ bundle exec rake routes:oas:ui
83
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:ui # pathsファイルを指定してドキュメント閲覧
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:dist # distribute
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
- $ # Generate docs
81
- $ bundle exec rake routes:oas:docs # Generate docs
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
- $ # Start swagger editor
85
- $ bundle exec rake routes:oas:editor # Start swagger 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
- $ # Start swagger ui
88
- $ bundle exec rake routes:oas:ui # Start swagger ui
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
- $ # Monitor swagger document
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
- $ # Analyze docs
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
@@ -1,29 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'r2-oas/version'
4
- require 'r2-oas/configuration'
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
- extend ActiveSupport::Autoload
10
-
11
7
  if !defined?(::Rails)
12
8
  raise NoImplementError, 'Can not load Rails'
13
9
  # support Rails version
14
10
  elsif ::Rails::VERSION::STRING >= '4.2.5.1'
15
11
  extend Configuration
16
12
  require 'r2-oas/task'
13
+ require 'r2-oas/plugin/public'
14
+ require 'r2-oas/lib/core_ext/hash/deep_merge'
15
+ require 'r2-oas/lib/core_ext/object/blank'
17
16
 
18
17
  autoload :Base, 'r2-oas/base'
19
18
  autoload :NoImplementError, 'r2-oas/errors'
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
- extend ActiveSupport::Autoload
26
-
27
25
  autoload :Base, 'r2-oas/schema/base'
28
26
  autoload :Generator, 'r2-oas/schema/generator'
29
27
  autoload :Builder, 'r2-oas/schema/builder'
@@ -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
@@ -44,8 +45,13 @@ module R2OAS
44
45
  # rubocop:enable Style/MutableConstant
45
46
  DEFAULT_TOOL = Tool.new
46
47
  # :dot or :underbar
47
- DEFAULT_NAMESPACE_TYPE = :underbar
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
@@ -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