r2-oas 0.1.0 → 0.3.1
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 +58 -1
- data/GEMSPEC.md +20 -0
- data/README.ja.md +65 -396
- data/README.md +62 -392
- data/devscript/all_support_ruby.sh +43 -0
- data/devscript/bundle_for_all_support_ruby.sh +31 -0
- data/devscript/rspec_for_all_support_ruby.sh +27 -0
- data/docs/.nojekyll +0 -0
- data/docs/README.md +173 -0
- data/docs/_sidebar.md +25 -0
- data/docs/attention/if_clash.md +17 -0
- data/docs/index.html +29 -0
- data/docs/{versions/v3.md → schema/3.0.0.md} +1 -1
- data/docs/setting/COC.md +14 -0
- data/docs/setting/CORS.md +22 -0
- data/docs/setting/configure.md +176 -0
- data/docs/trableshouting/runtime_error.md +44 -0
- data/docs/{HOW_TO_ANALYZE_DOCS.md → usage/analyze_docs.md} +52 -52
- data/docs/usage/clean_docs.md +19 -0
- data/docs/{HOW_TO_DEPLOY_SWAGGER_DOC.md → usage/deploy_docs.md} +29 -29
- data/docs/usage/display_paths_list.md +35 -0
- data/docs/{HOW_TO_DISPLAY_PATHS_STATS.md → usage/display_paths_stats.md} +15 -14
- data/docs/{HOW_TO_START_SWAGGER_EDITOR.md → usage/edit_docs.md} +88 -88
- data/docs/usage/generate_docs.md +412 -0
- data/docs/{HOW_TO_MONITOR_SWAGGER_DOC.md → usage/monitor_docs.md} +71 -71
- data/docs/usage/use_hook_methods.md +236 -0
- data/docs/{HOW_TO_USE_HOOK_WHEN_GENERATE_DOC.md → usage/use_hook_to_generate_docs.md} +48 -57
- data/docs/{HOW_TO_USE_SCHEMA_NAMESPACE.md → usage/use_schema_namespace.md} +46 -41
- data/docs/{HOW_TO_USE_TAG_NAMESPACE.md → usage/use_tag_namespace.md} +46 -42
- data/docs/{HOW_TO_START_SWAGGER_UI.md → usage/view_docs.md} +132 -132
- data/gemfiles/ruby_2.3.3.gemfile +11 -0
- data/gemfiles/ruby_2.4.2.gemfile +11 -0
- data/gemfiles/ruby_2.5.8.gemfile +11 -0
- data/gemfiles/ruby_2.6.6.gemfile +11 -0
- data/gemfiles/ruby_2.7.1.gemfile +11 -0
- data/lib/r2-oas.rb +3 -4
- data/lib/r2-oas/app_configuration.rb +19 -16
- data/lib/r2-oas/deploy/client.rb +14 -2
- 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/schema/v3/object/path_item_object.rb +17 -9
- 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 +25 -28
- data/lib/r2-oas/tool/paths/ls.rb +1 -1
- data/lib/r2-oas/version.rb +1 -1
- data/r2-oas.gemspec +20 -25
- metadata +122 -52
- data/Gemfile.lock +0 -207
- data/docs/HOW_TO_CLEAN_DOCS.md +0 -19
- data/docs/HOW_TO_DISPLAY_PATHS_LIST.md +0 -28
- data/docs/HOW_TO_GENERATE_DOCS.md +0 -256
data/README.md
CHANGED
@@ -1,10 +1,11 @@
|
|
1
1
|
# R2-OAS
|
2
2
|
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/r2-oas.svg)](https://badge.fury.io/rb/r2-oas)
|
3
4
|
[![Build Status](https://travis-ci.org/yukihirop/r2-oas.svg?branch=master)](https://travis-ci.org/yukihirop/r2-oas)
|
4
5
|
[![Coverage Status](https://coveralls.io/repos/github/yukihirop/r2-oas/badge.svg)](https://coveralls.io/github/yukihirop/r2-oas)
|
5
6
|
[![Maintainability](https://api.codeclimate.com/v1/badges/f8c3846f350bb412fd63/maintainability)](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
|
6
7
|
|
7
|
-
Generate api docment(OpenAPI) side only from `
|
8
|
+
Generate api docment(OpenAPI) side only from `Rails` routing.
|
8
9
|
|
9
10
|
Provides a rake command to help `generate` , `view` , and `edit` OpenAPI documents.
|
10
11
|
|
@@ -62,88 +63,16 @@ bundle exec routes:oas:docs
|
|
62
63
|
bundle exec routes:oas:editor
|
63
64
|
```
|
64
65
|
|
65
|
-
|
66
|
+
#### Generate docs
|
66
67
|
|
67
|
-
|
68
|
+
![oas_docs](https://user-images.githubusercontent.com/11146767/80856236-0b839a80-8c83-11ea-888f-d0e659e0c251.gif)
|
68
69
|
|
69
|
-
In your rails project, Write `config/environments/development.rb` like that:
|
70
70
|
|
71
|
-
|
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
|
71
|
+
#### Edit docs
|
102
72
|
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
138
|
-
config.tool.paths_stats.configure do |paths_stats|
|
139
|
-
paths_stats.month_to_turn_to_warning_color = 3
|
140
|
-
paths_stats.warning_color = :red
|
141
|
-
paths_stats.table_title_color = :yellow
|
142
|
-
paths_stats.heading_color = :yellow
|
143
|
-
paths_stats.highlight_color = :magenta
|
144
|
-
end
|
145
|
-
end
|
146
|
-
```
|
73
|
+
![oas_editor](https://user-images.githubusercontent.com/11146767/80856240-15a59900-8c83-11ea-9dbd-4382528944f2.gif)
|
74
|
+
|
75
|
+
## Usage
|
147
76
|
|
148
77
|
You can execute the following command in the root directory of rails.
|
149
78
|
|
@@ -179,20 +108,9 @@ $ bundle exec rake routes:oas:paths_ls
|
|
179
108
|
$ bundle exec rake routes:oas:paths_stats
|
180
109
|
```
|
181
110
|
|
182
|
-
## 📚
|
183
|
-
|
184
|
-
|
185
|
-
- [How to start swagger editor](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_START_SWAGGER_EDITOR.md)
|
186
|
-
- [How to start swagger ui](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_START_SWAGGER_UI.md)
|
187
|
-
- [How to monitor swagger document](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_MONITOR_SWAGGER_DOC.md)
|
188
|
-
- [How to analyze docs](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_ANALYZE_DOCS.md)
|
189
|
-
- [How to clean docs](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_CLEAN_DOCS.md)
|
190
|
-
- [How to deploy swagger doc](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_DEPLOY_SWAGGER_DOC.md)
|
191
|
-
- [How to use tag namespace](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_USE_TAG_NAMESPACE.md)
|
192
|
-
- [How to use schema namespace](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_USE_SCHEMA_NAMESPACE.md)
|
193
|
-
- [How to use hook when generate doc](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_USE_HOOK_WHEN_GENERATE_DOC.md)
|
194
|
-
- [How to display paths list](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_DISPLAY_PATHS_LIST.md)
|
195
|
-
- [How to display paths stats](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_DISPLAY_PATHS_STATS.md)
|
111
|
+
## 📚 Documents
|
112
|
+
|
113
|
+
Full docs are available at https://yukihirop.github.io/r2-oas
|
196
114
|
|
197
115
|
## ❤️ Support Rails Version
|
198
116
|
|
@@ -209,9 +127,7 @@ $ bundle exec rake routes:oas:paths_stats
|
|
209
127
|
|
210
128
|
## ❤️ Support OpenAPI Schema
|
211
129
|
|
212
|
-
|
213
|
-
|-------|--------|
|
214
|
-
|v3|[versions/v3.md](https://github.com/yukihirop/r2-oas/blob/master/docs/versions/v3.md)|
|
130
|
+
Full docs are available at https://yukihirop.github.io/r2-oas/#/schema/3.0.0
|
215
131
|
|
216
132
|
## ❗️ Convention over Configuration (CoC)
|
217
133
|
|
@@ -230,322 +146,76 @@ $ bundle exec rake routes:oas:paths_stats
|
|
230
146
|
|
231
147
|
## ⚙ Configure
|
232
148
|
|
233
|
-
|
234
|
-
|
235
|
-
#### basic
|
236
|
-
|
237
|
-
|option|description|default|
|
238
|
-
|------|-----------|---|
|
239
|
-
|version|OpenAPI schema version| `:v3` |
|
240
|
-
|root_dir_path|Root directory for storing products.| `"./oas_docs"` |
|
241
|
-
|schema_save_dir_name|Directory name for storing swagger schemas|`"src"`|
|
242
|
-
|doc_save_file_name|File name for storing swagger doc|`"oas_doc.yml"`|
|
243
|
-
|force_update_schema|Force update schema from routes data|`false`|
|
244
|
-
|use_tag_namespace|Use namespace for tag name|`true`|
|
245
|
-
|use_schema_namespace|Use namespace for schema name|`true`|
|
246
|
-
|interval_to_save_edited_tmp_schema|Interval(sec) to save edited tmp schema|`15`|
|
247
|
-
|http_statuses_when_http_method|Determine the response to support for each HTTP method|omission...|
|
248
|
-
|http_methods_when_generate_request_body|HTTP methods when generate requestBody|`[post put patch]`|
|
249
|
-
|namespace_type|namespace for components(schemas/requestBodies) name| `underbar` |
|
250
|
-
|deploy_dir_path|deploy directory.|`"./deploy_docs"`|
|
251
|
-
|
252
|
-
#### server
|
253
|
-
|
254
|
-
|option|children option|description|default|
|
255
|
-
|------|---------------|-----------|-------|
|
256
|
-
|server|data|Server data (url, description) |[{ url: `http://localhost:3000`, description: `localhost` }] |
|
257
|
-
|
258
|
-
#### swagger
|
259
|
-
|
260
|
-
|option|children option|grandchild option|description|default|
|
261
|
-
|------|---------------|-----------------|-----------|-------|
|
262
|
-
|swagger|ui|image|Swagger UI Docker Image|`"swaggerapi/swagger-ui"`|
|
263
|
-
|swagger|ui|port|Swagger UI Port|`"8080"`|
|
264
|
-
|swagger|ui|exposed_port|Swagger UI Exposed Port|`"8080/tcp"`|
|
265
|
-
|swagger|ui|volume|Swagger UI Volume|`"/app/swagger.json"`|
|
266
|
-
|swagger|editor|image|Swagger Editor Docker Image|`"swaggerapi/swagger-editor"`|
|
267
|
-
|swagger|editor|port|Swagger Editor Port|`"8080"`|
|
268
|
-
|swagger|editor|exposed_port|Swagger Editor Exposed Port|`"8080/tcp"`|
|
149
|
+
All settings are `optional`
|
269
150
|
|
270
|
-
|
271
|
-
|
272
|
-
|option|description|default|
|
273
|
-
|------|-----------|-------|
|
274
|
-
|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` }|
|
275
|
-
|
276
|
-
#### tool
|
277
|
-
|
278
|
-
|option|children option|grandchild option|description|default|
|
279
|
-
|------|---------------|-----------------|-----------|-------|
|
280
|
-
|tool|paths_stats|month_to_turn_to_warning_color|Elapsed month to issue a warning|`3`|
|
281
|
-
|tool|paths_stats|warning_color|Warning Color|`:red`|
|
282
|
-
|tool|paths_stats|table_title_color|Table Title Color|`:yellow`|
|
283
|
-
|tool|paths_stats|heading_color|Heading Color|`:yellow`|
|
284
|
-
|tool|paths_stats|highlight_color|Highlight Color|`:magenta`|
|
285
|
-
|
286
|
-
Please refer to [here](https://github.com/janlelis/paint) for the color.
|
287
|
-
|
288
|
-
## Environment variables
|
289
|
-
|
290
|
-
We explain the environment variables that can be set.
|
291
|
-
|
292
|
-
|variable|description|default|
|
293
|
-
|--------|-----------|-------|
|
294
|
-
|PATHS_FILE|Specify one paths file path|`""`|
|
295
|
-
|OAS_FILE|Specify swagger file path to analyze|`""`|
|
296
|
-
|
297
|
-
|
298
|
-
## .paths
|
299
|
-
|
300
|
-
Writing file paths in .paths will only read them.
|
301
|
-
You can comment out with `#`
|
302
|
-
|
303
|
-
`oas_docs/.paths`
|
304
|
-
|
305
|
-
```
|
306
|
-
#account_user_role.yml # ignore
|
307
|
-
account.yml
|
308
|
-
account.yml # ignore
|
309
|
-
account.yml # ignore
|
310
|
-
```
|
151
|
+
Full docs are available at https://yukihirop.github.io/r2-oas/#/setting/configure
|
311
152
|
|
312
153
|
## 💊 Life Cycle Methods (Hook Metohds)
|
313
154
|
|
314
155
|
Supported hook(life cycle methods) is like this:
|
315
156
|
|
316
|
-
-
|
317
|
-
- `after_create`
|
318
|
-
|
319
|
-
Supported Hook class is like this:
|
157
|
+
Full docs are available at https://yukihirop.github.io/r2-oas/#/usage/use_hook_methods
|
320
158
|
|
321
|
-
|
322
|
-
- `R2OAS::Schema::V3::PathsObject`
|
323
|
-
- `R2OAS::Schema::V3::PathItemObject`
|
324
|
-
- `R2OAS::Schema::V3::ExternalDocumentObject`
|
325
|
-
- `R2OAS::Schema::V3::ComponentsObject`
|
326
|
-
- `R2OAS::Schema::V3::Components::SchemaObject`
|
327
|
-
- `R2OAS::Schema::V3::Components::RequestBodyObject`
|
159
|
+
## Bundle and Rspec with multiple ruby versions
|
328
160
|
|
329
|
-
|
161
|
+
#### Bundle
|
330
162
|
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
after_create do |doc, path|
|
344
|
-
# [Important] Please change doc destructively.
|
345
|
-
# [Important] To be able to use methods in Rails !
|
346
|
-
doc.merge!({
|
347
|
-
# Something ....
|
348
|
-
})
|
349
|
-
end
|
350
|
-
end
|
351
|
-
```
|
352
|
-
|
353
|
-
#### case: PathsObject
|
354
|
-
|
355
|
-
```ruby
|
356
|
-
class CustomPathsObject < R2OAS::Schema::V3::PathsObject
|
357
|
-
before_create do |doc|
|
358
|
-
# [Important] Please change doc destructively.
|
359
|
-
# [Important] To be able to use methods in Rails !
|
360
|
-
doc.merge!({
|
361
|
-
# Something ....
|
362
|
-
})
|
363
|
-
end
|
364
|
-
|
365
|
-
after_create do |doc|
|
366
|
-
# [Important] Please change doc destructively.
|
367
|
-
# [Important] To be able to use methods in Rails !
|
368
|
-
doc.merge!({
|
369
|
-
# Something ....
|
370
|
-
})
|
371
|
-
end
|
372
|
-
end
|
373
|
-
```
|
374
|
-
|
375
|
-
#### case: PathItemObject
|
376
|
-
|
377
|
-
```ruby
|
378
|
-
class CustomPathItemObject < R2OAS::Schema::V3::PathItemObject
|
379
|
-
before_create do |doc, path|
|
380
|
-
# [Important] Please change doc destructively.
|
381
|
-
# [Important] To be able to use methods in Rails !
|
382
|
-
doc.merge!({
|
383
|
-
# Something ....
|
384
|
-
})
|
385
|
-
end
|
386
|
-
|
387
|
-
after_create do |doc, schema_name|
|
388
|
-
# [Important] Please change doc destructively.
|
389
|
-
# [Important] To be able to use methods in Rails !
|
390
|
-
doc.merge!({
|
391
|
-
# Something ....
|
392
|
-
})
|
393
|
-
end
|
394
|
-
end
|
395
|
-
```
|
396
|
-
|
397
|
-
#### case: ExternalDocumentObject
|
398
|
-
|
399
|
-
```ruby
|
400
|
-
class CustomExternalDocumentObject < R2OAS::Schema::V3::ExternalDocumentObject
|
401
|
-
before_create do |doc|
|
402
|
-
# [Important] Please change doc destructively.
|
403
|
-
# [Important] To be able to use methods in Rails !
|
404
|
-
doc.merge!({
|
405
|
-
# Something ....
|
406
|
-
})
|
407
|
-
end
|
408
|
-
|
409
|
-
after_create do |doc|
|
410
|
-
# [Important] Please change doc destructively.
|
411
|
-
# [Important] To be able to use methods in Rails !
|
412
|
-
doc.merge!({
|
413
|
-
# Something ....
|
414
|
-
})
|
415
|
-
end
|
416
|
-
end
|
417
|
-
```
|
418
|
-
|
419
|
-
#### case: ComponentsObject
|
420
|
-
|
421
|
-
```ruby
|
422
|
-
class CustomComponentsObject < R2OAS::Schema::V3::ComponentsObject
|
423
|
-
before_create do |doc|
|
424
|
-
# [Important] Please change doc destructively.
|
425
|
-
# [Important] To be able to use methods in Rails !
|
426
|
-
doc.merge!({
|
427
|
-
# Something ....
|
428
|
-
})
|
429
|
-
end
|
430
|
-
|
431
|
-
after_create do |doc|
|
432
|
-
# [Important] Please change doc destructively.
|
433
|
-
# [Important] To be able to use methods in Rails !
|
434
|
-
doc.merge!({
|
435
|
-
# Something ....
|
436
|
-
})
|
437
|
-
end
|
438
|
-
end
|
439
|
-
```
|
440
|
-
|
441
|
-
#### case: Components::SchemaObject
|
442
|
-
|
443
|
-
```ruby
|
444
|
-
class CustomComponentsSchemaObject < R2OAS::Schema::V3::Components::SchemaObject
|
445
|
-
before_create do |doc, schema_name|
|
446
|
-
# [Important] Please change doc destructively.
|
447
|
-
# [Important] To be able to use methods in Rails !
|
448
|
-
doc.merge!({
|
449
|
-
# Something ....
|
450
|
-
})
|
451
|
-
end
|
452
|
-
|
453
|
-
after_create do |doc, schema_name|
|
454
|
-
# [Important] Please change doc destructively.
|
455
|
-
# [Important] To be able to use methods in Rails !
|
456
|
-
doc.merge!({
|
457
|
-
# Something ....
|
458
|
-
})
|
459
|
-
end
|
460
|
-
end
|
461
|
-
```
|
462
|
-
|
463
|
-
If you want to determine the component schema name at runtime, like this:
|
464
|
-
|
465
|
-
```ruby
|
466
|
-
class CustomComponentsSchemaObject < R2OAS::Schema::V3::Components::SchemaObject
|
467
|
-
def components_schema_name(doc, path_component, tag_name, verb, http_status, schema_name)
|
468
|
-
# [Important] Please return string.
|
469
|
-
# default
|
470
|
-
schema_name
|
471
|
-
end
|
472
|
-
end
|
473
|
-
```
|
474
|
-
|
475
|
-
`path_component` is `R2OAS::Routing::PathComponent` instance.
|
476
|
-
|
477
|
-
```ruby
|
478
|
-
module R2OAS
|
479
|
-
module Routing
|
480
|
-
class PathComponent < BaseComponent
|
481
|
-
def initialize(path)
|
482
|
-
def to_s
|
483
|
-
def symbol_to_brace
|
484
|
-
def path_parameters_data
|
485
|
-
def path_excluded_path_parameters
|
486
|
-
def exist_path_parameters?
|
487
|
-
def path_parameters
|
488
|
-
private
|
489
|
-
def without_format
|
163
|
+
```bash
|
164
|
+
/bin/bash devscript/all_support_ruby.sh bundle
|
165
|
+
.
|
166
|
+
.
|
167
|
+
.
|
168
|
+
===== Bundle install for All Support Ruby Result =====
|
169
|
+
ruby-2.3.3: 0
|
170
|
+
ruby-2.4.2: 0
|
171
|
+
ruby-2.5.8: 0
|
172
|
+
ruby-2.6.6: 0
|
173
|
+
ruby-2.7.1: 0
|
174
|
+
======================================================
|
490
175
|
```
|
491
176
|
|
492
|
-
|
493
|
-
|
494
|
-
```ruby
|
495
|
-
class CustomComponentsRequestBodyObject < R2OAS::Schema::V3::Components::RequestBodyObject
|
496
|
-
before_create do |doc, schema_name|
|
497
|
-
# [Important] Please change doc destructively.
|
498
|
-
# [Important] To be able to use methods in Rails !
|
499
|
-
doc.merge!({
|
500
|
-
# Something ....
|
501
|
-
})
|
502
|
-
end
|
177
|
+
If specify ruby version `2.6.6` and `2.7.1`
|
503
178
|
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
509
|
-
|
510
|
-
|
511
|
-
|
179
|
+
```bash
|
180
|
+
/bin/bash devscript/all_support_ruby.sh bundle 2.6.6 2.7.1
|
181
|
+
.
|
182
|
+
.
|
183
|
+
.
|
184
|
+
===== Bundle install for All Support Ruby Result =====
|
185
|
+
ruby-2.6.6: 0
|
186
|
+
ruby-2.7.1: 0
|
187
|
+
======================================================
|
512
188
|
```
|
513
189
|
|
514
|
-
|
515
|
-
|
516
|
-
```ruby
|
517
|
-
class CustomComponentsRequestBodyObject < R2OAS::Schema::V3::Components::RequestBodyObject
|
518
|
-
def components_request_body_name(doc, path_component, tag_name, verb, schema_name)
|
519
|
-
# [Important] Please return string.
|
520
|
-
# default
|
521
|
-
schema_name
|
522
|
-
end
|
190
|
+
#### Rspec
|
523
191
|
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
192
|
+
```bash
|
193
|
+
/bin/bash devscript/all_support_ruby.sh rspec
|
194
|
+
.
|
195
|
+
.
|
196
|
+
.
|
197
|
+
===== Rspec for All Support Ruby Result =====
|
198
|
+
ruby-2.3.3: 0
|
199
|
+
ruby-2.4.2: 0
|
200
|
+
ruby-2.5.8: 0
|
201
|
+
ruby-2.6.6: 0
|
202
|
+
ruby-2.7.1: 0
|
203
|
+
=============================================
|
530
204
|
```
|
531
205
|
|
532
|
-
|
206
|
+
If specify ruby version `2.6.6` and `2.7.1`
|
533
207
|
|
534
|
-
```
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
541
|
-
|
542
|
-
|
543
|
-
})
|
544
|
-
end
|
208
|
+
```bash
|
209
|
+
/bin/bash devscript/all_support_ruby.sh rspec 2.6.6 2.7.1
|
210
|
+
.
|
211
|
+
.
|
212
|
+
.
|
213
|
+
===== Rspec for All Support Ruby Result =====
|
214
|
+
ruby-2.6.6: 0
|
215
|
+
ruby-2.7.1: 0
|
216
|
+
=============================================
|
545
217
|
```
|
546
218
|
|
547
|
-
This is the end.
|
548
|
-
|
549
219
|
## 🔩 CORS
|
550
220
|
|
551
221
|
Use [rack-cors](https://github.com/cyu/rack-cors) to enable CORS.
|