r2-oas 0.1.3 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +49 -0
- data/GEMSPEC.md +20 -0
- data/README.ja.md +63 -2
- data/README.md +62 -2
- data/lib/r2-oas.rb +3 -4
- data/lib/r2-oas/app_configuration.rb +1 -1
- 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 +13 -2
- 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/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/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 -19
- data/lib/r2-oas/schema/v3/generator/path_generator.rb +7 -19
- data/lib/r2-oas/schema/v3/generator/schema_generator.rb +5 -25
- data/lib/r2-oas/schema/v3/manager/file/base_file_manager.rb +3 -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 -4
- data/lib/r2-oas/tasks/common.rake +0 -1
- data/lib/r2-oas/tasks/main.rake +66 -73
- data/lib/r2-oas/tasks/tool.rake +32 -28
- data/lib/r2-oas/version.rb +1 -1
- metadata +85 -69
- data/.github/ISSUE_TEMPLATE.md +0 -12
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
- data/.gitignore +0 -12
- data/.rspec +0 -3
- data/.rubocop.yml +0 -7
- data/.rubocop_todo.yml +0 -228
- data/.travis.yml +0 -22
- data/CODE_OF_CONDUCT.md +0 -74
- data/Gemfile +0 -12
- data/Gemfile.lock +0 -222
- data/Rakefile +0 -8
- data/bin/console +0 -12
- data/bin/setup +0 -8
- data/docs/.nojekyll +0 -0
- data/docs/README.md +0 -173
- data/docs/_sidebar.md +0 -23
- data/docs/attention/if_clash.md +0 -19
- 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/r2-oas.gemspec +0 -42
@@ -1,235 +0,0 @@
|
|
1
|
-
## Use hook to generate docs
|
2
|
-
|
3
|
-
## Prepare
|
4
|
-
|
5
|
-
prepare a file like `custom_path_item_object.rb`
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
class CustomPathItemObject < R2OAS::Schema::V3::PathItemObject
|
9
|
-
|
10
|
-
# [Important] Please change doc destructively.
|
11
|
-
before_create do |doc, path|
|
12
|
-
# [Important] To be able to use methods in Rails !
|
13
|
-
#
|
14
|
-
# doc is {}.
|
15
|
-
doc.merge!({
|
16
|
-
})
|
17
|
-
end
|
18
|
-
|
19
|
-
# [Important] Please change doc destructively.
|
20
|
-
after_create do |doc, path|
|
21
|
-
# [Important] To be able to use methods in Rails !
|
22
|
-
|
23
|
-
# For example, doc (style is yaml) is like that:
|
24
|
-
# get:
|
25
|
-
# tags:
|
26
|
-
# - api/v1/post
|
27
|
-
# summary: get summary
|
28
|
-
# description: get description
|
29
|
-
# responses:
|
30
|
-
# default:
|
31
|
-
# description: ''
|
32
|
-
# '200':
|
33
|
-
# description: api/v1/post description
|
34
|
-
# content:
|
35
|
-
# application/json:
|
36
|
-
# schema:
|
37
|
-
# "$ref": "#/components/schemas/Post"
|
38
|
-
# deprecated: false
|
39
|
-
#
|
40
|
-
|
41
|
-
# If you want to merge `sort` query parameters when request is GET api/v1/post.
|
42
|
-
if doc['get'].present? && path == 'api/v1/post'
|
43
|
-
doc['get'].merge!({
|
44
|
-
'parameters' => {
|
45
|
-
'name' => 'sort',
|
46
|
-
'in' => 'query',
|
47
|
-
'description' => 'option to sort posts',
|
48
|
-
'required' => false,
|
49
|
-
'deprecated' => false
|
50
|
-
}
|
51
|
-
})
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
```
|
56
|
-
|
57
|
-
```ruby
|
58
|
-
require_relative 'custom_path_item_object'
|
59
|
-
|
60
|
-
R2OAS.configure do |config|
|
61
|
-
config.use_object_classes.merge!({
|
62
|
-
path_item_object: CustomPathItemObject
|
63
|
-
})
|
64
|
-
end
|
65
|
-
```
|
66
|
-
|
67
|
-
## Command
|
68
|
-
|
69
|
-
```bash
|
70
|
-
$ bundle exec rake routes:oas:docs
|
71
|
-
```
|
72
|
-
|
73
|
-
## Example
|
74
|
-
|
75
|
-
if there is routing like this:
|
76
|
-
|
77
|
-
```
|
78
|
-
$ bundle exec rake routes
|
79
|
-
Prefix Verb URI Pattern Controller#Action
|
80
|
-
rails_admin /admin RailsAdmin::Engine
|
81
|
-
api_v2_posts GET /api/v2/posts(.:format) api/v2/posts#index {:format=>:json}
|
82
|
-
POST /api/v2/posts(.:format) api/v2/posts#create {:format=>:json}
|
83
|
-
new_api_v2_post GET /api/v2/posts/new(.:format) api/v2/posts#new {:format=>:json}
|
84
|
-
edit_api_v2_post GET /api/v2/posts/:id/edit(.:format) api/v2/posts#edit {:format=>:json}
|
85
|
-
api_v2_post GET /api/v2/posts/:id(.:format) api/v2/posts#show {:format=>:json}
|
86
|
-
PATCH /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
|
87
|
-
PUT /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
|
88
|
-
DELETE /api/v2/posts/:id(.:format) api/v2/posts#destroy {:format=>:json}
|
89
|
-
api_v1_posts GET /api/v1/posts(.:format) api/v1/posts#index
|
90
|
-
POST /api/v1/posts(.:format) api/v1/posts#create
|
91
|
-
new_api_v1_post GET /api/v1/posts/new(.:format) api/v1/posts#new
|
92
|
-
edit_api_v1_post GET /api/v1/posts/:id/edit(.:format) api/v1/posts#edit
|
93
|
-
api_v1_post GET /api/v1/posts/:id(.:format) api/v1/posts#show
|
94
|
-
PATCH /api/v1/posts/:id(.:format) api/v1/posts#update
|
95
|
-
PUT /api/v1/posts/:id(.:format) api/v1/posts#update
|
96
|
-
DELETE /api/v1/posts/:id(.:format) api/v1/posts#destroy
|
97
|
-
api_v1_tasks GET /api/v1/tasks(.:format) api/v1/tasks#index
|
98
|
-
POST /api/v1/tasks(.:format) api/v1/tasks#create
|
99
|
-
new_api_v1_task GET /api/v1/tasks/new(.:format) api/v1/tasks#new
|
100
|
-
edit_api_v1_task GET /api/v1/tasks/:id/edit(.:format) api/v1/tasks#edit
|
101
|
-
api_v1_task GET /api/v1/tasks/:id(.:format) api/v1/tasks#show
|
102
|
-
PATCH /api/v1/tasks/:id(.:format) api/v1/tasks#update
|
103
|
-
PUT /api/v1/tasks/:id(.:format) api/v1/tasks#update
|
104
|
-
DELETE /api/v1/tasks/:id(.:format) api/v1/tasks#destroy
|
105
|
-
tasks GET /tasks(.:format) tasks#index
|
106
|
-
POST /tasks(.:format) tasks#create
|
107
|
-
new_task GET /tasks/new(.:format) tasks#new
|
108
|
-
edit_task GET /tasks/:id/edit(.:format) tasks#edit
|
109
|
-
task GET /tasks/:id(.:format) tasks#show
|
110
|
-
PATCH /tasks/:id(.:format) tasks#update
|
111
|
-
PUT /tasks/:id(.:format) tasks#update
|
112
|
-
DELETE /tasks/:id(.:format) tasks#destroy
|
113
|
-
users GET /users(.:format) users#index
|
114
|
-
POST /users(.:format) users#create
|
115
|
-
new_user GET /users/new(.:format) users#new
|
116
|
-
edit_user GET /users/:id/edit(.:format) users#edit
|
117
|
-
user GET /users/:id(.:format) users#show
|
118
|
-
PATCH /users/:id(.:format) users#update
|
119
|
-
PUT /users/:id(.:format) users#update
|
120
|
-
DELETE /users/:id(.:format) users#destroy
|
121
|
-
|
122
|
-
Routes for RailsAdmin::Engine:
|
123
|
-
dashboard GET / rails_admin/main#dashboard
|
124
|
-
index GET|POST /:model_name(.:format) rails_admin/main#index
|
125
|
-
new GET|POST /:model_name/new(.:format) rails_admin/main#new
|
126
|
-
export GET|POST /:model_name/export(.:format) rails_admin/main#export
|
127
|
-
bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
|
128
|
-
bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
|
129
|
-
show GET /:model_name/:id(.:format) rails_admin/main#show
|
130
|
-
edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
|
131
|
-
delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
|
132
|
-
show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
|
133
|
-
```
|
134
|
-
|
135
|
-
#### First try
|
136
|
-
|
137
|
-
```
|
138
|
-
$ bundle exec rake routes:oas:docs
|
139
|
-
I, [2019-06-02T22:12:41.530676 #61323] INFO -- : [R2-OAS] start
|
140
|
-
I, [2019-06-02T22:12:41.609492 #61323] INFO -- : [Generate Swagger schema files] start
|
141
|
-
I, [2019-06-02T22:12:41.609574 #61323] INFO -- : <From routes data>
|
142
|
-
I, [2019-06-02T22:12:41.609591 #61323] INFO -- : <Update schema files>
|
143
|
-
I, [2019-06-02T22:12:41.611183 #61323] INFO -- : Write schema file: oas_docs/src/openapi.yml
|
144
|
-
I, [2019-06-02T22:12:41.611676 #61323] INFO -- : Write schema file: oas_docs/src/info.yml
|
145
|
-
I, [2019-06-02T22:12:41.612596 #61323] INFO -- : Write schema file: oas_docs/src/tags.yml
|
146
|
-
I, [2019-06-02T22:12:41.612619 #61323] INFO -- : [Generate Swagger schema files (paths)] start
|
147
|
-
I, [2019-06-02T22:12:41.612765 #61323] INFO -- : <From routes data>
|
148
|
-
I, [2019-06-02T22:12:41.612782 #61323] INFO -- : <Update schema files (paths)>
|
149
|
-
I, [2019-06-02T22:12:41.614701 #61323] INFO -- : Write schema file: oas_docs/src/paths/rails_admin/engine.yml
|
150
|
-
I, [2019-06-02T22:12:41.618979 #61323] INFO -- : Write schema file: oas_docs/src/paths/api/v2/post.yml
|
151
|
-
I, [2019-06-02T22:12:41.623081 #61323] INFO -- : Write schema file: oas_docs/src/paths/api/v1/post.yml
|
152
|
-
I, [2019-06-02T22:12:41.630184 #61323] INFO -- : Write schema file: oas_docs/src/paths/api/v1/task.yml
|
153
|
-
I, [2019-06-02T22:12:41.633369 #61323] INFO -- : Write schema file: oas_docs/src/paths/task.yml
|
154
|
-
I, [2019-06-02T22:12:41.636323 #61323] INFO -- : Write schema file: oas_docs/src/paths/user.yml
|
155
|
-
I, [2019-06-02T22:12:41.642353 #61323] INFO -- : Write schema file: oas_docs/src/paths/rails_admin/main.yml
|
156
|
-
I, [2019-06-02T22:12:41.642381 #61323] INFO -- : [Generate Swagger schema files (paths)] end
|
157
|
-
I, [2019-06-02T22:12:41.642664 #61323] INFO -- : Write schema file: oas_docs/src/externalDocs.yml
|
158
|
-
I, [2019-06-02T22:12:41.642993 #61323] INFO -- : Write schema file: oas_docs/src/servers.yml
|
159
|
-
I, [2019-06-02T22:12:41.643015 #61323] INFO -- : [Generate Swagger schema files (components)] start
|
160
|
-
I, [2019-06-02T22:12:41.643335 #61323] INFO -- : <From routes data>
|
161
|
-
I, [2019-06-02T22:12:41.643421 #61323] INFO -- : <Update Components schema files (components/schemas)>
|
162
|
-
I, [2019-06-02T22:12:41.645158 #61323] INFO -- : Write schema file: oas_docs/src/components/schemas/engine.yml
|
163
|
-
I, [2019-06-02T22:12:41.645613 #61323] INFO -- : Write schema file: oas_docs/src/components/schemas/post.yml
|
164
|
-
I, [2019-06-02T22:12:41.645987 #61323] INFO -- : Write schema file: oas_docs/src/components/schemas/task.yml
|
165
|
-
I, [2019-06-02T22:12:41.646443 #61323] INFO -- : Write schema file: oas_docs/src/components/schemas/user.yml
|
166
|
-
I, [2019-06-02T22:12:41.646833 #61323] INFO -- : Write schema file: oas_docs/src/components/schemas/main.yml
|
167
|
-
I, [2019-06-02T22:12:41.646853 #61323] INFO -- : [Generate Swagger schema files (components)] end
|
168
|
-
I, [2019-06-02T22:12:41.646865 #61323] INFO -- : [Generate Swagger schema files] end
|
169
|
-
I, [2019-06-02T22:12:41.646874 #61323] INFO -- : [Generate Swagger docs from schema files] start
|
170
|
-
I, [2019-06-02T22:12:41.647400 #61323] INFO -- : Use schema file: oas_docs/src/openapi.yml
|
171
|
-
I, [2019-06-02T22:12:41.648404 #61323] INFO -- : Use schema file: oas_docs/src/paths/user.yml
|
172
|
-
I, [2019-06-02T22:12:41.649983 #61323] INFO -- : Use schema file: oas_docs/src/paths/api/v1/task.yml
|
173
|
-
I, [2019-06-02T22:12:41.651386 #61323] INFO -- : Use schema file: oas_docs/src/paths/api/v1/post.yml
|
174
|
-
I, [2019-06-02T22:12:41.652608 #61323] INFO -- : Use schema file: oas_docs/src/paths/api/v2/post.yml
|
175
|
-
I, [2019-06-02T22:12:41.654068 #61323] INFO -- : Use schema file: oas_docs/src/paths/task.yml
|
176
|
-
I, [2019-06-02T22:12:41.654754 #61323] INFO -- : Use schema file: oas_docs/src/paths/rails_admin/engine.yml
|
177
|
-
I, [2019-06-02T22:12:41.658028 #61323] INFO -- : Use schema file: oas_docs/src/paths/rails_admin/main.yml
|
178
|
-
I, [2019-06-02T22:12:41.658622 #61323] INFO -- : Use schema file: oas_docs/src/externalDocs.yml
|
179
|
-
I, [2019-06-02T22:12:41.659216 #61323] INFO -- : Use schema file: oas_docs/src/tags.yml
|
180
|
-
I, [2019-06-02T22:12:41.659715 #61323] INFO -- : Use schema file: oas_docs/src/components/schemas/user.yml
|
181
|
-
I, [2019-06-02T22:12:41.660165 #61323] INFO -- : Use schema file: oas_docs/src/components/schemas/task.yml
|
182
|
-
I, [2019-06-02T22:12:41.660528 #61323] INFO -- : Use schema file: oas_docs/src/components/schemas/engine.yml
|
183
|
-
I, [2019-06-02T22:12:41.660788 #61323] INFO -- : Use schema file: oas_docs/src/components/schemas/main.yml
|
184
|
-
I, [2019-06-02T22:12:41.661004 #61323] INFO -- : Use schema file: oas_docs/src/components/schemas/post.yml
|
185
|
-
I, [2019-06-02T22:12:41.661261 #61323] INFO -- : Use schema file: oas_docs/src/info.yml
|
186
|
-
I, [2019-06-02T22:12:41.661520 #61323] INFO -- : Use schema file: oas_docs/src/servers.yml
|
187
|
-
I, [2019-06-02T22:12:41.686435 #61323] INFO -- : [Generate Swagger docs from schema files] end
|
188
|
-
I, [2019-06-02T22:12:41.686477 #61323] INFO -- : [R2-OAS] end
|
189
|
-
```
|
190
|
-
|
191
|
-
`oas_docs/schema/paths/api/v1/post` is generated like that:
|
192
|
-
|
193
|
-
```diff
|
194
|
-
---
|
195
|
-
paths:
|
196
|
-
"/api/v1/posts":
|
197
|
-
get:
|
198
|
-
tags:
|
199
|
-
- api/v1/post
|
200
|
-
summary: get summary
|
201
|
-
description: get description
|
202
|
-
responses:
|
203
|
-
default:
|
204
|
-
description: ''
|
205
|
-
'200':
|
206
|
-
description: api/v1/post description
|
207
|
-
content:
|
208
|
-
application/json:
|
209
|
-
schema:
|
210
|
-
"$ref": "#/components/schemas/Post"
|
211
|
-
deprecated: false
|
212
|
-
+ parameters:
|
213
|
-
+ - name: sort
|
214
|
-
+ in: query
|
215
|
-
+ description: option to sort posts
|
216
|
-
+ required: false
|
217
|
-
+ deprecated: false
|
218
|
-
post:
|
219
|
-
tags:
|
220
|
-
- api/v1/post
|
221
|
-
summary: post summary
|
222
|
-
description: post description
|
223
|
-
responses:
|
224
|
-
default:
|
225
|
-
description: ''
|
226
|
-
'200':
|
227
|
-
description: api/v1/post description
|
228
|
-
content:
|
229
|
-
application/json:
|
230
|
-
schema:
|
231
|
-
"$ref": "#/components/schemas/Post"
|
232
|
-
deprecated: false
|
233
|
-
```
|
234
|
-
|
235
|
-
|
@@ -1,183 +0,0 @@
|
|
1
|
-
# Use Schema Namespace
|
2
|
-
|
3
|
-
## Prepare
|
4
|
-
|
5
|
-
Add this line to your application's Gemfile:
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
group :development do
|
9
|
-
gem 'r2-oas'
|
10
|
-
end
|
11
|
-
```
|
12
|
-
|
13
|
-
Add the following settings to your rails project's `config/environments/development.rb`.
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
require 'r2-oas'
|
17
|
-
|
18
|
-
R2OAS.configure do |config|
|
19
|
-
config.use_schema_namespace = true
|
20
|
-
end
|
21
|
-
```
|
22
|
-
|
23
|
-
## Command
|
24
|
-
|
25
|
-
```bash
|
26
|
-
$ bundle exec rake routes:oas:docs
|
27
|
-
```
|
28
|
-
|
29
|
-
## Example
|
30
|
-
|
31
|
-
if there is routing like this:
|
32
|
-
|
33
|
-
```
|
34
|
-
$ bundle exec rake routes
|
35
|
-
Prefix Verb URI Pattern Controller#Action
|
36
|
-
rails_admin /admin RailsAdmin::Engine
|
37
|
-
api_v2_posts GET /api/v2/posts(.:format) api/v2/posts#index {:format=>:json}
|
38
|
-
POST /api/v2/posts(.:format) api/v2/posts#create {:format=>:json}
|
39
|
-
new_api_v2_post GET /api/v2/posts/new(.:format) api/v2/posts#new {:format=>:json}
|
40
|
-
edit_api_v2_post GET /api/v2/posts/:id/edit(.:format) api/v2/posts#edit {:format=>:json}
|
41
|
-
api_v2_post GET /api/v2/posts/:id(.:format) api/v2/posts#show {:format=>:json}
|
42
|
-
PATCH /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
|
43
|
-
PUT /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
|
44
|
-
DELETE /api/v2/posts/:id(.:format) api/v2/posts#destroy {:format=>:json}
|
45
|
-
api_v1_posts GET /api/v1/posts(.:format) api/v1/posts#index
|
46
|
-
POST /api/v1/posts(.:format) api/v1/posts#create
|
47
|
-
new_api_v1_post GET /api/v1/posts/new(.:format) api/v1/posts#new
|
48
|
-
edit_api_v1_post GET /api/v1/posts/:id/edit(.:format) api/v1/posts#edit
|
49
|
-
api_v1_post GET /api/v1/posts/:id(.:format) api/v1/posts#show
|
50
|
-
PATCH /api/v1/posts/:id(.:format) api/v1/posts#update
|
51
|
-
PUT /api/v1/posts/:id(.:format) api/v1/posts#update
|
52
|
-
DELETE /api/v1/posts/:id(.:format) api/v1/posts#destroy
|
53
|
-
api_v1_tasks GET /api/v1/tasks(.:format) api/v1/tasks#index
|
54
|
-
POST /api/v1/tasks(.:format) api/v1/tasks#create
|
55
|
-
new_api_v1_task GET /api/v1/tasks/new(.:format) api/v1/tasks#new
|
56
|
-
edit_api_v1_task GET /api/v1/tasks/:id/edit(.:format) api/v1/tasks#edit
|
57
|
-
api_v1_task GET /api/v1/tasks/:id(.:format) api/v1/tasks#show
|
58
|
-
PATCH /api/v1/tasks/:id(.:format) api/v1/tasks#update
|
59
|
-
PUT /api/v1/tasks/:id(.:format) api/v1/tasks#update
|
60
|
-
DELETE /api/v1/tasks/:id(.:format) api/v1/tasks#destroy
|
61
|
-
tasks GET /tasks(.:format) tasks#index
|
62
|
-
POST /tasks(.:format) tasks#create
|
63
|
-
new_task GET /tasks/new(.:format) tasks#new
|
64
|
-
edit_task GET /tasks/:id/edit(.:format) tasks#edit
|
65
|
-
task GET /tasks/:id(.:format) tasks#show
|
66
|
-
PATCH /tasks/:id(.:format) tasks#update
|
67
|
-
PUT /tasks/:id(.:format) tasks#update
|
68
|
-
DELETE /tasks/:id(.:format) tasks#destroy
|
69
|
-
users GET /users(.:format) users#index
|
70
|
-
POST /users(.:format) users#create
|
71
|
-
new_user GET /users/new(.:format) users#new
|
72
|
-
edit_user GET /users/:id/edit(.:format) users#edit
|
73
|
-
user GET /users/:id(.:format) users#show
|
74
|
-
PATCH /users/:id(.:format) users#update
|
75
|
-
PUT /users/:id(.:format) users#update
|
76
|
-
DELETE /users/:id(.:format) users#destroy
|
77
|
-
|
78
|
-
Routes for RailsAdmin::Engine:
|
79
|
-
dashboard GET / rails_admin/main#dashboard
|
80
|
-
index GET|POST /:model_name(.:format) rails_admin/main#index
|
81
|
-
new GET|POST /:model_name/new(.:format) rails_admin/main#new
|
82
|
-
export GET|POST /:model_name/export(.:format) rails_admin/main#export
|
83
|
-
bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
|
84
|
-
bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
|
85
|
-
show GET /:model_name/:id(.:format) rails_admin/main#show
|
86
|
-
edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
|
87
|
-
delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
|
88
|
-
show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
|
89
|
-
```
|
90
|
-
|
91
|
-
<img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/56959813-c1586c80-6b89-11e9-9903-da95d25858f0.png" width="546">
|
92
|
-
|
93
|
-
Generate like this:
|
94
|
-
|
95
|
-
```
|
96
|
-
oas_docs
|
97
|
-
├── schema
|
98
|
-
│ ├── components
|
99
|
-
│ │ └── schemas
|
100
|
-
│ │ ├── api
|
101
|
-
│ │ │ ├── v1
|
102
|
-
│ │ │ │ ├── post.yml
|
103
|
-
│ │ │ │ └── task.yml
|
104
|
-
│ │ │ └── v2
|
105
|
-
│ │ │ └── post.yml
|
106
|
-
│ │ ├── rails_admin
|
107
|
-
│ │ │ ├── engine.yml
|
108
|
-
│ │ │ └── main.yml
|
109
|
-
│ │ ├── task.yml
|
110
|
-
│ │ └── user.yml
|
111
|
-
│ ├── externalDocs.yml
|
112
|
-
│ ├── info.yml
|
113
|
-
│ ├── openapi.yml
|
114
|
-
│ ├── paths
|
115
|
-
│ │ ├── api
|
116
|
-
│ │ │ ├── v1
|
117
|
-
│ │ │ │ ├── post.yml
|
118
|
-
│ │ │ │ └── task.yml
|
119
|
-
│ │ │ └── v2
|
120
|
-
│ │ │ └── post.yml
|
121
|
-
│ │ ├── rails_admin
|
122
|
-
│ │ │ ├── engine.yml
|
123
|
-
│ │ │ └── main.yml
|
124
|
-
│ │ ├── task.yml
|
125
|
-
│ │ └── user.yml
|
126
|
-
│ ├── servers.yml
|
127
|
-
│ └── tags.yml
|
128
|
-
└── oas_doc.yml
|
129
|
-
```
|
130
|
-
|
131
|
-
## Do not Use Tag Namespace
|
132
|
-
|
133
|
-
```ruby
|
134
|
-
|
135
|
-
require 'r2-oas'
|
136
|
-
|
137
|
-
R2OAS.configure do |config|
|
138
|
-
# default setting
|
139
|
-
config.root_dir_path = "./oas_docs"
|
140
|
-
config.schema_save_dir_name = "src"
|
141
|
-
config.doc_save_file_name = "oas_doc.yml"
|
142
|
-
config.use_tag_namespace = true
|
143
|
-
config.use_schema_namespace = false # write here
|
144
|
-
end
|
145
|
-
```
|
146
|
-
|
147
|
-
```bash
|
148
|
-
$ bundle exec rake routes:oas:docs
|
149
|
-
```
|
150
|
-
|
151
|
-
<img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/57007768-134ed000-6c26-11e9-9b4e-60f58c78221e.png" width="546">
|
152
|
-
|
153
|
-
Generate like this:
|
154
|
-
|
155
|
-
```
|
156
|
-
oas_docs
|
157
|
-
├── schema
|
158
|
-
│ ├── components
|
159
|
-
│ │ └── schemas
|
160
|
-
│ │ ├── engine.yml
|
161
|
-
│ │ ├── main.yml
|
162
|
-
│ │ ├── post.yml
|
163
|
-
│ │ ├── task.yml
|
164
|
-
│ │ └── user.yml
|
165
|
-
│ ├── externalDocs.yml
|
166
|
-
│ ├── info.yml
|
167
|
-
│ ├── openapi.yml
|
168
|
-
│ ├── paths
|
169
|
-
│ │ ├── api
|
170
|
-
│ │ │ ├── v1
|
171
|
-
│ │ │ │ ├── post.yml
|
172
|
-
│ │ │ │ └── task.yml
|
173
|
-
│ │ │ └── v2
|
174
|
-
│ │ │ └── post.yml
|
175
|
-
│ │ ├── rails_admin
|
176
|
-
│ │ │ ├── engine.yml
|
177
|
-
│ │ │ └── main.yml
|
178
|
-
│ │ ├── task.yml
|
179
|
-
│ │ └── user.yml
|
180
|
-
│ ├── servers.yml
|
181
|
-
│ └── tags.yml
|
182
|
-
└── oas_doc.yml
|
183
|
-
```
|
@@ -1,182 +0,0 @@
|
|
1
|
-
# Use Tag Namespace
|
2
|
-
|
3
|
-
## Prepare
|
4
|
-
|
5
|
-
Add this line to your application's Gemfile:
|
6
|
-
|
7
|
-
```ruby
|
8
|
-
group :development do
|
9
|
-
gem 'r2-oas'
|
10
|
-
end
|
11
|
-
```
|
12
|
-
|
13
|
-
Add the following settings to your rails project's `config/environments/development.rb`.
|
14
|
-
|
15
|
-
```ruby
|
16
|
-
require 'r2-oas'
|
17
|
-
|
18
|
-
R2OAS.configure do |config|
|
19
|
-
config.use_tag_namespace = true
|
20
|
-
end
|
21
|
-
```
|
22
|
-
|
23
|
-
## Command
|
24
|
-
|
25
|
-
```bash
|
26
|
-
$ bundle exec rake routes:oas:docs
|
27
|
-
```
|
28
|
-
|
29
|
-
## Example
|
30
|
-
|
31
|
-
if there is routing like this:
|
32
|
-
|
33
|
-
```
|
34
|
-
$ bundle exec rake routes
|
35
|
-
Prefix Verb URI Pattern Controller#Action
|
36
|
-
rails_admin /admin RailsAdmin::Engine
|
37
|
-
api_v2_posts GET /api/v2/posts(.:format) api/v2/posts#index {:format=>:json}
|
38
|
-
POST /api/v2/posts(.:format) api/v2/posts#create {:format=>:json}
|
39
|
-
new_api_v2_post GET /api/v2/posts/new(.:format) api/v2/posts#new {:format=>:json}
|
40
|
-
edit_api_v2_post GET /api/v2/posts/:id/edit(.:format) api/v2/posts#edit {:format=>:json}
|
41
|
-
api_v2_post GET /api/v2/posts/:id(.:format) api/v2/posts#show {:format=>:json}
|
42
|
-
PATCH /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
|
43
|
-
PUT /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
|
44
|
-
DELETE /api/v2/posts/:id(.:format) api/v2/posts#destroy {:format=>:json}
|
45
|
-
api_v1_posts GET /api/v1/posts(.:format) api/v1/posts#index
|
46
|
-
POST /api/v1/posts(.:format) api/v1/posts#create
|
47
|
-
new_api_v1_post GET /api/v1/posts/new(.:format) api/v1/posts#new
|
48
|
-
edit_api_v1_post GET /api/v1/posts/:id/edit(.:format) api/v1/posts#edit
|
49
|
-
api_v1_post GET /api/v1/posts/:id(.:format) api/v1/posts#show
|
50
|
-
PATCH /api/v1/posts/:id(.:format) api/v1/posts#update
|
51
|
-
PUT /api/v1/posts/:id(.:format) api/v1/posts#update
|
52
|
-
DELETE /api/v1/posts/:id(.:format) api/v1/posts#destroy
|
53
|
-
api_v1_tasks GET /api/v1/tasks(.:format) api/v1/tasks#index
|
54
|
-
POST /api/v1/tasks(.:format) api/v1/tasks#create
|
55
|
-
new_api_v1_task GET /api/v1/tasks/new(.:format) api/v1/tasks#new
|
56
|
-
edit_api_v1_task GET /api/v1/tasks/:id/edit(.:format) api/v1/tasks#edit
|
57
|
-
api_v1_task GET /api/v1/tasks/:id(.:format) api/v1/tasks#show
|
58
|
-
PATCH /api/v1/tasks/:id(.:format) api/v1/tasks#update
|
59
|
-
PUT /api/v1/tasks/:id(.:format) api/v1/tasks#update
|
60
|
-
DELETE /api/v1/tasks/:id(.:format) api/v1/tasks#destroy
|
61
|
-
tasks GET /tasks(.:format) tasks#index
|
62
|
-
POST /tasks(.:format) tasks#create
|
63
|
-
new_task GET /tasks/new(.:format) tasks#new
|
64
|
-
edit_task GET /tasks/:id/edit(.:format) tasks#edit
|
65
|
-
task GET /tasks/:id(.:format) tasks#show
|
66
|
-
PATCH /tasks/:id(.:format) tasks#update
|
67
|
-
PUT /tasks/:id(.:format) tasks#update
|
68
|
-
DELETE /tasks/:id(.:format) tasks#destroy
|
69
|
-
users GET /users(.:format) users#index
|
70
|
-
POST /users(.:format) users#create
|
71
|
-
new_user GET /users/new(.:format) users#new
|
72
|
-
edit_user GET /users/:id/edit(.:format) users#edit
|
73
|
-
user GET /users/:id(.:format) users#show
|
74
|
-
PATCH /users/:id(.:format) users#update
|
75
|
-
PUT /users/:id(.:format) users#update
|
76
|
-
DELETE /users/:id(.:format) users#destroy
|
77
|
-
|
78
|
-
Routes for RailsAdmin::Engine:
|
79
|
-
dashboard GET / rails_admin/main#dashboard
|
80
|
-
index GET|POST /:model_name(.:format) rails_admin/main#index
|
81
|
-
new GET|POST /:model_name/new(.:format) rails_admin/main#new
|
82
|
-
export GET|POST /:model_name/export(.:format) rails_admin/main#export
|
83
|
-
bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
|
84
|
-
bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
|
85
|
-
show GET /:model_name/:id(.:format) rails_admin/main#show
|
86
|
-
edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
|
87
|
-
delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
|
88
|
-
show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
|
89
|
-
```
|
90
|
-
|
91
|
-
<img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/56959813-c1586c80-6b89-11e9-9903-da95d25858f0.png" width="546">
|
92
|
-
|
93
|
-
Generate like this:
|
94
|
-
|
95
|
-
```
|
96
|
-
oas_docs
|
97
|
-
├── schema
|
98
|
-
│ ├── components
|
99
|
-
│ │ └── schemas
|
100
|
-
│ │ ├── api
|
101
|
-
│ │ │ ├── v1
|
102
|
-
│ │ │ │ ├── post.yml
|
103
|
-
│ │ │ │ └── task.yml
|
104
|
-
│ │ │ └── v2
|
105
|
-
│ │ │ └── post.yml
|
106
|
-
│ │ ├── rails_admin
|
107
|
-
│ │ │ ├── engine.yml
|
108
|
-
│ │ │ └── main.yml
|
109
|
-
│ │ ├── task.yml
|
110
|
-
│ │ └── user.yml
|
111
|
-
│ ├── externalDocs.yml
|
112
|
-
│ ├── info.yml
|
113
|
-
│ ├── openapi.yml
|
114
|
-
│ ├── paths
|
115
|
-
│ │ ├── api
|
116
|
-
│ │ │ ├── v1
|
117
|
-
│ │ │ │ ├── post.yml
|
118
|
-
│ │ │ │ └── task.yml
|
119
|
-
│ │ │ └── v2
|
120
|
-
│ │ │ └── post.yml
|
121
|
-
│ │ ├── rails_admin
|
122
|
-
│ │ │ ├── engine.yml
|
123
|
-
│ │ │ └── main.yml
|
124
|
-
│ │ ├── task.yml
|
125
|
-
│ │ └── user.yml
|
126
|
-
│ ├── servers.yml
|
127
|
-
│ └── tags.yml
|
128
|
-
└── oas_doc.yml
|
129
|
-
```
|
130
|
-
|
131
|
-
# Do not Use Tag Namespace
|
132
|
-
|
133
|
-
## Prepare
|
134
|
-
|
135
|
-
```ruby
|
136
|
-
|
137
|
-
require 'r2-oas'
|
138
|
-
|
139
|
-
R2OAS.configure do |config|
|
140
|
-
config.use_tag_namespace = false
|
141
|
-
end
|
142
|
-
```
|
143
|
-
|
144
|
-
## Command
|
145
|
-
|
146
|
-
```bash
|
147
|
-
$ bundle exec rake routes:oas:docs
|
148
|
-
```
|
149
|
-
|
150
|
-
<img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/57007590-bdc5f380-6c24-11e9-9aa4-85f2fe97e463.png" width="546">
|
151
|
-
|
152
|
-
Generate like this:
|
153
|
-
|
154
|
-
```
|
155
|
-
oas_docs
|
156
|
-
├── schema
|
157
|
-
│ ├── components
|
158
|
-
│ │ └── schemas
|
159
|
-
│ │ ├── api
|
160
|
-
│ │ │ ├── v1
|
161
|
-
│ │ │ │ ├── post.yml
|
162
|
-
│ │ │ │ └── task.yml
|
163
|
-
│ │ │ └── v2
|
164
|
-
│ │ │ └── post.yml
|
165
|
-
│ │ ├── rails_admin
|
166
|
-
│ │ │ ├── engine.yml
|
167
|
-
│ │ │ └── main.yml
|
168
|
-
│ │ ├── task.yml
|
169
|
-
│ │ └── user.yml
|
170
|
-
│ ├── externalDocs.yml
|
171
|
-
│ ├── info.yml
|
172
|
-
│ ├── openapi.yml
|
173
|
-
│ ├── paths
|
174
|
-
│ │ ├── engine.yml
|
175
|
-
│ │ ├── main.yml
|
176
|
-
│ │ ├── post.yml
|
177
|
-
│ │ ├── task.yml
|
178
|
-
│ │ └── user.yml
|
179
|
-
│ ├── servers.yml
|
180
|
-
│ └── tags.yml
|
181
|
-
└── oas_doc.yml
|
182
|
-
```
|