r2-oas 0.2.0 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +41 -0
  3. data/GEMSPEC.md +19 -22
  4. data/README.ja.md +61 -0
  5. data/README.md +60 -0
  6. data/lib/r2-oas.rb +2 -4
  7. data/lib/r2-oas/app_configuration.rb +1 -1
  8. data/lib/r2-oas/deploy/client.rb +33 -6
  9. data/lib/r2-oas/lib/core_ext/hash/deep_merge.rb +44 -0
  10. data/lib/r2-oas/lib/core_ext/object/blank.rb +135 -0
  11. data/lib/r2-oas/schema/editor.rb +13 -2
  12. data/lib/r2-oas/schema/ui.rb +0 -1
  13. data/lib/r2-oas/task_logging.rb +0 -4
  14. data/lib/r2-oas/tasks/common.rake +0 -1
  15. data/lib/r2-oas/tasks/tool.rake +9 -2
  16. data/lib/r2-oas/version.rb +1 -1
  17. data/r2-oas.gemspec +12 -13
  18. metadata +61 -78
  19. data/.github/ISSUE_TEMPLATE.md +0 -12
  20. data/.github/PULL_REQUEST_TEMPLATE.md +0 -12
  21. data/.gitignore +0 -12
  22. data/.rspec +0 -3
  23. data/.rubocop.yml +0 -7
  24. data/.rubocop_todo.yml +0 -249
  25. data/.travis.yml +0 -24
  26. data/CODE_OF_CONDUCT.md +0 -74
  27. data/Gemfile +0 -12
  28. data/Gemfile.lock +0 -224
  29. data/Rakefile +0 -8
  30. data/bin/console +0 -12
  31. data/bin/setup +0 -8
  32. data/docs/.nojekyll +0 -0
  33. data/docs/README.md +0 -173
  34. data/docs/_sidebar.md +0 -23
  35. data/docs/attention/if_clash.md +0 -19
  36. data/docs/index.html +0 -29
  37. data/docs/schema/3.0.0.md +0 -155
  38. data/docs/setting/COC.md +0 -14
  39. data/docs/setting/CORS.md +0 -22
  40. data/docs/setting/configure.md +0 -176
  41. data/docs/usage/analyze_docs.md +0 -875
  42. data/docs/usage/clean_docs.md +0 -19
  43. data/docs/usage/deploy_docs.md +0 -839
  44. data/docs/usage/display_paths_list.md +0 -35
  45. data/docs/usage/display_paths_stats.md +0 -54
  46. data/docs/usage/edit_docs.md +0 -218
  47. data/docs/usage/generate_docs.md +0 -412
  48. data/docs/usage/monitor_docs.md +0 -219
  49. data/docs/usage/use_hook_methods.md +0 -236
  50. data/docs/usage/use_hook_to_generate_docs.md +0 -235
  51. data/docs/usage/use_schema_namespace.md +0 -181
  52. data/docs/usage/use_tag_namespace.md +0 -180
  53. data/docs/usage/view_docs.md +0 -262
  54. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-16x16.png +0 -0
  55. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-32x32.png +0 -0
  56. data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.html +0 -68
  57. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js +0 -134
  58. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js.map +0 -1
  59. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js +0 -22
  60. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js.map +0 -1
  61. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css +0 -4
  62. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css.map +0 -1
  63. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js +0 -9
  64. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js.map +0 -1
