r2-oas 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.
- checksums.yaml +7 -0
- data/CHANGELOG.md +99 -0
- data/GEMSPEC.md +20 -0
- data/LICENSE.txt +21 -0
- data/README.ja.md +271 -0
- data/README.md +271 -0
- data/lib/r2-oas.rb +35 -0
- data/lib/r2-oas/app_configuration.rb +121 -0
- data/lib/r2-oas/app_configuration/deprecation.rb +28 -0
- data/lib/r2-oas/app_configuration/server.rb +35 -0
- data/lib/r2-oas/app_configuration/swagger.rb +35 -0
- data/lib/r2-oas/app_configuration/swagger/editor.rb +47 -0
- data/lib/r2-oas/app_configuration/swagger/ui.rb +45 -0
- data/lib/r2-oas/app_configuration/tool.rb +31 -0
- data/lib/r2-oas/app_configuration/tool/paths/stats.rb +43 -0
- data/lib/r2-oas/base.rb +48 -0
- data/lib/r2-oas/configuration.rb +121 -0
- data/lib/r2-oas/configuration/paths_config.rb +44 -0
- data/lib/r2-oas/deploy/client.rb +70 -0
- data/lib/r2-oas/deploy/swagger-ui/index.html.erb +60 -0
- data/lib/r2-oas/dynamic/schema/v3/object/from_routes/hookable_base_object.rb +100 -0
- data/lib/r2-oas/errors.rb +13 -0
- data/lib/r2-oas/hooks/global_hook.rb +20 -0
- data/lib/r2-oas/hooks/hook.rb +79 -0
- data/lib/r2-oas/hooks/repository.rb +15 -0
- data/lib/r2-oas/lib/core_ext/hash/deep_merge.rb +44 -0
- data/lib/r2-oas/lib/core_ext/object/blank.rb +135 -0
- data/lib/r2-oas/lib/three-way-merge/twm.rb +83 -0
- data/lib/r2-oas/logger/stdout_logger.rb +129 -0
- data/lib/r2-oas/pluggable_configuration.rb +36 -0
- 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/routing/adjustor.rb +44 -0
- data/lib/r2-oas/routing/base.rb +12 -0
- data/lib/r2-oas/routing/components/all.rb +5 -0
- data/lib/r2-oas/routing/components/base_component.rb +10 -0
- data/lib/r2-oas/routing/components/path_component.rb +67 -0
- data/lib/r2-oas/routing/components/request_component.rb +75 -0
- data/lib/r2-oas/routing/components/verb_component.rb +21 -0
- data/lib/r2-oas/routing/parser.rb +93 -0
- data/lib/r2-oas/schema/analyzer.rb +23 -0
- data/lib/r2-oas/schema/base.rb +11 -0
- data/lib/r2-oas/schema/builder.rb +23 -0
- data/lib/r2-oas/schema/cleaner.rb +23 -0
- data/lib/r2-oas/schema/editor.rb +146 -0
- data/lib/r2-oas/schema/generator.rb +23 -0
- data/lib/r2-oas/schema/manager/file/path_item_file_manager.rb +24 -0
- data/lib/r2-oas/schema/manager/file_manager.rb +26 -0
- data/lib/r2-oas/schema/monitor.rb +52 -0
- data/lib/r2-oas/schema/squeezer.rb +23 -0
- data/lib/r2-oas/schema/ui.rb +73 -0
- data/lib/r2-oas/schema/v3/analyzer.rb +58 -0
- data/lib/r2-oas/schema/v3/analyzer/base_analyzer.rb +71 -0
- data/lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb +38 -0
- data/lib/r2-oas/schema/v3/analyzer/components_analyzer.rb +30 -0
- data/lib/r2-oas/schema/v3/analyzer/path_analyzer.rb +116 -0
- data/lib/r2-oas/schema/v3/analyzer/tag_analyzer.rb +38 -0
- data/lib/r2-oas/schema/v3/base.rb +28 -0
- data/lib/r2-oas/schema/v3/builder.rb +28 -0
- data/lib/r2-oas/schema/v3/builder/base_builder.rb +72 -0
- data/lib/r2-oas/schema/v3/builder/doc_builder.rb +51 -0
- data/lib/r2-oas/schema/v3/cleaner.rb +19 -0
- data/lib/r2-oas/schema/v3/cleaner/base_cleaner.rb +30 -0
- data/lib/r2-oas/schema/v3/cleaner/components_cleaner.rb +42 -0
- data/lib/r2-oas/schema/v3/generator.rb +24 -0
- data/lib/r2-oas/schema/v3/generator/base_generator.rb +122 -0
- data/lib/r2-oas/schema/v3/generator/components/object_generator.rb +64 -0
- data/lib/r2-oas/schema/v3/generator/components/request_body_generator.rb +45 -0
- data/lib/r2-oas/schema/v3/generator/components_generator.rb +38 -0
- data/lib/r2-oas/schema/v3/generator/doc_generator.rb +115 -0
- data/lib/r2-oas/schema/v3/generator/path_generator.rb +78 -0
- data/lib/r2-oas/schema/v3/generator/schema_generator.rb +58 -0
- data/lib/r2-oas/schema/v3/manager/diff/base_array_diff_manager.rb +60 -0
- data/lib/r2-oas/schema/v3/manager/diff/base_diff_manager.rb +29 -0
- data/lib/r2-oas/schema/v3/manager/diff/base_hash_diff_manager.rb +95 -0
- data/lib/r2-oas/schema/v3/manager/diff/components_diff_manager.rb +19 -0
- data/lib/r2-oas/schema/v3/manager/diff/tag_diff_manager.rb +17 -0
- data/lib/r2-oas/schema/v3/manager/file/base_file_manager.rb +66 -0
- data/lib/r2-oas/schema/v3/manager/file/components_file_manager.rb +22 -0
- data/lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb +89 -0
- data/lib/r2-oas/schema/v3/manager/file/path_item_file_manager.rb +22 -0
- data/lib/r2-oas/schema/v3/manager/file_manager.rb +12 -0
- data/lib/r2-oas/schema/v3/manager/pathname_manager.rb +78 -0
- 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/from_routes/base_object.rb +75 -0
- data/lib/r2-oas/schema/v3/object/from_routes/components/request_body_object.rb +96 -0
- data/lib/r2-oas/schema/v3/object/from_routes/components/schema_object.rb +59 -0
- data/lib/r2-oas/schema/v3/object/from_routes/components_object.rb +81 -0
- data/lib/r2-oas/schema/v3/object/from_routes/external_document_object.rb +28 -0
- data/lib/r2-oas/schema/v3/object/from_routes/info_object.rb +43 -0
- data/lib/r2-oas/schema/v3/object/from_routes/openapi_object.rb +59 -0
- data/lib/r2-oas/schema/v3/object/from_routes/path_item_object.rb +175 -0
- data/lib/r2-oas/schema/v3/object/from_routes/paths_object.rb +77 -0
- data/lib/r2-oas/schema/v3/object/from_routes/public.rb +9 -0
- data/lib/r2-oas/schema/v3/object/from_routes/server_object.rb +21 -0
- data/lib/r2-oas/schema/v3/object/from_routes/tag_object.rb +37 -0
- data/lib/r2-oas/schema/v3/object/store.rb +54 -0
- data/lib/r2-oas/schema/v3/squeezer.rb +29 -0
- data/lib/r2-oas/schema/v3/squeezer/base_squeezer.rb +37 -0
- data/lib/r2-oas/schema/v3/squeezer/path_squeezer.rb +28 -0
- data/lib/r2-oas/schema/v3/squeezer/tag_squeezer.rb +19 -0
- data/lib/r2-oas/shared/all.rb +4 -0
- data/lib/r2-oas/shared/callable.rb +17 -0
- data/lib/r2-oas/shared/sortable.rb +23 -0
- data/lib/r2-oas/store.rb +122 -0
- 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.rb +11 -0
- data/lib/r2-oas/task_logging.rb +41 -0
- data/lib/r2-oas/tasks/common.rake +25 -0
- data/lib/r2-oas/tasks/main.rake +132 -0
- data/lib/r2-oas/tasks/tool.rake +86 -0
- data/lib/r2-oas/tool/paths/ls.rb +15 -0
- data/lib/r2-oas/tool/paths/stats.rb +84 -0
- data/lib/r2-oas/version.rb +5 -0
- data/r2-oas.gemspec +48 -0
- metadata +415 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b365f9c68dd7df3c642a3b6d067d4a63f8e112806ee68711f949c76a244652e2
|
|
4
|
+
data.tar.gz: c3c3ef2eca59de1d9db5889d1191ae480b8c96e09ac58cf8ef9036bb932c3781
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 24fd75460c287ff115e05b9fb86fb8f5e253a99e0c368943d54ee4b5142425ce90086857220fa158e998b3325bc7ff40f5f0af87f9adf27a9d899e3d4a4747b5
|
|
7
|
+
data.tar.gz: 6a8b41ccaad2f0a4fc38b4af4fbb7a569042b76623a859ec8a9d4c42072805c5d7d0b037129ce7d82c6d50637fd493e7a08e0f2b7fa64773fe8218c3b7eadd7b
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Change Log
|
|
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
|
+
|
|
48
|
+
## v0.3.0
|
|
49
|
+
|
|
50
|
+
2020-05-30
|
|
51
|
+
|
|
52
|
+
- [`Feature/Breaking`] Support Ruby 2.7 🎉 ([931ec4b](https://github.com/yukihirop/r2-oas/pull/122))
|
|
53
|
+
|
|
54
|
+
- Remove `Gemfile.lock`
|
|
55
|
+
|
|
56
|
+
- [`Developer`] Create script to test all support ruby in development ([8d0df98](https://github.com/yukihirop/r2-oas/pull/124))
|
|
57
|
+
- [`Docs`] Add docs about Trableshouting ([f4a782f](https://github.com/yukihirop/r2-oas/pull/125))
|
|
58
|
+
|
|
59
|
+
## v0.2.0
|
|
60
|
+
|
|
61
|
+
2020-05-02
|
|
62
|
+
|
|
63
|
+
- [`Feature/Breaking`] Upgrade `routes:oas:docs` cmd ([37ccddf](https://github.com/yukihirop/r2-oas/pull/117))
|
|
64
|
+
|
|
65
|
+
- `.docs` is needed to continue using r2-oas. `If you are using previous version`,you need to run the following command to generate `.docs`.
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
CACHE_DOCS=true bundle exec rake routes:oas:docs
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
- [`Breaking`] Divide into `Generator` and `Builder` ([00fea7d](https://github.com/yukihirop/r2-oas/pull/116))
|
|
72
|
+
- `routes:oas:docs` cmd do not generate `oas_docs/oas_doc.yml`
|
|
73
|
+
|
|
74
|
+
## v0.1.3
|
|
75
|
+
|
|
76
|
+
2020-04-27
|
|
77
|
+
|
|
78
|
+
- [`FixBugs`] Fix clash when edit ([906d068](https://github.com/yukihirop/r2-oas/pull/109))
|
|
79
|
+
- [`Feature`] Change log display to relative path ([c735d22](https://github.com/yukihirop/r2-oas/pull/111))
|
|
80
|
+
|
|
81
|
+
## v0.1.2
|
|
82
|
+
|
|
83
|
+
2020-04-22
|
|
84
|
+
|
|
85
|
+
- No Change
|
|
86
|
+
|
|
87
|
+
## v0.1.1
|
|
88
|
+
|
|
89
|
+
2020-04-22
|
|
90
|
+
|
|
91
|
+
- [`Feature`] Create document by docsify([def4463](https://github.com/yukihirop/r2-oas/pull/99))
|
|
92
|
+
- [`Breaking`] Do not generate component schema when http_status equal 204 and 404 by default ([f7fcafd](https://github.com/yukihirop/r2-oas/pull/103))
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
## v0.1.0
|
|
96
|
+
|
|
97
|
+
2019-10-22 / The day of the throne (called 即位礼正殿の儀の行われる日 in Japanease)
|
|
98
|
+
|
|
99
|
+
- first release
|
data/GEMSPEC.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Configureless and no DSL. 👍 But you can also configure.
|
|
2
|
+
Manage with yaml file instead of Ruby code.
|
|
3
|
+
Loosely coupled to your Rails project. 👍
|
|
4
|
+
So if you want to use another tool, you can port it right away. 😢
|
|
5
|
+
Generate api docment(OpenAPI) side only from `Rails` routing.
|
|
6
|
+
|
|
7
|
+
Provide rake tasks to management API Docment (OpenAPI) 🎉
|
|
8
|
+
|
|
9
|
+
$ bundle exec rake routes:oas:init
|
|
10
|
+
$ bundle exec rake routes:oas:docs
|
|
11
|
+
$ bundle exec rake routes:oas:ui
|
|
12
|
+
$ bundle exec rake routes:oas:editor
|
|
13
|
+
$ bundle exec rake routes:oas:monitor
|
|
14
|
+
$ bundle exec rake routes:oas:build
|
|
15
|
+
$ bundle exec rake routes:oas:clean
|
|
16
|
+
$ bundle exec rake routes:oas:analyze
|
|
17
|
+
$ bundle exec rake routes:oas:deploy
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
Happy Coding ❗️
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 yukihirop
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.ja.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# R2-OAS
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/r2-oas)
|
|
4
|
+
[](https://travis-ci.org/yukihirop/r2-oas)
|
|
5
|
+
[](https://coveralls.io/github/yukihirop/r2-oas)
|
|
6
|
+
[](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
|
|
7
|
+
|
|
8
|
+
Railsのルーティング情報からOpenAPI形式のドキュメントを生成し、閲覧・編集・管理するためのrakeタスクの提供をします。
|
|
9
|
+
|
|
10
|
+
```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 # ドキュメントデプロイ
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## 💎 Installation
|
|
23
|
+
|
|
24
|
+
railsアプリケーションのGemfileに以下を追加します。
|
|
25
|
+
|
|
26
|
+
```ruby
|
|
27
|
+
group :development do
|
|
28
|
+
gem 'r2-oas'
|
|
29
|
+
end
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## 🔦 Requirements
|
|
33
|
+
|
|
34
|
+
もしSwaggerEditorやSwaggerUIを使ってドキュメントを閲覧・編集する場合には以下のものが必要です。
|
|
35
|
+
|
|
36
|
+
- [`swaggerapi/swagger-ui:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-ui/)
|
|
37
|
+
- [`swaggerapi/swagger-editor:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-editor/)
|
|
38
|
+
- [`chromedriver`](http://chromedriver.chromium.org/downloads)
|
|
39
|
+
|
|
40
|
+
もしダウンロードしてなかったら以下のコマンドでダウンロードできます。
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
$ docker pull swaggerapi/swagger-editor:latest
|
|
44
|
+
$ docker pull swaggerapi/swagger-ui:latest
|
|
45
|
+
$ brew cask install chromedriver
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## 🚀 Tutorial
|
|
49
|
+
|
|
50
|
+
gemをrequire後、以下のrakeタスクを実行するだけです。
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
bundle exec routes:oas:docs
|
|
54
|
+
bundle exec routes:oas:editor
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
#### Generate docs
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
#### Edit docs
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+
|
|
66
|
+
## 📚 Documents
|
|
67
|
+
|
|
68
|
+
公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas
|
|
69
|
+
|
|
70
|
+
## 📖 Usage
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
railsプロジェクトのルートディレクトリで以下のコマンドが実行可能です。
|
|
74
|
+
一般的なコマンドの使用例を示します。
|
|
75
|
+
|
|
76
|
+
### Initialize
|
|
77
|
+
|
|
78
|
+
`r2-oas`の初期化
|
|
79
|
+
|
|
80
|
+
```bash
|
|
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
|
|
91
|
+
```
|
|
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
|
+
```
|
|
128
|
+
|
|
129
|
+
## ⚾️ sample
|
|
130
|
+
|
|
131
|
+
実際の使用例を見るにはこちらのリポジトリを参考にしてください。
|
|
132
|
+
|
|
133
|
+
- [yukihirop/r2oas-k8s-example](https://github.com/yukihirop/r2oas-k8s-example)
|
|
134
|
+
- [yukihirop/r2oas-moneyforward-example](https://github.com/yukihirop/r2oas-moneyforward-example)
|
|
135
|
+
- [yukihirop/r2oas-leaddesk-example](https://github.com/yukihirop/r2oas-leaddesk-example)
|
|
136
|
+
- [yukihirop/r2oas-advanced-example](https://github.com/yukihirop/r2oas-advanced-example)
|
|
137
|
+
|
|
138
|
+
## ❤️ Support Rails Version
|
|
139
|
+
|
|
140
|
+
- Rails (>= 4.2.5.1)
|
|
141
|
+
|
|
142
|
+
## ❤️ Support Ruby Version
|
|
143
|
+
|
|
144
|
+
- Ruby (>= 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin18])
|
|
145
|
+
|
|
146
|
+
## ❤️ Support Rouging
|
|
147
|
+
|
|
148
|
+
- Rails Engine Routing
|
|
149
|
+
- Rails Normal Routing
|
|
150
|
+
|
|
151
|
+
## ❤️ Support OpenAPI Schema
|
|
152
|
+
|
|
153
|
+
OpenAPIの3.0.0をサポートしてます。
|
|
154
|
+
|
|
155
|
+
公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/schema/3.0.0
|
|
156
|
+
|
|
157
|
+
## ❗️Convention over Configuration (CoC)
|
|
158
|
+
|
|
159
|
+
ツールを便利にするために、設定よりも制約があります。
|
|
160
|
+
|
|
161
|
+
- `タグ名` は `コントローラー名` を表しており、`pathsファイル名とパス` を決定するのに使用されます。
|
|
162
|
+
- 例えば、 `コントローラー名` が `Api::V1::UsersController` ならば、 `タグ名` は `api/v1/user` になります。そして、 `pathsファイル名とパス` は `api/v1/user.yml` となります。
|
|
163
|
+
|
|
164
|
+
- `components/{schemas, requestBodies, ...}名` の `_` は保存時に `/` に変換されます。hennkannsaremasu.
|
|
165
|
+
- 例えば、 `components/schemas名` が `Api_V1_User` なら、 `components/schemasのファイル名とパス` は `api/v1/user.yml` となります。
|
|
166
|
+
- フォーマットは、 `Namespace1_Namespace2_Model` です。
|
|
167
|
+
|
|
168
|
+
- `components/{schemas, requestBodies, ...}名` の `.` は保存時に `/` に変換されます。hennkannsaremasu.
|
|
169
|
+
- 例えば、 `components/schemas名` が `api.v1.User` なら、 `components/schemasのファイル名とパス` は `api/v1/user.yml` となります。
|
|
170
|
+
- フォーマットは、 `namespace1.namespace2.Model` です。
|
|
171
|
+
|
|
172
|
+
## ⚙ Configure
|
|
173
|
+
|
|
174
|
+
全ての設定は `オプショナル` です。設定してもしなくても構いません。
|
|
175
|
+
|
|
176
|
+
公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/setting/configure
|
|
177
|
+
|
|
178
|
+
## Bundle and Rspec with multiple ruby versions
|
|
179
|
+
|
|
180
|
+
#### Bundle
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
/bin/bash devscript/all_support_ruby.sh bundle
|
|
184
|
+
.
|
|
185
|
+
.
|
|
186
|
+
.
|
|
187
|
+
===== Bundle install for All Support Ruby Result =====
|
|
188
|
+
ruby-2.3.3: 0
|
|
189
|
+
ruby-2.4.2: 0
|
|
190
|
+
ruby-2.5.8: 0
|
|
191
|
+
ruby-2.6.6: 0
|
|
192
|
+
ruby-2.7.1: 0
|
|
193
|
+
======================================================
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
rubyのバージョンを `2.6.6` と `2.7.1` に指定する場合
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
/bin/bash devscript/all_support_ruby.sh bundle 2.6.6 2.7.1
|
|
200
|
+
.
|
|
201
|
+
.
|
|
202
|
+
.
|
|
203
|
+
===== Bundle install for All Support Ruby Result =====
|
|
204
|
+
ruby-2.6.6: 0
|
|
205
|
+
ruby-2.7.1: 0
|
|
206
|
+
======================================================
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### Rspec
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
/bin/bash devscript/all_support_ruby.sh rspec
|
|
213
|
+
.
|
|
214
|
+
.
|
|
215
|
+
.
|
|
216
|
+
===== Rspec for All Support Ruby Result =====
|
|
217
|
+
ruby-2.3.3: 0
|
|
218
|
+
ruby-2.4.2: 0
|
|
219
|
+
ruby-2.5.8: 0
|
|
220
|
+
ruby-2.6.6: 0
|
|
221
|
+
ruby-2.7.1: 0
|
|
222
|
+
=============================================
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
rubyのバージョンを `2.6.6` と `2.7.1` に指定する場合
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
/bin/bash devscript/all_support_ruby.sh rspec 2.6.6 2.7.1
|
|
229
|
+
.
|
|
230
|
+
.
|
|
231
|
+
.
|
|
232
|
+
===== Rspec for All Support Ruby Result =====
|
|
233
|
+
ruby-2.6.6: 0
|
|
234
|
+
ruby-2.7.1: 0
|
|
235
|
+
=============================================
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 🔩 CORS
|
|
239
|
+
|
|
240
|
+
[rack-cors](https://github.com/cyu/rack-cors)を使用する事でCORSを可能にします。
|
|
241
|
+
|
|
242
|
+
```ruby
|
|
243
|
+
require 'rack/cors'
|
|
244
|
+
use Rack::Cors do
|
|
245
|
+
allow do
|
|
246
|
+
origins '*'
|
|
247
|
+
resource '*', headers: :any, methods: [ :get, :post, :put, :delete, :options ]
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
`before` ブロックにCORSヘッダーを設定できます。
|
|
253
|
+
|
|
254
|
+
```ruby
|
|
255
|
+
before do
|
|
256
|
+
header['Access-Control-Allow-Origin'] = '*'
|
|
257
|
+
header['Access-Control-Request-Method'] = '*'
|
|
258
|
+
end
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 📝 License
|
|
262
|
+
|
|
263
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
264
|
+
|
|
265
|
+
## 🤝 Contributing
|
|
266
|
+
|
|
267
|
+
1. Fork it ( http://github.com/yukihirop/r2-oas/fork )
|
|
268
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
269
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
270
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
271
|
+
5. Create new Pull Request
|
data/README.md
ADDED
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
# R2-OAS
|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/rb/r2-oas)
|
|
4
|
+
[](https://travis-ci.org/yukihirop/r2-oas)
|
|
5
|
+
[](https://coveralls.io/github/yukihirop/r2-oas)
|
|
6
|
+
[](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
|
|
7
|
+
|
|
8
|
+
Generate api docment(OpenAPI) side only from `Rails` routing.
|
|
9
|
+
|
|
10
|
+
Provides a rake command to help `generate` , `view` , and `edit` OpenAPI documents.
|
|
11
|
+
|
|
12
|
+
```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
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## 💎 Installation
|
|
25
|
+
|
|
26
|
+
Add this line to your application's Gemfile:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
group :development do
|
|
30
|
+
gem 'r2-oas'
|
|
31
|
+
end
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
And then execute:
|
|
35
|
+
|
|
36
|
+
$ bundle
|
|
37
|
+
|
|
38
|
+
Or install it yourself as:
|
|
39
|
+
|
|
40
|
+
$ gem install r2-oas
|
|
41
|
+
|
|
42
|
+
## 🔦 Requirements
|
|
43
|
+
|
|
44
|
+
If you want to view with `Swagger UI` or edit with `Swagger Editor`, This gem needs the following:
|
|
45
|
+
|
|
46
|
+
- [`swaggerapi/swagger-ui:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-ui/)
|
|
47
|
+
- [`swaggerapi/swagger-editor:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-editor/)
|
|
48
|
+
- [`chromedriver`](http://chromedriver.chromium.org/downloads)
|
|
49
|
+
|
|
50
|
+
If you do not have it download as below.
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
$ docker pull swaggerapi/swagger-editor:latest
|
|
54
|
+
$ docker pull swaggerapi/swagger-ui:latest
|
|
55
|
+
$ brew cask install chromedriver
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## 🚀 Tutorial
|
|
59
|
+
|
|
60
|
+
After requiring a gem,
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
bundle exec routes:oas:docs
|
|
64
|
+
bundle exec routes:oas:editor
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Generate docs
|
|
68
|
+
|
|
69
|
+

|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
#### Edit docs
|
|
73
|
+
|
|
74
|
+

|
|
75
|
+
|
|
76
|
+
## Usage
|
|
77
|
+
|
|
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.
|
|
86
|
+
|
|
87
|
+
```bash
|
|
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
|
|
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.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
$ bundle exec rake routes:oas:editor # Start swagger editor
|
|
106
|
+
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:editor # Start swagger editor by specify unit paths
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### UI
|
|
110
|
+
|
|
111
|
+
Start swagger ui.
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
$ bundle exec rake routes:oas:ui # Start swagger ui
|
|
115
|
+
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:ui # Start swagger ui by specify unit paths
|
|
116
|
+
```
|
|
117
|
+
|
|
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
|
|
133
|
+
$ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
## 📚 Documents
|
|
137
|
+
|
|
138
|
+
Full docs are available at https://yukihirop.github.io/r2-oas
|
|
139
|
+
|
|
140
|
+
## ❤️ Support Rails Version
|
|
141
|
+
|
|
142
|
+
- Rails (>= 4.2.5.1)
|
|
143
|
+
|
|
144
|
+
## ❤️ Support Ruby Version
|
|
145
|
+
|
|
146
|
+
- Ruby (>= 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin18])
|
|
147
|
+
|
|
148
|
+
## ❤️ Support Rouging
|
|
149
|
+
|
|
150
|
+
- Rails Engine Routing
|
|
151
|
+
- Rails Normal Routing
|
|
152
|
+
|
|
153
|
+
## ❤️ Support OpenAPI Schema
|
|
154
|
+
|
|
155
|
+
Full docs are available at https://yukihirop.github.io/r2-oas/#/schema/3.0.0
|
|
156
|
+
|
|
157
|
+
## ❗️ Convention over Configuration (CoC)
|
|
158
|
+
|
|
159
|
+
- `tag name` represents `controller name` and determine `paths file name`.
|
|
160
|
+
- For example, If `controller name` is `Api::V1::UsersController`, `tag_name` is `api/v1/user`. and `paths file name` is `api/v1/user.yml`
|
|
161
|
+
|
|
162
|
+
- `_` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
|
|
163
|
+
- For example, If `components/schemas name` is `Api_V1_User`, `components/schemas file name` is `api/v1/user.yml`.
|
|
164
|
+
- `_` is supposed to be used to express `namespace`.
|
|
165
|
+
- format is `Namespace1_Namespace2_Model`.
|
|
166
|
+
|
|
167
|
+
- `.` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
|
|
168
|
+
- For example, If `components/schemas name` is `api.v1.User`, `components/schemas file name` is `api/v1/user.yml`.
|
|
169
|
+
- `.` is supposed to be used to express `namespace`.
|
|
170
|
+
- format is `namespace1.namespace2.Model`.
|
|
171
|
+
|
|
172
|
+
## ⚙ Configure
|
|
173
|
+
|
|
174
|
+
All settings are `optional`
|
|
175
|
+
|
|
176
|
+
Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configure
|
|
177
|
+
|
|
178
|
+
## Bundle and Rspec with multiple ruby versions
|
|
179
|
+
|
|
180
|
+
#### Bundle
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
/bin/bash devscript/all_support_ruby.sh bundle
|
|
184
|
+
.
|
|
185
|
+
.
|
|
186
|
+
.
|
|
187
|
+
===== Bundle install for All Support Ruby Result =====
|
|
188
|
+
ruby-2.3.3: 0
|
|
189
|
+
ruby-2.4.2: 0
|
|
190
|
+
ruby-2.5.8: 0
|
|
191
|
+
ruby-2.6.6: 0
|
|
192
|
+
ruby-2.7.1: 0
|
|
193
|
+
======================================================
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
If specify ruby version `2.6.6` and `2.7.1`
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
/bin/bash devscript/all_support_ruby.sh bundle 2.6.6 2.7.1
|
|
200
|
+
.
|
|
201
|
+
.
|
|
202
|
+
.
|
|
203
|
+
===== Bundle install for All Support Ruby Result =====
|
|
204
|
+
ruby-2.6.6: 0
|
|
205
|
+
ruby-2.7.1: 0
|
|
206
|
+
======================================================
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
#### Rspec
|
|
210
|
+
|
|
211
|
+
```bash
|
|
212
|
+
/bin/bash devscript/all_support_ruby.sh rspec
|
|
213
|
+
.
|
|
214
|
+
.
|
|
215
|
+
.
|
|
216
|
+
===== Rspec for All Support Ruby Result =====
|
|
217
|
+
ruby-2.3.3: 0
|
|
218
|
+
ruby-2.4.2: 0
|
|
219
|
+
ruby-2.5.8: 0
|
|
220
|
+
ruby-2.6.6: 0
|
|
221
|
+
ruby-2.7.1: 0
|
|
222
|
+
=============================================
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
If specify ruby version `2.6.6` and `2.7.1`
|
|
226
|
+
|
|
227
|
+
```bash
|
|
228
|
+
/bin/bash devscript/all_support_ruby.sh rspec 2.6.6 2.7.1
|
|
229
|
+
.
|
|
230
|
+
.
|
|
231
|
+
.
|
|
232
|
+
===== Rspec for All Support Ruby Result =====
|
|
233
|
+
ruby-2.6.6: 0
|
|
234
|
+
ruby-2.7.1: 0
|
|
235
|
+
=============================================
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
## 🔩 CORS
|
|
239
|
+
|
|
240
|
+
Use [rack-cors](https://github.com/cyu/rack-cors) to enable CORS.
|
|
241
|
+
|
|
242
|
+
```ruby
|
|
243
|
+
require 'rack/cors'
|
|
244
|
+
use Rack::Cors do
|
|
245
|
+
allow do
|
|
246
|
+
origins '*'
|
|
247
|
+
resource '*', headers: :any, methods: [ :get, :post, :put, :delete, :options ]
|
|
248
|
+
end
|
|
249
|
+
end
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
Alternatively you can set CORS headers in a `before` block.
|
|
253
|
+
|
|
254
|
+
```ruby
|
|
255
|
+
before do
|
|
256
|
+
header['Access-Control-Allow-Origin'] = '*'
|
|
257
|
+
header['Access-Control-Request-Method'] = '*'
|
|
258
|
+
end
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## 📝 License
|
|
262
|
+
|
|
263
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
264
|
+
|
|
265
|
+
## 🤝 Contributing
|
|
266
|
+
|
|
267
|
+
1. Fork it ( http://github.com/yukihirop/r2-oas/fork )
|
|
268
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
269
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
270
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
271
|
+
5. Create new Pull Request
|