r2-oas 0.1.2 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +4 -0
- data/.rubocop.yml +6 -3
- data/.rubocop_todo.yml +68 -1
- data/.travis.yml +6 -2
- data/Appraisals +13 -0
- data/CHANGELOG.md +51 -0
- data/GEMSPEC.md +20 -0
- data/README.ja.md +71 -0
- data/README.md +70 -0
- data/lib/r2-oas.rb +3 -4
- data/lib/r2-oas/deploy/client.rb +33 -6
- data/lib/r2-oas/errors.rb +1 -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/schema/builder.rb +23 -0
- data/lib/r2-oas/schema/editor.rb +26 -7
- data/lib/r2-oas/schema/generator.rb +1 -1
- data/lib/r2-oas/schema/manager/file_manager.rb +26 -0
- data/lib/r2-oas/schema/ui.rb +0 -1
- data/lib/r2-oas/schema/v3/analyzer/base_analyzer.rb +1 -6
- data/lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/analyzer/path_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/analyzer/tag_analyzer.rb +1 -1
- data/lib/r2-oas/schema/v3/builder.rb +28 -0
- data/lib/r2-oas/schema/v3/builder/base_builder.rb +60 -0
- data/lib/r2-oas/schema/v3/builder/doc_builder.rb +43 -0
- data/lib/r2-oas/schema/v3/cleaner/base_cleaner.rb +1 -1
- data/lib/r2-oas/schema/v3/generator.rb +1 -5
- data/lib/r2-oas/schema/v3/generator/base_generator.rb +30 -1
- data/lib/r2-oas/schema/v3/generator/components/object_generator.rb +6 -25
- data/lib/r2-oas/schema/v3/generator/components/request_body_generator.rb +6 -6
- data/lib/r2-oas/schema/v3/generator/doc_generator.rb +84 -18
- data/lib/r2-oas/schema/v3/generator/path_generator.rb +7 -19
- data/lib/r2-oas/schema/v3/generator/schema_generator.rb +6 -26
- data/lib/r2-oas/schema/v3/manager/file/base_file_manager.rb +10 -4
- data/lib/r2-oas/schema/v3/manager/pathname_manager.rb +6 -1
- data/lib/r2-oas/store.rb +118 -0
- data/lib/r2-oas/task_logging.rb +6 -0
- data/lib/r2-oas/tasks/main.rake +66 -73
- data/lib/r2-oas/tasks/tool.rake +32 -28
- data/lib/r2-oas/tool/paths/ls.rb +1 -1
- data/lib/r2-oas/version.rb +1 -1
- data/r2-oas.gemspec +19 -10
- metadata +88 -60
- data/.github/ISSUE_TEMPLATE.md +0 -12
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
- data/Gemfile.lock +0 -222
- data/bin/console +0 -12
- data/bin/setup +0 -8
- data/docs/.nojekyll +0 -0
- data/docs/README.md +0 -326
- data/docs/_sidebar.md +0 -22
- data/docs/index.html +0 -28
- 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 -163
- 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 -256
- 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 -183
- data/docs/usage/use_tag_namespace.md +0 -182
- data/docs/usage/view_docs.md +0 -262
- 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/.github/ISSUE_TEMPLATE.md
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
### Summary
|
2
|
-
|
3
|
-
### Other Information
|
4
|
-
|
5
|
-
If there's anything else that's important and relevant to your pull
|
6
|
-
request, mention that information here. This could include
|
7
|
-
benchmarks, or other information.
|
8
|
-
|
9
|
-
If you are updating any of the CHANGELOG files or are asked to update the
|
10
|
-
CHANGELOG files by reviewers, please add the CHANGELOG entry at the top of the file.
|
11
|
-
|
12
|
-
Thanks for contributing to r2-oas!
|
data/Gemfile.lock
DELETED
@@ -1,222 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
r2-oas (0.1.2)
|
5
|
-
docker-api (~> 1.34.2)
|
6
|
-
easy_diff (~> 1.0.0)
|
7
|
-
eventmachine (~> 1.2.0)
|
8
|
-
paint
|
9
|
-
rails (>= 4.2.5)
|
10
|
-
terminal-table (~> 1.6.0)
|
11
|
-
watir (~> 6.0)
|
12
|
-
|
13
|
-
GEM
|
14
|
-
remote: https://rubygems.org/
|
15
|
-
specs:
|
16
|
-
actioncable (6.0.2.2)
|
17
|
-
actionpack (= 6.0.2.2)
|
18
|
-
nio4r (~> 2.0)
|
19
|
-
websocket-driver (>= 0.6.1)
|
20
|
-
actionmailbox (6.0.2.2)
|
21
|
-
actionpack (= 6.0.2.2)
|
22
|
-
activejob (= 6.0.2.2)
|
23
|
-
activerecord (= 6.0.2.2)
|
24
|
-
activestorage (= 6.0.2.2)
|
25
|
-
activesupport (= 6.0.2.2)
|
26
|
-
mail (>= 2.7.1)
|
27
|
-
actionmailer (6.0.2.2)
|
28
|
-
actionpack (= 6.0.2.2)
|
29
|
-
actionview (= 6.0.2.2)
|
30
|
-
activejob (= 6.0.2.2)
|
31
|
-
mail (~> 2.5, >= 2.5.4)
|
32
|
-
rails-dom-testing (~> 2.0)
|
33
|
-
actionpack (6.0.2.2)
|
34
|
-
actionview (= 6.0.2.2)
|
35
|
-
activesupport (= 6.0.2.2)
|
36
|
-
rack (~> 2.0, >= 2.0.8)
|
37
|
-
rack-test (>= 0.6.3)
|
38
|
-
rails-dom-testing (~> 2.0)
|
39
|
-
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
40
|
-
actiontext (6.0.2.2)
|
41
|
-
actionpack (= 6.0.2.2)
|
42
|
-
activerecord (= 6.0.2.2)
|
43
|
-
activestorage (= 6.0.2.2)
|
44
|
-
activesupport (= 6.0.2.2)
|
45
|
-
nokogiri (>= 1.8.5)
|
46
|
-
actionview (6.0.2.2)
|
47
|
-
activesupport (= 6.0.2.2)
|
48
|
-
builder (~> 3.1)
|
49
|
-
erubi (~> 1.4)
|
50
|
-
rails-dom-testing (~> 2.0)
|
51
|
-
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
52
|
-
activejob (6.0.2.2)
|
53
|
-
activesupport (= 6.0.2.2)
|
54
|
-
globalid (>= 0.3.6)
|
55
|
-
activemodel (6.0.2.2)
|
56
|
-
activesupport (= 6.0.2.2)
|
57
|
-
activerecord (6.0.2.2)
|
58
|
-
activemodel (= 6.0.2.2)
|
59
|
-
activesupport (= 6.0.2.2)
|
60
|
-
activestorage (6.0.2.2)
|
61
|
-
actionpack (= 6.0.2.2)
|
62
|
-
activejob (= 6.0.2.2)
|
63
|
-
activerecord (= 6.0.2.2)
|
64
|
-
marcel (~> 0.3.1)
|
65
|
-
activesupport (6.0.2.2)
|
66
|
-
concurrent-ruby (~> 1.0, >= 1.0.2)
|
67
|
-
i18n (>= 0.7, < 2)
|
68
|
-
minitest (~> 5.1)
|
69
|
-
tzinfo (~> 1.1)
|
70
|
-
zeitwerk (~> 2.2)
|
71
|
-
ast (2.4.0)
|
72
|
-
builder (3.2.4)
|
73
|
-
childprocess (3.0.0)
|
74
|
-
coderay (1.1.2)
|
75
|
-
concurrent-ruby (1.1.6)
|
76
|
-
coveralls (0.8.23)
|
77
|
-
json (>= 1.8, < 3)
|
78
|
-
simplecov (~> 0.16.1)
|
79
|
-
term-ansicolor (~> 1.3)
|
80
|
-
thor (>= 0.19.4, < 2.0)
|
81
|
-
tins (~> 1.6)
|
82
|
-
crass (1.0.6)
|
83
|
-
diff-lcs (1.3)
|
84
|
-
docile (1.3.2)
|
85
|
-
docker-api (1.34.2)
|
86
|
-
excon (>= 0.47.0)
|
87
|
-
multi_json
|
88
|
-
easy_diff (1.0.0)
|
89
|
-
erubi (1.9.0)
|
90
|
-
eventmachine (1.2.7)
|
91
|
-
excon (0.73.0)
|
92
|
-
globalid (0.4.2)
|
93
|
-
activesupport (>= 4.2.0)
|
94
|
-
i18n (1.8.2)
|
95
|
-
concurrent-ruby (~> 1.0)
|
96
|
-
jaro_winkler (1.5.3)
|
97
|
-
json (2.2.0)
|
98
|
-
loofah (2.5.0)
|
99
|
-
crass (~> 1.0.2)
|
100
|
-
nokogiri (>= 1.5.9)
|
101
|
-
mail (2.7.1)
|
102
|
-
mini_mime (>= 0.1.1)
|
103
|
-
marcel (0.3.3)
|
104
|
-
mimemagic (~> 0.3.2)
|
105
|
-
method_source (0.9.2)
|
106
|
-
mimemagic (0.3.4)
|
107
|
-
mini_mime (1.0.2)
|
108
|
-
mini_portile2 (2.4.0)
|
109
|
-
minitest (5.14.0)
|
110
|
-
multi_json (1.14.1)
|
111
|
-
nio4r (2.5.2)
|
112
|
-
nokogiri (1.10.9)
|
113
|
-
mini_portile2 (~> 2.4.0)
|
114
|
-
paint (2.2.0)
|
115
|
-
parallel (1.17.0)
|
116
|
-
parser (2.6.3.0)
|
117
|
-
ast (~> 2.4.0)
|
118
|
-
pry (0.12.2)
|
119
|
-
coderay (~> 1.1.0)
|
120
|
-
method_source (~> 0.9.0)
|
121
|
-
rack (2.2.2)
|
122
|
-
rack-test (1.1.0)
|
123
|
-
rack (>= 1.0, < 3)
|
124
|
-
rails (6.0.2.2)
|
125
|
-
actioncable (= 6.0.2.2)
|
126
|
-
actionmailbox (= 6.0.2.2)
|
127
|
-
actionmailer (= 6.0.2.2)
|
128
|
-
actionpack (= 6.0.2.2)
|
129
|
-
actiontext (= 6.0.2.2)
|
130
|
-
actionview (= 6.0.2.2)
|
131
|
-
activejob (= 6.0.2.2)
|
132
|
-
activemodel (= 6.0.2.2)
|
133
|
-
activerecord (= 6.0.2.2)
|
134
|
-
activestorage (= 6.0.2.2)
|
135
|
-
activesupport (= 6.0.2.2)
|
136
|
-
bundler (>= 1.3.0)
|
137
|
-
railties (= 6.0.2.2)
|
138
|
-
sprockets-rails (>= 2.0.0)
|
139
|
-
rails-dom-testing (2.0.3)
|
140
|
-
activesupport (>= 4.2.0)
|
141
|
-
nokogiri (>= 1.6)
|
142
|
-
rails-html-sanitizer (1.3.0)
|
143
|
-
loofah (~> 2.3)
|
144
|
-
railties (6.0.2.2)
|
145
|
-
actionpack (= 6.0.2.2)
|
146
|
-
activesupport (= 6.0.2.2)
|
147
|
-
method_source
|
148
|
-
rake (>= 0.8.7)
|
149
|
-
thor (>= 0.20.3, < 2.0)
|
150
|
-
rainbow (3.0.0)
|
151
|
-
rake (13.0.1)
|
152
|
-
regexp_parser (1.7.0)
|
153
|
-
rspec (3.8.0)
|
154
|
-
rspec-core (~> 3.8.0)
|
155
|
-
rspec-expectations (~> 3.8.0)
|
156
|
-
rspec-mocks (~> 3.8.0)
|
157
|
-
rspec-core (3.8.0)
|
158
|
-
rspec-support (~> 3.8.0)
|
159
|
-
rspec-expectations (3.8.2)
|
160
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
161
|
-
rspec-support (~> 3.8.0)
|
162
|
-
rspec-mocks (3.8.0)
|
163
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
164
|
-
rspec-support (~> 3.8.0)
|
165
|
-
rspec-support (3.8.0)
|
166
|
-
rubocop (0.72.0)
|
167
|
-
jaro_winkler (~> 1.5.1)
|
168
|
-
parallel (~> 1.10)
|
169
|
-
parser (>= 2.6)
|
170
|
-
rainbow (>= 2.2.2, < 4.0)
|
171
|
-
ruby-progressbar (~> 1.7)
|
172
|
-
unicode-display_width (>= 1.4.0, < 1.7)
|
173
|
-
ruby-progressbar (1.10.1)
|
174
|
-
rubyzip (2.3.0)
|
175
|
-
selenium-webdriver (3.142.7)
|
176
|
-
childprocess (>= 0.5, < 4.0)
|
177
|
-
rubyzip (>= 1.2.2)
|
178
|
-
simplecov (0.16.1)
|
179
|
-
docile (~> 1.1)
|
180
|
-
json (>= 1.8, < 3)
|
181
|
-
simplecov-html (~> 0.10.0)
|
182
|
-
simplecov-html (0.10.2)
|
183
|
-
sprockets (4.0.0)
|
184
|
-
concurrent-ruby (~> 1.0)
|
185
|
-
rack (> 1, < 3)
|
186
|
-
sprockets-rails (3.2.1)
|
187
|
-
actionpack (>= 4.0)
|
188
|
-
activesupport (>= 4.0)
|
189
|
-
sprockets (>= 3.0.0)
|
190
|
-
sqlite3 (1.4.1)
|
191
|
-
term-ansicolor (1.7.1)
|
192
|
-
tins (~> 1.0)
|
193
|
-
terminal-table (1.6.0)
|
194
|
-
thor (1.0.1)
|
195
|
-
thread_safe (0.3.6)
|
196
|
-
tins (1.21.1)
|
197
|
-
tzinfo (1.2.7)
|
198
|
-
thread_safe (~> 0.1)
|
199
|
-
unicode-display_width (1.6.0)
|
200
|
-
watir (6.16.5)
|
201
|
-
regexp_parser (~> 1.2)
|
202
|
-
selenium-webdriver (~> 3.6)
|
203
|
-
websocket-driver (0.7.1)
|
204
|
-
websocket-extensions (>= 0.1.0)
|
205
|
-
websocket-extensions (0.1.4)
|
206
|
-
zeitwerk (2.3.0)
|
207
|
-
|
208
|
-
PLATFORMS
|
209
|
-
ruby
|
210
|
-
|
211
|
-
DEPENDENCIES
|
212
|
-
bundler (~> 1.17)
|
213
|
-
coveralls
|
214
|
-
pry
|
215
|
-
r2-oas!
|
216
|
-
rake (~> 13.0)
|
217
|
-
rspec (~> 3.0)
|
218
|
-
rubocop
|
219
|
-
sqlite3
|
220
|
-
|
221
|
-
BUNDLED WITH
|
222
|
-
1.17.3
|
data/bin/console
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
require 'bundler/setup'
|
5
|
-
require 'r2-oas'
|
6
|
-
|
7
|
-
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
-
# with your gem easier. You can also use a different console, if you like.
|
9
|
-
|
10
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
-
require 'pry'
|
12
|
-
Pry.start
|
data/bin/setup
DELETED
data/docs/.nojekyll
DELETED
File without changes
|
data/docs/README.md
DELETED
@@ -1,326 +0,0 @@
|
|
1
|
-
# R2-OAS
|
2
|
-
|
3
|
-
[![Build Status](https://travis-ci.org/yukihirop/r2-oas.svg?branch=master)](https://travis-ci.org/yukihirop/r2-oas)
|
4
|
-
[![Coverage Status](https://coveralls.io/repos/github/yukihirop/r2-oas/badge.svg)](https://coveralls.io/github/yukihirop/r2-oas)
|
5
|
-
[![Maintainability](https://api.codeclimate.com/v1/badges/f8c3846f350bb412fd63/maintainability)](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
|
6
|
-
|
7
|
-
Generate api docment(OpenAPI) side only from `Rails` routing.
|
8
|
-
|
9
|
-
Provides a rake command to help `generate` , `view` , and `edit` OpenAPI documents.
|
10
|
-
|
11
|
-
```bash
|
12
|
-
bundle exec rake routes:oas:docs # generate
|
13
|
-
bundle exec rake routes:oas:ui # view
|
14
|
-
bundle exec rake routes:oas:editor # edit
|
15
|
-
bundle exec rake routes:oas:monitor # monitor
|
16
|
-
bundle exec rake routes:oas:dist # distribute
|
17
|
-
bundle exec rake routes:oas:clean # clean
|
18
|
-
bundle exec rake routes:oas:analyze # analyze
|
19
|
-
bundle exec rake routes:oas:deploy # deploy
|
20
|
-
```
|
21
|
-
|
22
|
-
## 💎 Installation
|
23
|
-
|
24
|
-
Add this line to your application's Gemfile:
|
25
|
-
|
26
|
-
```ruby
|
27
|
-
group :development do
|
28
|
-
gem 'r2-oas'
|
29
|
-
end
|
30
|
-
```
|
31
|
-
|
32
|
-
And then execute:
|
33
|
-
|
34
|
-
$ bundle
|
35
|
-
|
36
|
-
Or install it yourself as:
|
37
|
-
|
38
|
-
$ gem install r2-oas
|
39
|
-
|
40
|
-
## 🔦 Requirements
|
41
|
-
|
42
|
-
If you want to view with `Swagger UI` or edit with `Swagger Editor`, This gem needs the following:
|
43
|
-
|
44
|
-
- [`swaggerapi/swagger-ui:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-ui/)
|
45
|
-
- [`swaggerapi/swagger-editor:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-editor/)
|
46
|
-
- [`chromedriver`](http://chromedriver.chromium.org/downloads)
|
47
|
-
|
48
|
-
If you do not have it download as below.
|
49
|
-
|
50
|
-
```
|
51
|
-
$ docker pull swaggerapi/swagger-editor:latest
|
52
|
-
$ docker pull swaggerapi/swagger-ui:latest
|
53
|
-
$ brew cask install chromedriver
|
54
|
-
```
|
55
|
-
|
56
|
-
## 🚀 Tutorial
|
57
|
-
|
58
|
-
After requiring a gem,
|
59
|
-
|
60
|
-
```bash
|
61
|
-
bundle exec routes:oas:docs
|
62
|
-
bundle exec routes:oas:editor
|
63
|
-
```
|
64
|
-
|
65
|
-
## 📖 Usage
|
66
|
-
|
67
|
-
All settings are optional. The initial value is as follows.
|
68
|
-
|
69
|
-
In your rails project, Write `config/environments/development.rb` like that:
|
70
|
-
|
71
|
-
```ruby
|
72
|
-
# default setting
|
73
|
-
R2OAS.configure do |config|
|
74
|
-
config.version = :v3
|
75
|
-
config.root_dir_path = "./oas_docs"
|
76
|
-
config.schema_save_dir_name = "src"
|
77
|
-
config.doc_save_file_name = "oas_doc.yml"
|
78
|
-
config.force_update_schema = false
|
79
|
-
config.use_tag_namespace = true
|
80
|
-
config.use_schema_namespace = false
|
81
|
-
config.interval_to_save_edited_tmp_schema = 15
|
82
|
-
# :dot or :underbar
|
83
|
-
config.namespace_type = :underbar
|
84
|
-
config.deploy_dir_path = "./deploy_docs"
|
85
|
-
|
86
|
-
config.server.data = [
|
87
|
-
{
|
88
|
-
url: "http://localhost:3000",
|
89
|
-
description: "localhost"
|
90
|
-
}
|
91
|
-
]
|
92
|
-
|
93
|
-
config.swagger.configure do |swagger|
|
94
|
-
swagger.ui.image = "swaggerapi/swagger-ui"
|
95
|
-
swagger.ui.port = "8080"
|
96
|
-
swagger.ui.exposed_port = "8080/tcp"
|
97
|
-
swagger.ui.volume = "/app/swagger.json"
|
98
|
-
swagger.editor.image = "swaggerapi/swagger-editor"
|
99
|
-
swagger.editor.port = "81"
|
100
|
-
swagger.editor.exposed_port = "8080/tcp"
|
101
|
-
end
|
102
|
-
|
103
|
-
config.use_object_classes = {
|
104
|
-
info_object: R2OAS::Schema::V3::InfoObject,
|
105
|
-
paths_object: R2OAS::Schema::V3::PathsObject,
|
106
|
-
path_item_object: R2OAS::Schema::V3::PathItemObject,
|
107
|
-
external_document_object: R2OAS::Schema::V3::ExternalDocumentObject,
|
108
|
-
components_object: R2OAS::Schema::V3::ComponentsObject,
|
109
|
-
components_schema_object: R2OAS::Schema::V3::Components::SchemaObject,
|
110
|
-
components_request_body_object: R2OAS::Schema::V3::Components::RequestBodyObject
|
111
|
-
}
|
112
|
-
|
113
|
-
config.http_statuses_when_http_method = {
|
114
|
-
get: {
|
115
|
-
default: %w(200 422),
|
116
|
-
path_parameter: %w(200 404 422)
|
117
|
-
},
|
118
|
-
post: {
|
119
|
-
default: %w(201 422),
|
120
|
-
path_parameter: %w(201 404 422)
|
121
|
-
},
|
122
|
-
patch: {
|
123
|
-
default: %w(204 422),
|
124
|
-
path_parameter: %w(204 404 422)
|
125
|
-
},
|
126
|
-
put: {
|
127
|
-
default: %w(204 422),
|
128
|
-
path_parameter: %w(204 404 422)
|
129
|
-
},
|
130
|
-
delete: {
|
131
|
-
default: %w(200 422),
|
132
|
-
path_parameter: %w(200 404 422)
|
133
|
-
}
|
134
|
-
}
|
135
|
-
|
136
|
-
config.http_methods_when_generate_request_body = %w[post patch put]
|
137
|
-
config.ignored_http_statuses_when_generate_component_schema = %w[204 404]
|
138
|
-
|
139
|
-
config.tool.paths_stats.configure do |paths_stats|
|
140
|
-
paths_stats.month_to_turn_to_warning_color = 3
|
141
|
-
paths_stats.warning_color = :red
|
142
|
-
paths_stats.table_title_color = :yellow
|
143
|
-
paths_stats.heading_color = :yellow
|
144
|
-
paths_stats.highlight_color = :magenta
|
145
|
-
end
|
146
|
-
end
|
147
|
-
```
|
148
|
-
|
149
|
-
You can execute the following command in the root directory of rails.
|
150
|
-
|
151
|
-
```bash
|
152
|
-
$ # Generate docs
|
153
|
-
$ bundle exec rake routes:oas:docs # Generate docs
|
154
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:docs # Generate docs by specify unit paths
|
155
|
-
|
156
|
-
$ # Start swagger editor
|
157
|
-
$ bundle exec rake routes:oas:editor # Start swagger editor
|
158
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:editor # Start swagger editor by specify unit paths
|
159
|
-
$ # Start swagger ui
|
160
|
-
$ bundle exec rake routes:oas:ui # Start swagger ui
|
161
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:ui # Start swagger ui by specify unit paths
|
162
|
-
$ # Monitor swagger document
|
163
|
-
$ bundle exec rake routes:oas:monitor # Monitor swagger document
|
164
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:monitor # Monitor swagger by specify unit paths
|
165
|
-
|
166
|
-
$ # Analyze docs
|
167
|
-
$ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
|
168
|
-
$ # Clean docs
|
169
|
-
$ bundle exec rake routes:oas:clean
|
170
|
-
$ # Deploy docs
|
171
|
-
$ bundle exec rake routes:oas:deploy
|
172
|
-
$ # Distribute swagger document
|
173
|
-
$ bundle exec rake routes:oas:dist
|
174
|
-
$ # Distribute swagger document
|
175
|
-
$ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:dist # Distribute swagger document by specify unit paths
|
176
|
-
|
177
|
-
# Display paths list
|
178
|
-
$ bundle exec rake routes:oas:paths_ls
|
179
|
-
# Display paths stats
|
180
|
-
$ bundle exec rake routes:oas:paths_stats
|
181
|
-
```
|
182
|
-
|
183
|
-
## ❤️ Support Rails Version
|
184
|
-
|
185
|
-
- Rails (>= 4.2.5.1)
|
186
|
-
|
187
|
-
## ❤️ Support Ruby Version
|
188
|
-
|
189
|
-
- Ruby (>= 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin18])
|
190
|
-
|
191
|
-
## ❤️ Support Rouging
|
192
|
-
|
193
|
-
- Rails Engine Routing
|
194
|
-
- Rails Normal Routing
|
195
|
-
|
196
|
-
## ❗️ Convention over Configuration (CoC)
|
197
|
-
|
198
|
-
- `tag name` represents `controller name` and determine `paths file name`.
|
199
|
-
- For example, If `controller name` is `Api::V1::UsersController`, `tag_name` is `api/v1/user`. and `paths file name` is `api/v1/user.yml`
|
200
|
-
|
201
|
-
- `_` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
|
202
|
-
- For example, If `components/schemas name` is `Api_V1_User`, `components/schemas file name` is `api/v1/user.yml`.
|
203
|
-
- `_` is supposed to be used to express `namespace`.
|
204
|
-
- format is `Namespace1_Namespace2_Model`.
|
205
|
-
|
206
|
-
- `.` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
|
207
|
-
- For example, If `components/schemas name` is `api.v1.User`, `components/schemas file name` is `api/v1/user.yml`.
|
208
|
-
- `.` is supposed to be used to express `namespace`.
|
209
|
-
- format is `namespace1.namespace2.Model`.
|
210
|
-
|
211
|
-
## ⚙ Configure
|
212
|
-
|
213
|
-
we explain the options that can be set.
|
214
|
-
|
215
|
-
#### basic
|
216
|
-
|
217
|
-
|option|description|default|
|
218
|
-
|------|-----------|---|
|
219
|
-
|version|OpenAPI schema version| `:v3` |
|
220
|
-
|root_dir_path|Root directory for storing products.| `"./oas_docs"` |
|
221
|
-
|schema_save_dir_name|Directory name for storing swagger schemas|`"src"`|
|
222
|
-
|doc_save_file_name|File name for storing swagger doc|`"oas_doc.yml"`|
|
223
|
-
|force_update_schema|Force update schema from routes data|`false`|
|
224
|
-
|use_tag_namespace|Use namespace for tag name|`true`|
|
225
|
-
|use_schema_namespace|Use namespace for schema name|`true`|
|
226
|
-
|interval_to_save_edited_tmp_schema|Interval(sec) to save edited tmp schema|`15`|
|
227
|
-
|http_statuses_when_http_method|Determine the response to support for each HTTP method|omission...|
|
228
|
-
|http_methods_when_generate_request_body|HTTP methods when generate requestBody|`[post put patch]`|
|
229
|
-
|ignored_http_statuses_when_generate_component_schema|Ignore HTTP statuses when generate component schema|`[204 404]`|
|
230
|
-
|namespace_type|namespace for components(schemas/requestBodies) name| `underbar` |
|
231
|
-
|deploy_dir_path|deploy directory.|`"./deploy_docs"`|
|
232
|
-
|
233
|
-
#### server
|
234
|
-
|
235
|
-
|option|children option|description|default|
|
236
|
-
|------|---------------|-----------|-------|
|
237
|
-
|server|data|Server data (url, description) |[{ url: `http://localhost:3000`, description: `localhost` }] |
|
238
|
-
|
239
|
-
#### swagger
|
240
|
-
|
241
|
-
|option|children option|grandchild option|description|default|
|
242
|
-
|------|---------------|-----------------|-----------|-------|
|
243
|
-
|swagger|ui|image|Swagger UI Docker Image|`"swaggerapi/swagger-ui"`|
|
244
|
-
|swagger|ui|port|Swagger UI Port|`"8080"`|
|
245
|
-
|swagger|ui|exposed_port|Swagger UI Exposed Port|`"8080/tcp"`|
|
246
|
-
|swagger|ui|volume|Swagger UI Volume|`"/app/swagger.json"`|
|
247
|
-
|swagger|editor|image|Swagger Editor Docker Image|`"swaggerapi/swagger-editor"`|
|
248
|
-
|swagger|editor|port|Swagger Editor Port|`"8080"`|
|
249
|
-
|swagger|editor|exposed_port|Swagger Editor Exposed Port|`"8080/tcp"`|
|
250
|
-
|
251
|
-
#### hook
|
252
|
-
|
253
|
-
|option|description|default|
|
254
|
-
|------|-----------|-------|
|
255
|
-
|use_object_classes|Object class(hook class) to generate Openapi document|{ info_object: `R2OAS::Schema::V3::InfoObject`,<br>paths_object: `R2OAS::Schema::V3::PathsObject`,<br>path_item_object: `R2OAS::Schema::V3::PathItemObject`, external_document_object: `R2OAS::Schema::V3::ExternalDocumentObject`,<br> components_object: `R2OAS::Schema::V3::ComponentsObject`,<br> components_schema_object: `R2OAS::Schema::V3::Components::SchemaObject`, <br> components_request_body_object:`R2OAS::Schema::V3::Components::RequestBodyObject` }|
|
256
|
-
|
257
|
-
#### tool
|
258
|
-
|
259
|
-
|option|children option|grandchild option|description|default|
|
260
|
-
|------|---------------|-----------------|-----------|-------|
|
261
|
-
|tool|paths_stats|month_to_turn_to_warning_color|Elapsed month to issue a warning|`3`|
|
262
|
-
|tool|paths_stats|warning_color|Warning Color|`:red`|
|
263
|
-
|tool|paths_stats|table_title_color|Table Title Color|`:yellow`|
|
264
|
-
|tool|paths_stats|heading_color|Heading Color|`:yellow`|
|
265
|
-
|tool|paths_stats|highlight_color|Highlight Color|`:magenta`|
|
266
|
-
|
267
|
-
Please refer to [here](https://github.com/janlelis/paint) for the color.
|
268
|
-
|
269
|
-
## Environment variables
|
270
|
-
|
271
|
-
We explain the environment variables that can be set.
|
272
|
-
|
273
|
-
|variable|description|default|
|
274
|
-
|--------|-----------|-------|
|
275
|
-
|PATHS_FILE|Specify one paths file path|`""`|
|
276
|
-
|OAS_FILE|Specify swagger file path to analyze|`""`|
|
277
|
-
|
278
|
-
|
279
|
-
## .paths
|
280
|
-
|
281
|
-
Writing file paths in .paths will only read them.
|
282
|
-
You can comment out with `#`
|
283
|
-
|
284
|
-
`oas_docs/.paths`
|
285
|
-
|
286
|
-
```
|
287
|
-
#account_user_role.yml # ignore
|
288
|
-
account.yml
|
289
|
-
account.yml # ignore
|
290
|
-
account.yml # ignore
|
291
|
-
```
|
292
|
-
|
293
|
-
## 🔩 CORS
|
294
|
-
|
295
|
-
Use [rack-cors](https://github.com/cyu/rack-cors) to enable CORS.
|
296
|
-
|
297
|
-
```ruby
|
298
|
-
require 'rack/cors'
|
299
|
-
use Rack::Cors do
|
300
|
-
allow do
|
301
|
-
origins '*'
|
302
|
-
resource '*', headers: :any, methods: [ :get, :post, :put, :delete, :options ]
|
303
|
-
end
|
304
|
-
end
|
305
|
-
```
|
306
|
-
|
307
|
-
Alternatively you can set CORS headers in a `before` block.
|
308
|
-
|
309
|
-
```ruby
|
310
|
-
before do
|
311
|
-
header['Access-Control-Allow-Origin'] = '*'
|
312
|
-
header['Access-Control-Request-Method'] = '*'
|
313
|
-
end
|
314
|
-
```
|
315
|
-
|
316
|
-
## 📝 License
|
317
|
-
|
318
|
-
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
319
|
-
|
320
|
-
## 🤝 Contributing
|
321
|
-
|
322
|
-
1. Fork it ( http://github.com/yukihirop/r2-oas/fork )
|
323
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
324
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
325
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
326
|
-
5. Create new Pull Request
|