@@ -1,219 +0,0 @@
1
- # Monitor docs
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
- ## Command
14
-
15
- ```bash
16
- $ bundle exec rake routes:oas:monitor
17
- ```
18
-
19
- ## Example
20
-
21
- if there is routing like this:
22
-
23
- ```
24
- $ bundle exec rake routes
25
- Prefix Verb URI Pattern Controller#Action
26
- api_v1_account_user_roles GET /api/v1/account_user_roles(.:format) api/v1/account_user_roles#index
27
- new_api_v1_account_user_role GET /api/v1/account_user_roles/new(.:format) api/v1/account_user_roles#new
28
- edit_api_v1_account_user_role GET /api/v1/account_user_roles/:id/edit(.:format) api/v1/account_user_roles#edit
29
- api_v1_account_user_role GET /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#show
30
- PATCH /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#update
31
- PUT /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#update
32
- DELETE /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#destroy
33
- api_v1 POST /api/v1/accounts/:account_id/users(.:format) api/v1/account_user_role#create
34
- api_v1_account_users GET /api/v1/accounts/:account_id/users(.:format) api/v1/users#index
35
- new_api_v1_account_user GET /api/v1/accounts/:account_id/users/new(.:format) api/v1/users#new
36
- edit_api_v1_account_user GET /api/v1/accounts/:account_id/users/:id/edit(.:format) api/v1/users#edit
37
- api_v1_account_user GET /api/v1/accounts/:account_id/users/:id(.:format) api/v1/users#show
38
- PATCH /api/v1/accounts/:account_id/users/:id(.:format) api/v1/users#update
39
- PUT /api/v1/accounts/:account_id/users/:id(.:format) api/v1/users#update
40
- DELETE /api/v1/accounts/:account_id/users/:id(.:format) api/v1/users#destroy
41
- api_v1_accounts GET /api/v1/accounts(.:format) api/v1/accounts#index
42
- POST /api/v1/accounts(.:format) api/v1/accounts#create
43
- new_api_v1_account GET /api/v1/accounts/new(.:format) api/v1/accounts#new
44
- edit_api_v1_account GET /api/v1/accounts/:id/edit(.:format) api/v1/accounts#edit
45
- api_v1_account GET /api/v1/accounts/:id(.:format) api/v1/accounts#show
46
- PATCH /api/v1/accounts/:id(.:format) api/v1/accounts#update
47
- PUT /api/v1/accounts/:id(.:format) api/v1/accounts#update
48
- DELETE /api/v1/accounts/:id(.:format) api/v1/accounts#destroy
49
- GET /api/v1/account_user_roles(.:format) api/v1/account_user_roles#index
50
- POST /api/v1/account_user_roles(.:format) api/v1/account_user_roles#create
51
- GET /api/v1/account_user_roles/new(.:format) api/v1/account_user_roles#new
52
- GET /api/v1/account_user_roles/:id/edit(.:format) api/v1/account_user_roles#edit
53
- GET /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#show
54
- PATCH /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#update
55
- PUT /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#update
56
- DELETE /api/v1/account_user_roles/:id(.:format) api/v1/account_user_roles#destroy
57
- api_v1_users GET /api/v1/users(.:format) api/v1/users#index
58
- POST /api/v1/users(.:format) api/v1/users#create
59
- new_api_v1_user GET /api/v1/users/new(.:format) api/v1/users#new
60
- edit_api_v1_user GET /api/v1/users/:id/edit(.:format) api/v1/users#edit
61
- api_v1_user GET /api/v1/users/:id(.:format) api/v1/users#show
62
- PATCH /api/v1/users/:id(.:format) api/v1/users#update
63
- PUT /api/v1/users/:id(.:format) api/v1/users#update
64
- DELETE /api/v1/users/:id(.:format) api/v1/users#destroy
65
- GET /api/v1/accounts(.:format) api/v1/accounts#index
66
- POST /api/v1/accounts(.:format) api/v1/accounts#create
67
- GET /api/v1/accounts/new(.:format) api/v1/accounts#new
68
- GET /api/v1/accounts/:id/edit(.:format) api/v1/accounts#edit
69
- GET /api/v1/accounts/:id(.:format) api/v1/accounts#show
70
- PATCH /api/v1/accounts/:id(.:format) api/v1/accounts#update
71
- PUT /api/v1/accounts/:id(.:format) api/v1/accounts#update
72
- DELETE /api/v1/accounts/:id(.:format) api/v1/accounts#destroy
73
- api_v2_custom_posts GET /api/v2/custom_posts(.:format) api/v2/custom_posts#index
74
- POST /api/v2/custom_posts(.:format) api/v2/custom_posts#create
75
- new_api_v2_custom_post GET /api/v2/custom_posts/new(.:format) api/v2/custom_posts#new
76
- edit_api_v2_custom_post GET /api/v2/custom_posts/:id/edit(.:format) api/v2/custom_posts#edit
77
- api_v2_custom_post GET /api/v2/custom_posts/:id(.:format) api/v2/custom_posts#show
78
- PATCH /api/v2/custom_posts/:id(.:format) api/v2/custom_posts#update
79
- PUT /api/v2/custom_posts/:id(.:format) api/v2/custom_posts#update
80
- DELETE /api/v2/custom_posts/:id(.:format) api/v2/custom_posts#destroy
81
- rails_subadmin /subadmin RailsAdmin::Engine
82
- rails_admin /admin RailsAdmin::Engine
83
- api_v2_posts GET /api/v2/posts(.:format) api/v2/posts#index {: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
- GET /api/v2/custom_posts(.:format) api/v2/custom_posts#index {:format=>:json}
89
- GET /api/v2/custom_posts/:id/edit(.:format) api/v2/custom_posts#edit {:format=>:json}
90
- GET /api/v2/custom_posts/:id(.:format) api/v2/custom_posts#show {:format=>:json}
91
- PATCH /api/v2/custom_posts/:id(.:format) api/v2/custom_posts#update {:format=>:json}
92
- PUT /api/v2/custom_posts/:id(.:format) api/v2/custom_posts#update {:format=>:json}
93
- POST /api/v2/posts(.:format) api/v2/custom_posts#create {:format=>:json}
94
- api_v1_posts GET /api/v1/posts(.:format) api/v1/posts#index
95
- POST /api/v1/posts(.:format) api/v1/posts#create
96
- new_api_v1_post GET /api/v1/posts/new(.:format) api/v1/posts#new
97
- edit_api_v1_post GET /api/v1/posts/:id/edit(.:format) api/v1/posts#edit
98
- api_v1_post GET /api/v1/posts/:id(.:format) api/v1/posts#show
99
- PATCH /api/v1/posts/:id(.:format) api/v1/posts#update
100
- PUT /api/v1/posts/:id(.:format) api/v1/posts#update
101
- DELETE /api/v1/posts/:id(.:format) api/v1/posts#destroy
102
- api_v1_tasks GET /api/v1/tasks(.:format) api/v1/tasks#index
103
- POST /api/v1/tasks(.:format) api/v1/tasks#create
104
- new_api_v1_task GET /api/v1/tasks/new(.:format) api/v1/tasks#new
105
- edit_api_v1_task GET /api/v1/tasks/:id/edit(.:format) api/v1/tasks#edit
106
- api_v1_task GET /api/v1/tasks/:id(.:format) api/v1/tasks#show
107
- PATCH /api/v1/tasks/:id(.:format) api/v1/tasks#update
108
- PUT /api/v1/tasks/:id(.:format) api/v1/tasks#update
109
- DELETE /api/v1/tasks/:id(.:format) api/v1/tasks#destroy
110
- tasks GET /tasks(.:format) tasks#index
111
- POST /tasks(.:format) tasks#create
112
- new_task GET /tasks/new(.:format) tasks#new
113
- edit_task GET /tasks/:id/edit(.:format) tasks#edit
114
- task GET /tasks/:id(.:format) tasks#show
115
- PATCH /tasks/:id(.:format) tasks#update
116
- PUT /tasks/:id(.:format) tasks#update
117
- DELETE /tasks/:id(.:format) tasks#destroy
118
- users GET /users(.:format) users#index
119
- POST /users(.:format) users#create
120
- new_user GET /users/new(.:format) users#new
121
- edit_user GET /users/:id/edit(.:format) users#edit
122
- user GET /users/:id(.:format) users#show
123
- PATCH /users/:id(.:format) users#update
124
- PUT /users/:id(.:format) users#update
125
- DELETE /users/:id(.:format) users#destroy
126
-
127
- Routes for RailsAdmin::Engine:
128
- dashboard GET / rails_admin/main#dashboard
129
- index GET|POST /:model_name(.:format) rails_admin/main#index
130
- new GET|POST /:model_name/new(.:format) rails_admin/main#new
131
- export GET|POST /:model_name/export(.:format) rails_admin/main#export
132
- bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
133
- bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
134
- show GET /:model_name/:id(.:format) rails_admin/main#show
135
- edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
136
- delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
137
- show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
138
- ```
139
-
140
- #### VS Code
141
-
142
- If you use [Swagger Viewer](https://marketplace.visualstudio.com/items?itemName=Arjun.swagger-viewer)
143
-
144
- <img alt="swagger_editor" src="https://user-images.githubusercontent.com/11146767/60355006-75e70100-9a08-11e9-9f52-dfacb681791e.png" width="546">
145
-
146
- ```
147
- I, [2019-06-29T00:52:29.568306 #16277] INFO -- : [R2-OAS] start
148
- I, [2019-06-29T00:52:29.857556 #16277] INFO -- : [Build OAS schema files] start
149
- I, [2019-06-29T00:52:29.857599 #16277] INFO -- : [Build OAS schema files] end
150
- I, [2019-06-29T00:52:29.857609 #16277] INFO -- : [Build OAS docs from schema files] start
151
- I, [2019-06-29T00:52:29.858201 #16277] INFO -- : Use schema file: oas_docs/src/openapi.yml
152
- I, [2019-06-29T00:52:29.859837 #16277] INFO -- : Use schema file: oas_docs/src/paths/user.yml
153
- I, [2019-06-29T00:52:29.861592 #16277] INFO -- : Use schema file: oas_docs/src/paths/api/v1/account_user_role.yml
154
- I, [2019-06-29T00:52:29.865069 #16277] INFO -- : Use schema file: oas_docs/src/paths/api/v1/user.yml
155
- I, [2019-06-29T00:52:29.866911 #16277] INFO -- : Use schema file: oas_docs/src/paths/api/v1/account.yml
156
- I, [2019-06-29T00:52:29.868569 #16277] INFO -- : Use schema file: oas_docs/src/paths/api/v1/task.yml
157
- I, [2019-06-29T00:52:29.869994 #16277] INFO -- : Use schema file: oas_docs/src/paths/api/v1/post.yml
158
- I, [2019-06-29T00:52:29.871558 #16277] INFO -- : Use schema file: oas_docs/src/paths/api/v2/custom_post.yml
159
- I, [2019-06-29T00:52:29.872561 #16277] INFO -- : Use schema file: oas_docs/src/paths/api/v2/post.yml
160
- I, [2019-06-29T00:52:29.873925 #16277] INFO -- : Use schema file: oas_docs/src/paths/task.yml
161
- I, [2019-06-29T00:52:29.874329 #16277] INFO -- : Use schema file: oas_docs/src/paths/rails_admin/engine.yml
162
- I, [2019-06-29T00:52:29.877551 #16277] INFO -- : Use schema file: oas_docs/src/paths/rails_admin/main.yml
163
- I, [2019-06-29T00:52:29.877670 #16277] INFO -- : Use schema file: oas_docs/src/externalDocs.yml
164
- I, [2019-06-29T00:52:29.878309 #16277] INFO -- : Use schema file: oas_docs/src/tags.yml
165
- I, [2019-06-29T00:52:29.878477 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/account_user_role.yml
166
- I, [2019-06-29T00:52:29.878635 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/custom_post.yml
167
- I, [2019-06-29T00:52:29.878778 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/user/new/200/get.yml
168
- I, [2019-06-29T00:52:29.878955 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/user.yml
169
- I, [2019-06-29T00:52:29.879127 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/account.yml
170
- I, [2019-06-29T00:52:29.879270 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/task.yml
171
- I, [2019-06-29T00:52:29.879441 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/engine.yml
172
- I, [2019-06-29T00:52:29.879621 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/main.yml
173
- I, [2019-06-29T00:52:29.879767 #16277] INFO -- : Use schema file: oas_docs/src/components/schemas/post.yml
174
- I, [2019-06-29T00:52:29.879960 #16277] INFO -- : Use schema file: oas_docs/src/info.yml
175
- I, [2019-06-29T00:52:29.880072 #16277] INFO -- : Use schema file: oas_docs/src/servers.yml
176
- I, [2019-06-29T00:52:29.926654 #16277] INFO -- : [Build OAS docs from schema files] end
177
-
178
- wait for single trap ...
179
- ```
180
-
181
- When you press `Ctrl + C` after edit schema ,
182
-
183
- ```
184
- ^C
185
- ^CI, [2019-06-29T00:55:38.492337 #16277] INFO -- : [Analyze OAS file] start
186
- I, [2019-06-29T00:55:38.494113 #16277] INFO -- : [Analyze OAS file (paths)] start
187
- I, [2019-06-29T00:55:38.503677 #16277] INFO -- : Write schema file: oas_docs/src/paths/rails_admin/main.yml
188
- I, [2019-06-29T00:55:38.504894 #16277] INFO -- : Write schema file: oas_docs/src/paths/rails_admin/engine.yml
189
- I, [2019-06-29T00:55:38.509686 #16277] INFO -- : Write schema file: oas_docs/src/paths/api/v1/account_user_role.yml
190
- I, [2019-06-29T00:55:38.522787 #16277] INFO -- : Write schema file: oas_docs/src/paths/api/v1/account.yml
191
- I, [2019-06-29T00:55:38.532995 #16277] INFO -- : Write schema file: oas_docs/src/paths/api/v1/user.yml
192
- I, [2019-06-29T00:55:38.537879 #16277] INFO -- : Write schema file: oas_docs/src/paths/api/v1/post.yml
193
- I, [2019-06-29T00:55:38.542680 #16277] INFO -- : Write schema file: oas_docs/src/paths/api/v1/task.yml
194
- I, [2019-06-29T00:55:38.548333 #16277] INFO -- : Write schema file: oas_docs/src/paths/api/v2/custom_post.yml
195
- I, [2019-06-29T00:55:38.552802 #16277] INFO -- : Write schema file: oas_docs/src/paths/api/v2/post.yml
196
- I, [2019-06-29T00:55:38.560056 #16277] INFO -- : Write schema file: oas_docs/src/paths/task.yml
197
- I, [2019-06-29T00:55:38.566850 #16277] INFO -- : Write schema file: oas_docs/src/paths/user.yml
198
- I, [2019-06-29T00:55:38.566886 #16277] INFO -- : [Analyze OAS file (paths)] end
199
- I, [2019-06-29T00:55:38.567852 #16277] INFO -- : [Analyze OAS file (tags)] start
200
- I, [2019-06-29T00:55:38.569655 #16277] INFO -- : Write schema file: oas_docs/src/tags.yml
201
- I, [2019-06-29T00:55:38.569691 #16277] INFO -- : [Analyze OAS file (tags)] end
202
- I, [2019-06-29T00:55:38.569708 #16277] INFO -- : [Analyze OAS file (components)] start
203
- I, [2019-06-29T00:55:38.569724 #16277] INFO -- : [Analyze OAS file (components/schemas)] start
204
- I, [2019-06-29T00:55:38.570894 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/account.yml
205
- I, [2019-06-29T00:55:38.571540 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/account_user_role.yml
206
- I, [2019-06-29T00:55:38.572217 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/custom_post.yml
207
- I, [2019-06-29T00:55:38.573028 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/engine.yml
208
- I, [2019-06-29T00:55:38.573710 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/main.yml
209
- I, [2019-06-29T00:55:38.574328 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/post.yml
210
- I, [2019-06-29T00:55:38.575088 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/task.yml
211
- I, [2019-06-29T00:55:38.575687 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/user.yml
212
- I, [2019-06-29T00:55:38.576485 #16277] INFO -- : Write schema file: oas_docs/src/components/schemas/user/new/200/get.yml
213
- I, [2019-06-29T00:55:38.576518 #16277] INFO -- : [Analyze OAS file (components/schemas)] end
214
- I, [2019-06-29T00:55:38.576535 #16277] INFO -- : [Analyze OAS file (components/requestBodies)] start
215
- I, [2019-06-29T00:55:38.576852 #16277] INFO -- : [Analyze OAS file (components/requestBodies)] end
216
- I, [2019-06-29T00:55:38.576867 #16277] INFO -- : [Analyze OAS file (components)] end
217
- I, [2019-06-29T00:55:38.580873 #16277] INFO -- : [Analyze OAS file] end
218
- I, [2019-06-29T00:55:38.587586 #16277] INFO -- : [R2-OAS] end
219
- ```
@@ -1,236 +0,0 @@
1
- # Use hook methods
2
-
3
- Supported hook(life cycle methods) is like this:
4
-
5
- - `before_create`
6
- - `after_create`
7
-
8
- Supported Hook class is like this:
9
-
10
- - `R2OAS::Schema::V3::InfoObject`
11
- - `R2OAS::Schema::V3::PathsObject`
12
- - `R2OAS::Schema::V3::PathItemObject`
13
- - `R2OAS::Schema::V3::ExternalDocumentObject`
14
- - `R2OAS::Schema::V3::ComponentsObject`
15
- - `R2OAS::Schema::V3::Components::SchemaObject`
16
- - `R2OAS::Schema::V3::Components::RequestBodyObject`
17
-
18
- By inheriting these classes, you can hook them at the time of document generation by writing like this:
19
-
20
- #### case: InfoObject
21
-
22
- ```ruby
23
- class CustomInfoObject < R2OAS::Schema::V3::InfoObject
24
- before_create do |doc|
25
- # [Important] Please change doc destructively.
26
- # [Important] To be able to use methods in Rails !
27
- doc.merge!({
28
- # Something ....
29
- })
30
- end
31
-
32
- after_create do |doc, path|
33
- # [Important] Please change doc destructively.
34
- # [Important] To be able to use methods in Rails !
35
- doc.merge!({
36
- # Something ....
37
- })
38
- end
39
- end
40
- ```
41
-
42
- #### case: PathsObject
43
-
44
- ```ruby
45
- class CustomPathsObject < R2OAS::Schema::V3::PathsObject
46
- before_create do |doc|
47
- # [Important] Please change doc destructively.
48
- # [Important] To be able to use methods in Rails !
49
- doc.merge!({
50
- # Something ....
51
- })
52
- end
53
-
54
- after_create do |doc|
55
- # [Important] Please change doc destructively.
56
- # [Important] To be able to use methods in Rails !
57
- doc.merge!({
58
- # Something ....
59
- })
60
- end
61
- end
62
- ```
63
-
64
- #### case: PathItemObject
65
-
66
- ```ruby
67
- class CustomPathItemObject < R2OAS::Schema::V3::PathItemObject
68
- before_create do |doc, path|
69
- # [Important] Please change doc destructively.
70
- # [Important] To be able to use methods in Rails !
71
- doc.merge!({
72
- # Something ....
73
- })
74
- end
75
-
76
- after_create do |doc, schema_name|
77
- # [Important] Please change doc destructively.
78
- # [Important] To be able to use methods in Rails !
79
- doc.merge!({
80
- # Something ....
81
- })
82
- end
83
- end
84
- ```
85
-
86
- #### case: ExternalDocumentObject
87
-
88
- ```ruby
89
- class CustomExternalDocumentObject < R2OAS::Schema::V3::ExternalDocumentObject
90
- before_create do |doc|
91
- # [Important] Please change doc destructively.
92
- # [Important] To be able to use methods in Rails !
93
- doc.merge!({
94
- # Something ....
95
- })
96
- end
97
-
98
- after_create do |doc|
99
- # [Important] Please change doc destructively.
100
- # [Important] To be able to use methods in Rails !
101
- doc.merge!({
102
- # Something ....
103
- })
104
- end
105
- end
106
- ```
107
-
108
- #### case: ComponentsObject
109
-
110
- ```ruby
111
- class CustomComponentsObject < R2OAS::Schema::V3::ComponentsObject
112
- before_create do |doc|
113
- # [Important] Please change doc destructively.
114
- # [Important] To be able to use methods in Rails !
115
- doc.merge!({
116
- # Something ....
117
- })
118
- end
119
-
120
- after_create do |doc|
121
- # [Important] Please change doc destructively.
122
- # [Important] To be able to use methods in Rails !
123
- doc.merge!({
124
- # Something ....
125
- })
126
- end
127
- end
128
- ```
129
-
130
- #### case: Components::SchemaObject
131
-
132
- ```ruby
133
- class CustomComponentsSchemaObject < R2OAS::Schema::V3::Components::SchemaObject
134
- before_create do |doc, schema_name|
135
- # [Important] Please change doc destructively.
136
- # [Important] To be able to use methods in Rails !
137
- doc.merge!({
138
- # Something ....
139
- })
140
- end
141
-
142
- after_create do |doc, schema_name|
143
- # [Important] Please change doc destructively.
144
- # [Important] To be able to use methods in Rails !
145
- doc.merge!({
146
- # Something ....
147
- })
148
- end
149
- end
150
- ```
151
-
152
- If you want to determine the component schema name at runtime, like this:
153
-
154
- ```ruby
155
- class CustomComponentsSchemaObject < R2OAS::Schema::V3::Components::SchemaObject
156
- def components_schema_name(doc, path_component, tag_name, verb, http_status, schema_name)
157
- # [Important] Please return string.
158
- # default
159
- schema_name
160
- end
161
- end
162
- ```
163
-
164
- `path_component` is `R2OAS::Routing::PathComponent` instance.
165
-
166
- ```ruby
167
- module R2OAS
168
- module Routing
169
- class PathComponent < BaseComponent
170
- def initialize(path)
171
- def to_s
172
- def symbol_to_brace
173
- def path_parameters_data
174
- def path_excluded_path_parameters
175
- def exist_path_parameters?
176
- def path_parameters
177
- private
178
- def without_format
179
- ```
180
-
181
- #### case: Components::RequestBodyObject
182
-
183
- ```ruby
184
- class CustomComponentsRequestBodyObject < R2OAS::Schema::V3::Components::RequestBodyObject
185
- before_create do |doc, schema_name|
186
- # [Important] Please change doc destructively.
187
- # [Important] To be able to use methods in Rails !
188
- doc.merge!({
189
- # Something ....
190
- })
191
- end
192
-
193
- after_create do |doc, schema_name|
194
- # [Important] Please change doc destructively.
195
- # [Important] To be able to use methods in Rails !
196
- doc.merge!({
197
- # Something ....
198
- })
199
- end
200
- end
201
- ```
202
-
203
- If you want to determine the component schema name at runtime, like this:
204
-
205
- ```ruby
206
- class CustomComponentsRequestBodyObject < R2OAS::Schema::V3::Components::RequestBodyObject
207
- def components_request_body_name(doc, path_component, tag_name, verb, schema_name)
208
- # [Important] Please return string.
209
- # default
210
- schema_name
211
- end
212
-
213
- def components_schema_name(doc, path_component, tag_name, verb, schema_name)
214
- # [Important] Please return string.
215
- # default
216
- schema_name
217
- end
218
- end
219
- ```
220
-
221
- And write this to the configuration.
222
-
223
- ```ruby
224
- # If only InfoObject and PathItemObject, use a custom class
225
- R2OAS.configure do |config|
226
- #
227
- # omission ...
228
- #
229
- config.use_object_classes.merge!({
230
- info_object: CustomInfoObject,
231
- path_item_object: CustomPathItemObject
232
- })
233
- end
234
- ```
235
-
236
- This is the end.