r2-oas 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +13 -1
  3. data/Gemfile.lock +85 -70
  4. data/README.ja.md +11 -413
  5. data/README.md +9 -409
  6. data/docs/.nojekyll +0 -0
  7. data/docs/README.md +326 -0
  8. data/docs/_sidebar.md +22 -0
  9. data/docs/index.html +28 -0
  10. data/docs/{versions/v3.md → schema/3.0.0.md} +1 -1
  11. data/docs/setting/COC.md +14 -0
  12. data/docs/setting/CORS.md +22 -0
  13. data/docs/setting/configure.md +163 -0
  14. data/docs/{HOW_TO_ANALYZE_DOCS.md → usage/analyze_docs.md} +8 -8
  15. data/docs/usage/clean_docs.md +19 -0
  16. data/docs/{HOW_TO_DEPLOY_SWAGGER_DOC.md → usage/deploy_docs.md} +8 -8
  17. data/docs/{HOW_TO_DISPLAY_PATHS_LIST.md → usage/display_paths_list.md} +15 -8
  18. data/docs/{HOW_TO_DISPLAY_PATHS_STATS.md → usage/display_paths_stats.md} +15 -14
  19. data/docs/{HOW_TO_START_SWAGGER_EDITOR.md → usage/edit_docs.md} +10 -10
  20. data/docs/{HOW_TO_GENERATE_DOCS.md → usage/generate_docs.md} +9 -9
  21. data/docs/{HOW_TO_MONITOR_SWAGGER_DOC.md → usage/monitor_docs.md} +9 -9
  22. data/docs/usage/use_hook_methods.md +236 -0
  23. data/docs/{HOW_TO_USE_HOOK_WHEN_GENERATE_DOC.md → usage/use_hook_to_generate_docs.md} +6 -15
  24. data/docs/{HOW_TO_USE_SCHEMA_NAMESPACE.md → usage/use_schema_namespace.md} +16 -9
  25. data/docs/{HOW_TO_USE_TAG_NAMESPACE.md → usage/use_tag_namespace.md} +22 -16
  26. data/docs/{HOW_TO_START_SWAGGER_UI.md → usage/view_docs.md} +10 -10
  27. data/lib/r2-oas/app_configuration.rb +19 -16
  28. data/lib/r2-oas/deploy/client.rb +1 -1
  29. data/lib/r2-oas/schema/v3/object/path_item_object.rb +17 -9
  30. data/lib/r2-oas/version.rb +1 -1
  31. data/r2-oas.gemspec +5 -19
  32. metadata +42 -46
  33. data/docs/HOW_TO_CLEAN_DOCS.md +0 -19
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 464bbc729526628547f9d689984b3925eeab1c6b7d2e58ee7a9712f222643f60
4
- data.tar.gz: 808faa249dc984ccf43928188cc139bce945fe7b7e3a296ee336f755cb063315
3
+ metadata.gz: 9eec703f732ad44e2cd37ad10c80bc2a2335a139d2d1e49fb16a8e5a2f74c768
4
+ data.tar.gz: 18757357c5b9958d68e5cbba48e098788f5182d5942b532eb56554204c2df66a
5
5
  SHA512:
6
- metadata.gz: 82f601ac4610d3744422b11f58b9eab7dca668bde7e3da02ef013816d2b2edab6294404d1820579465e0f3a545904f48bb53777f9099d6f462cfd4717b69ab13
7
- data.tar.gz: e12135a40bf94764064b0dc6b42dbe1880e7fd8e536c140fda3241d79fa82671d4f7aef899df287516b3ce2ba0fc7ad2d035196d6ebfc7e3f2a25efad2033930
6
+ metadata.gz: ed60f8a51749c1989332104c4282fb95e1c85cd842893335437d29666ac17217035dd8fcd7db6fbfd7406b3da5e24aa2fc1110e0dd86a6c59fb167163dd23b6b
7
+ data.tar.gz: c2e023025e03f76944a3a9b8459acfd2a18d1c8ca89cbc4a3753d60bc5cc713afabd1a7087e2dddea6ca01fe8b28c644ff1dcf8f477d553332931b7861111a89
@@ -1,3 +1,15 @@
1
+ # Change Log
2
+
3
+ ## v0.1.1
4
+
5
+ 2020-04-22
6
+
7
+ - [`Feature`] Create document by docsify([def4463](https://github.com/yukihirop/r2-oas/pull/99))
8
+ - [`Breaking`] Do not generate component schema when http_status equal 204 and 404 by default ([f7fcafd](https://github.com/yukihirop/r2-oas/pull/103))
9
+
10
+
1
11
  ## v0.1.0
2
12
 
3
- - first release [2019-10-22 / The day of the throne (called 即位礼正殿の儀の行われる日 in Japanease)]
13
+ 2019-10-22 / The day of the throne (called 即位礼正殿の儀の行われる日 in Japanease)
14
+
15
+ - first release
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- r2-oas (0.1.0)
4
+ r2-oas (0.1.2)
5
5
  docker-api (~> 1.34.2)
6
6
  easy_diff (~> 1.0.0)
7
7
  eventmachine (~> 1.2.0)
@@ -13,77 +13,89 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- actioncable (5.2.3)
17
- actionpack (= 5.2.3)
16
+ actioncable (6.0.2.2)
17
+ actionpack (= 6.0.2.2)
18
18
  nio4r (~> 2.0)
19
19
  websocket-driver (>= 0.6.1)
20
- actionmailer (5.2.3)
21
- actionpack (= 5.2.3)
22
- actionview (= 5.2.3)
23
- activejob (= 5.2.3)
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)
24
31
  mail (~> 2.5, >= 2.5.4)
25
32
  rails-dom-testing (~> 2.0)
26
- actionpack (5.2.3)
27
- actionview (= 5.2.3)
28
- activesupport (= 5.2.3)
29
- rack (~> 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)
30
37
  rack-test (>= 0.6.3)
31
38
  rails-dom-testing (~> 2.0)
32
- rails-html-sanitizer (~> 1.0, >= 1.0.2)
33
- actionview (5.2.3)
34
- activesupport (= 5.2.3)
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)
35
48
  builder (~> 3.1)
36
49
  erubi (~> 1.4)
37
50
  rails-dom-testing (~> 2.0)
38
- rails-html-sanitizer (~> 1.0, >= 1.0.3)
39
- activejob (5.2.3)
40
- activesupport (= 5.2.3)
51
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
52
+ activejob (6.0.2.2)
53
+ activesupport (= 6.0.2.2)
41
54
  globalid (>= 0.3.6)
42
- activemodel (5.2.3)
43
- activesupport (= 5.2.3)
44
- activerecord (5.2.3)
45
- activemodel (= 5.2.3)
46
- activesupport (= 5.2.3)
47
- arel (>= 9.0)
48
- activestorage (5.2.3)
49
- actionpack (= 5.2.3)
50
- activerecord (= 5.2.3)
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)
51
64
  marcel (~> 0.3.1)
52
- activesupport (5.2.3)
65
+ activesupport (6.0.2.2)
53
66
  concurrent-ruby (~> 1.0, >= 1.0.2)
54
67
  i18n (>= 0.7, < 2)
55
68
  minitest (~> 5.1)
56
69
  tzinfo (~> 1.1)
57
- arel (9.0.0)
70
+ zeitwerk (~> 2.2)
58
71
  ast (2.4.0)
59
- builder (3.2.3)
60
- childprocess (2.0.0)
61
- rake (< 13.0)
72
+ builder (3.2.4)
73
+ childprocess (3.0.0)
62
74
  coderay (1.1.2)
63
- concurrent-ruby (1.1.5)
75
+ concurrent-ruby (1.1.6)
64
76
  coveralls (0.8.23)
65
77
  json (>= 1.8, < 3)
66
78
  simplecov (~> 0.16.1)
67
79
  term-ansicolor (~> 1.3)
68
80
  thor (>= 0.19.4, < 2.0)
69
81
  tins (~> 1.6)
70
- crass (1.0.4)
82
+ crass (1.0.6)
71
83
  diff-lcs (1.3)
72
84
  docile (1.3.2)
73
85
  docker-api (1.34.2)
74
86
  excon (>= 0.47.0)
75
87
  multi_json
76
88
  easy_diff (1.0.0)
77
- erubi (1.8.0)
89
+ erubi (1.9.0)
78
90
  eventmachine (1.2.7)
79
- excon (0.67.0)
91
+ excon (0.73.0)
80
92
  globalid (0.4.2)
81
93
  activesupport (>= 4.2.0)
82
- i18n (1.6.0)
94
+ i18n (1.8.2)
83
95
  concurrent-ruby (~> 1.0)
84
96
  jaro_winkler (1.5.3)
85
97
  json (2.2.0)
86
- loofah (2.2.3)
98
+ loofah (2.5.0)
87
99
  crass (~> 1.0.2)
88
100
  nokogiri (>= 1.5.9)
89
101
  mail (2.7.1)
@@ -91,51 +103,53 @@ GEM
91
103
  marcel (0.3.3)
92
104
  mimemagic (~> 0.3.2)
93
105
  method_source (0.9.2)
94
- mimemagic (0.3.3)
106
+ mimemagic (0.3.4)
95
107
  mini_mime (1.0.2)
96
108
  mini_portile2 (2.4.0)
97
- minitest (5.12.0)
98
- multi_json (1.13.1)
109
+ minitest (5.14.0)
110
+ multi_json (1.14.1)
99
111
  nio4r (2.5.2)
100
- nokogiri (1.10.4)
112
+ nokogiri (1.10.9)
101
113
  mini_portile2 (~> 2.4.0)
102
- paint (2.1.1)
114
+ paint (2.2.0)
103
115
  parallel (1.17.0)
104
116
  parser (2.6.3.0)
105
117
  ast (~> 2.4.0)
106
118
  pry (0.12.2)
107
119
  coderay (~> 1.1.0)
108
120
  method_source (~> 0.9.0)
109
- rack (2.0.7)
121
+ rack (2.2.2)
110
122
  rack-test (1.1.0)
111
123
  rack (>= 1.0, < 3)
112
- rails (5.2.3)
113
- actioncable (= 5.2.3)
114
- actionmailer (= 5.2.3)
115
- actionpack (= 5.2.3)
116
- actionview (= 5.2.3)
117
- activejob (= 5.2.3)
118
- activemodel (= 5.2.3)
119
- activerecord (= 5.2.3)
120
- activestorage (= 5.2.3)
121
- activesupport (= 5.2.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)
122
136
  bundler (>= 1.3.0)
123
- railties (= 5.2.3)
137
+ railties (= 6.0.2.2)
124
138
  sprockets-rails (>= 2.0.0)
125
139
  rails-dom-testing (2.0.3)
126
140
  activesupport (>= 4.2.0)
127
141
  nokogiri (>= 1.6)
128
- rails-html-sanitizer (1.2.0)
129
- loofah (~> 2.2, >= 2.2.2)
130
- railties (5.2.3)
131
- actionpack (= 5.2.3)
132
- activesupport (= 5.2.3)
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)
133
147
  method_source
134
148
  rake (>= 0.8.7)
135
- thor (>= 0.19.0, < 2.0)
149
+ thor (>= 0.20.3, < 2.0)
136
150
  rainbow (3.0.0)
137
- rake (10.5.0)
138
- regexp_parser (1.6.0)
151
+ rake (13.0.1)
152
+ regexp_parser (1.7.0)
139
153
  rspec (3.8.0)
140
154
  rspec-core (~> 3.8.0)
141
155
  rspec-expectations (~> 3.8.0)
@@ -157,16 +171,16 @@ GEM
157
171
  ruby-progressbar (~> 1.7)
158
172
  unicode-display_width (>= 1.4.0, < 1.7)
159
173
  ruby-progressbar (1.10.1)
160
- rubyzip (1.2.4)
161
- selenium-webdriver (3.142.4)
162
- childprocess (>= 0.5, < 3.0)
163
- rubyzip (~> 1.2, >= 1.2.2)
174
+ rubyzip (2.3.0)
175
+ selenium-webdriver (3.142.7)
176
+ childprocess (>= 0.5, < 4.0)
177
+ rubyzip (>= 1.2.2)
164
178
  simplecov (0.16.1)
165
179
  docile (~> 1.1)
166
180
  json (>= 1.8, < 3)
167
181
  simplecov-html (~> 0.10.0)
168
182
  simplecov-html (0.10.2)
169
- sprockets (3.7.2)
183
+ sprockets (4.0.0)
170
184
  concurrent-ruby (~> 1.0)
171
185
  rack (> 1, < 3)
172
186
  sprockets-rails (3.2.1)
@@ -177,10 +191,10 @@ GEM
177
191
  term-ansicolor (1.7.1)
178
192
  tins (~> 1.0)
179
193
  terminal-table (1.6.0)
180
- thor (0.20.3)
194
+ thor (1.0.1)
181
195
  thread_safe (0.3.6)
182
196
  tins (1.21.1)
183
- tzinfo (1.2.5)
197
+ tzinfo (1.2.7)
184
198
  thread_safe (~> 0.1)
185
199
  unicode-display_width (1.6.0)
186
200
  watir (6.16.5)
@@ -189,6 +203,7 @@ GEM
189
203
  websocket-driver (0.7.1)
190
204
  websocket-extensions (>= 0.1.0)
191
205
  websocket-extensions (0.1.4)
206
+ zeitwerk (2.3.0)
192
207
 
193
208
  PLATFORMS
194
209
  ruby
@@ -198,7 +213,7 @@ DEPENDENCIES
198
213
  coveralls
199
214
  pry
200
215
  r2-oas!
201
- rake (~> 10.0)
216
+ rake (~> 13.0)
202
217
  rspec (~> 3.0)
203
218
  rubocop
204
219
  sqlite3
@@ -4,7 +4,7 @@
4
4
  [![Coverage Status](https://coveralls.io/repos/github/yukihirop/r2-oas/badge.svg)](https://coveralls.io/github/yukihirop/r2-oas)
5
5
  [![Maintainability](https://api.codeclimate.com/v1/badges/f8c3846f350bb412fd63/maintainability)](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
6
6
 
7
- railsのルーティング情報からOpenAPI形式のドキュメントを生成し、閲覧・編集・管理するためのrakeタスクの提供をします。
7
+ Railsのルーティング情報からOpenAPI形式のドキュメントを生成し、閲覧・編集・管理するためのrakeタスクの提供をします。
8
8
 
9
9
  ```bash
10
10
  bundle exec rake routes:oas:docs # ドキュメント生成
@@ -52,90 +52,11 @@ bundle exec routes:oas:docs
52
52
  bundle exec routes:oas:editor
53
53
  ```
54
54
 
55
- ## 📖 Usage
56
-
57
- 全ての設定は `オプショナル` です。設定してもしなくても構いません。
58
-
59
- 設定はrailsプロジェクトの `config/environments/development.rb` に書きます。
55
+ ## 📚 Documents
60
56
 
61
- デフォルトでは以下に設定されています。
57
+ 公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas
62
58
 
63
- ```ruby
64
- # default setting
65
- R2OAS.configure do |config|
66
- config.version = :v3
67
- config.root_dir_path = "./oas_docs"
68
- config.schema_save_dir_name = "src"
69
- config.doc_save_file_name = "oas_doc.yml"
70
- config.force_update_schema = false
71
- config.use_tag_namespace = true
72
- config.use_schema_namespace = false
73
- config.interval_to_save_edited_tmp_schema = 15
74
- # :dot or :underbar
75
- config.namespace_type = :underbar
76
- config.deploy_dir_path = "./deploy_docs"
77
-
78
- config.server.data = [
79
- {
80
- url: "http://localhost:3000",
81
- description: "localhost"
82
- }
83
- ]
84
-
85
- config.swagger.configure do |swagger|
86
- swagger.ui.image = "swaggerapi/swagger-ui"
87
- swagger.ui.port = "8080"
88
- swagger.ui.exposed_port = "8080/tcp"
89
- swagger.ui.volume = "/app/swagger.json"
90
- swagger.editor.image = "swaggerapi/swagger-editor"
91
- swagger.editor.port = "81"
92
- swagger.editor.exposed_port = "8080/tcp"
93
- end
94
-
95
- config.use_object_classes = {
96
- info_object: R2OAS::Schema::V3::InfoObject,
97
- paths_object: R2OAS::Schema::V3::PathsObject,
98
- path_item_object: R2OAS::Schema::V3::PathItemObject,
99
- external_document_object: R2OAS::Schema::V3::ExternalDocumentObject,
100
- components_object: R2OAS::Schema::V3::ComponentsObject,
101
- components_schema_object: R2OAS::Schema::V3::Components::SchemaObject,
102
- components_request_body_object: R2OAS::Schema::V3::Components::RequestBodyObject
103
- }
104
-
105
- config.http_statuses_when_http_method = {
106
- get: {
107
- default: %w(200 422),
108
- path_parameter: %w(200 404 422)
109
- },
110
- post: {
111
- default: %w(201 422),
112
- path_parameter: %w(201 404 422)
113
- },
114
- patch: {
115
- default: %w(204 422),
116
- path_parameter: %w(204 404 422)
117
- },
118
- put: {
119
- default: %w(204 422),
120
- path_parameter: %w(204 404 422)
121
- },
122
- delete: {
123
- default: %w(200 422),
124
- path_parameter: %w(200 404 422)
125
- }
126
- }
127
-
128
- config.http_methods_when_generate_request_body = %w[post patch put]
129
-
130
- config.tool.paths_stats.configure do |paths_stats|
131
- paths_stats.month_to_turn_to_warning_color = 3
132
- paths_stats.warning_color = :red
133
- paths_stats.table_title_color = :yellow
134
- paths_stats.heading_color = :yellow
135
- paths_stats.highlight_color = :magenta
136
- end
137
- end
138
- ```
59
+ ## 📖 Usage
139
60
 
140
61
  railsプロジェクトのルートディレクトリで以下のコマンドが実行可能です。
141
62
 
@@ -170,21 +91,6 @@ $ bundle exec rake routes:oas:paths_ls
170
91
  $ bundle exec rake routes:oas:paths_stats
171
92
  ```
172
93
 
173
- ## 📚 More Usage
174
-
175
- - [How to generate docs](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_GENERATE_DOCS.md)
176
- - [How to start swagger editor](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_START_SWAGGER_EDITOR.md)
177
- - [How to start swagger ui](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_START_SWAGGER_UI.md)
178
- - [How to monitor swagger document](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_MONITOR_SWAGGER_DOC.md)
179
- - [How to analyze docs](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_ANALYZE_DOCS.md)
180
- - [How to clean docs](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_CLEAN_DOCS.md)
181
- - [How to deploy swagger doc](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_DEPLOY_SWAGGER_DOC.md)
182
- - [How to use tag namespace](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_USE_TAG_NAMESPACE.md)
183
- - [How to use schema namespace](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_USE_SCHEMA_NAMESPACE.md)
184
- - [How to use hook when generate doc](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_USE_HOOK_WHEN_GENERATE_DOC.md)
185
- - [How to display paths list](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_DISPLAY_PATHS_LIST.md)
186
- - [How to display paths stats](https://github.com/yukihirop/r2-oas/blob/master/docs/HOW_TO_DISPLAY_PATHS_STATS.md)
187
-
188
94
 
189
95
  ## ⚾️ sample
190
96
 
@@ -210,11 +116,11 @@ $ bundle exec rake routes:oas:paths_stats
210
116
 
211
117
  ## ❤️ Support OpenAPI Schema
212
118
 
213
- |version|document|
214
- |-------|--------|
215
- |v3|[versions/v3.md](https://github.com/yukihirop/r2-oas/blob/master/docs/versions/v3.md)|
119
+ OpenAPIの3.0.0をサポートしてます。
120
+
121
+ 公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/schema/3.0.0
216
122
 
217
- ## ❗️ Convention over Configuration (CoC)
123
+ ## ❗️Convention over Configuration (CoC)
218
124
 
219
125
  ツールを便利にするために、設定よりも制約があります。
220
126
 
@@ -231,323 +137,15 @@ $ bundle exec rake routes:oas:paths_stats
231
137
 
232
138
  ## ⚙ Configure
233
139
 
234
- 設定可能な設定に関して説明します。
235
-
236
- #### basic
237
-
238
- |option|description|default|
239
- |------|-----------|---|
240
- |version|OpenAPIのバージョン| `:v3` |
241
- |root_dir_path|ドキュメントの保存パス| `"./oas_docs"` |
242
- |schema_save_dir_name|分解したスキーマの保存ディレクトリ名|`"src"`|
243
- |doc_save_file_name|生成したドキュメントのファイル名|`"oas_doc.yml"`|
244
- |force_update_schema|既生のドキュメントをルーティング情報から生成されたデータで更新するか否か|`false`|
245
- |use_tag_namespace|タグ名にネームスペースを使うか否か|`true`|
246
- |use_schema_namespace|components/{schemas,requestBodies}名に擬似ネームスペースを利用するか否か|`true`|
247
- |interval_to_save_edited_tmp_schema|SwaggerEditor上で編集されたドキュメントをメモリに保存する間隔(sec)|`15`|
248
- |http_statuses_when_http_method|HTTPメソッド毎にどのHTTPステータスのレスポンスを用意するかを決める設定|omission...|
249
- |http_methods_when_generate_request_body|リクエストボディーを生成する時のHTTPメソッド|`[post put patch]`|
250
- |namespace_type|components/{schemas,requestBodies,...}名で使用する擬似ネームスペースの種類(:dot or :underbar)| `:underbar` |
251
- |deploy_dir_path|deployのディレクトリパス|`"./deploy_docs"`|
252
-
253
- #### server
254
-
255
- |option|children option|description|default|
256
- |------|---------------|-----------|-------|
257
- |server|data|サーバー情報(url, description) |[{ url: `http://localhost:3000`, description: `localhost` }] |
258
-
259
- #### swagger
260
-
261
- |option|children option|grandchild option|description|default|
262
- |------|---------------|-----------------|-----------|-------|
263
- |swagger|ui|image|SwaggerUIのDockerイメージ|`"swaggerapi/swagger-ui"`|
264
- |swagger|ui|port|SwaggerUIのポート|`"8080"`|
265
- |swagger|ui|exposed_port|SwaggerUIの公開ポート|`"8080/tcp"`|
266
- |swagger|ui|volume|SwaggerUIのVolume|`"/app/swagger.json"`|
267
- |swagger|editor|image|SwaggerEditorのDockerイメージ|`"swaggerapi/swagger-editor"`|
268
- |swagger|editor|port|SwaggerEditorのポート|`"8080"`|
269
- |swagger|editor|exposed_port|SwaggerEditorの公開ポート|`"8080/tcp"`|
270
-
271
- #### hook
272
-
273
- |option|description|default|
274
- |------|-----------|-------|
275
- |use_object_classes|ドキュメント生成時に使用するオブジェクトクラスの設定|{ 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` }|
276
-
277
- #### tool
278
-
279
- |option|children option|grandchild option|description|default|
280
- |------|---------------|-----------------|-----------|-------|
281
- |tool|paths_stats|month_to_turn_to_warning_color|警告色を表示するまでの期間(ヶ月)|`3`|
282
- |tool|paths_stats|warning_color|警告色|`:red`|
283
- |tool|paths_stats|table_title_color|テーブルのタイトルの色|`:yellow`|
284
- |tool|paths_stats|heading_color|ヘッダーの色|`:yellow`|
285
- |tool|paths_stats|highlight_color|強調色|`:magenta`|
286
-
287
- Please refer to [here](https://github.com/janlelis/paint) for the color.
288
-
289
- ## Environment variables
290
-
291
- 環境変数は以下を用意しております。
292
-
293
- |variable|description|default|
294
- |--------|-----------|-------|
295
- |PATHS_FILE|pathsファイルのパス|`""`|
296
- |OAS_FILE|analyzeするドキュメントへのパス|`""`|
297
-
298
-
299
- ## .paths
300
-
301
- `.paths` ファイルを書くことで必要な分だけドキュメントを閲覧・編集・配布する事が可能になります。
302
-
303
- `#` から始まる行はコメントとして扱われ無視されます。重複も無視されます。
304
-
305
- `paths` ディレクトリ以下のパスを書きます。
140
+ 全ての設定は `オプショナル` です。設定してもしなくても構いません。
306
141
 
307
- `oas_docs/.paths`
308
- ```
309
- #account_user_role.yml # ignore
310
- account.yml
311
- account.yml # ignore
312
- account.yml # ignore
313
- ```
142
+ 公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/setting/configure
314
143
 
315
144
  ## 💊 Life Cycle Methods (Hook Metohds)
316
145
 
317
146
  ドキュメント生成時に、フックを可能にするメソッドを用意しております。
318
147
 
319
- - `before_create`
320
- - `after_create`
321
-
322
- フック可能なオブジェクトは以下の通りです。
323
-
324
- - `R2OAS::Schema::V3::InfoObject`
325
- - `R2OAS::Schema::V3::PathsObject`
326
- - `R2OAS::Schema::V3::PathItemObject`
327
- - `R2OAS::Schema::V3::ExternalDocumentObject`
328
- - `R2OAS::Schema::V3::ComponentsObject`
329
- - `R2OAS::Schema::V3::Components::SchemaObject`
330
- - `R2OAS::Schema::V3::Components::RequestBodyObject`
331
-
332
- これらのクラスを継承して、フックの設定を書きます。以下に例を用意しました。
333
-
334
- #### case: InfoObject
335
-
336
- ```ruby
337
- class CustomInfoObject < R2OAS::Schema::V3::InfoObject
338
- before_create do |doc|
339
- # [重要] docへの破壊的な変更をしてください。
340
- # [重要] railsが提供するメソッドを使用する事ができます。
341
- doc.merge!({
342
- # Something ....
343
- })
344
- end
345
-
346
- after_create do |doc, path|
347
- # [重要] docへの破壊的な変更をしてください。
348
- # [重要] railsが提供するメソッドを使用する事ができます。
349
- doc.merge!({
350
- # Something ....
351
- })
352
- end
353
- end
354
- ```
355
-
356
- #### case: PathsObject
357
-
358
- ```ruby
359
- class CustomPathsObject < R2OAS::Schema::V3::PathsObject
360
- before_create do |doc|
361
- # [重要] docへの破壊的な変更をしてください。
362
- # [重要] railsが提供するメソッドを使用する事ができます。
363
- doc.merge!({
364
- # Something ....
365
- })
366
- end
367
-
368
- after_create do |doc|
369
- # [重要] docへの破壊的な変更をしてください。
370
- # [重要] railsが提供するメソッドを使用する事ができます。
371
- doc.merge!({
372
- # Something ....
373
- })
374
- end
375
- end
376
- ```
377
-
378
- #### case: PathItemObject
379
-
380
- ```ruby
381
- class CustomPathItemObject < R2OAS::Schema::V3::PathItemObject
382
- before_create do |doc, path|
383
- # [重要] docへの破壊的な変更をしてください。
384
- # [重要] railsが提供するメソッドを使用する事ができます。
385
- doc.merge!({
386
- # Something ....
387
- })
388
- end
389
-
390
- after_create do |doc, schema_name|
391
- # [重要] docへの破壊的な変更をしてください。
392
- # [重要] railsが提供するメソッドを使用する事ができます。
393
- doc.merge!({
394
- # Something ....
395
- })
396
- end
397
- end
398
- ```
399
-
400
- #### case: ExternalDocumentObject
401
-
402
- ```ruby
403
- class CustomExternalDocumentObject < R2OAS::Schema::V3::ExternalDocumentObject
404
- before_create do |doc|
405
- # [重要] docへの破壊的な変更をしてください。
406
- # [重要] railsが提供するメソッドを使用する事ができます。
407
- doc.merge!({
408
- # Something ....
409
- })
410
- end
411
-
412
- after_create do |doc|
413
- # [重要] docへの破壊的な変更をしてください。
414
- # [重要] railsが提供するメソッドを使用する事ができます。
415
- doc.merge!({
416
- # Something ....
417
- })
418
- end
419
- end
420
- ```
421
-
422
- #### case: ComponentsObject
423
-
424
- ```ruby
425
- class CustomComponentsObject < R2OAS::Schema::V3::ComponentsObject
426
- before_create do |doc|
427
- # [重要] docへの破壊的な変更をしてください。
428
- # [重要] railsが提供するメソッドを使用する事ができます。
429
- doc.merge!({
430
- # Something ....
431
- })
432
- end
433
-
434
- after_create do |doc|
435
- # [重要] docへの破壊的な変更をしてください。
436
- # [重要] railsが提供するメソッドを使用する事ができます。
437
- doc.merge!({
438
- # Something ....
439
- })
440
- end
441
- end
442
- ```
443
-
444
- #### case: Components::SchemaObject
445
-
446
- ```ruby
447
- class CustomComponentsSchemaObject < R2OAS::Schema::V3::Components::SchemaObject
448
- before_create do |doc, schema_name|
449
- # [重要] docへの破壊的な変更をしてください。
450
- # [重要] railsが提供するメソッドを使用する事ができます。
451
- doc.merge!({
452
- # Something ....
453
- })
454
- end
455
-
456
- after_create do |doc, schema_name|
457
- # [重要] docへの破壊的な変更をしてください。
458
- # [重要] railsが提供するメソッドを使用する事ができます。
459
- doc.merge!({
460
- # Something ....
461
- })
462
- end
463
- end
464
- ```
465
-
466
- ドキュメント生成時にcomponents/schemas名を上書きしたい場合は以下の様にします。
467
-
468
- ```ruby
469
- class CustomComponentsSchemaObject < R2OAS::Schema::V3::Components::SchemaObject
470
- def components_schema_name(doc, path_component, tag_name, verb, http_status, schema_name)
471
- # [重要] 返値は文字列であるべきです。
472
- # 初期値はschema_name
473
- schema_name
474
- end
475
- end
476
- ```
477
-
478
- `path_component` は `R2OAS::Routing::PathComponent` のインスタンスです。
479
-
480
- ```ruby
481
- module R2OAS
482
- module Routing
483
- class PathComponent < BaseComponent
484
- def initialize(path)
485
- def to_s
486
- def symbol_to_brace
487
- def path_parameters_data
488
- def path_excluded_path_parameters
489
- def exist_path_parameters?
490
- def path_parameters
491
- private
492
- def without_format
493
- ```
494
-
495
- #### case: Components::RequestBodyObject
496
-
497
- ```ruby
498
- class CustomComponentsRequestBodyObject < R2OAS::Schema::V3::Components::RequestBodyObject
499
- before_create do |doc, schema_name|
500
- # [重要] docへの破壊的な変更をしてください。
501
- # [重要] railsが提供するメソッドを使用する事ができます。
502
- doc.merge!({
503
- # Something ....
504
- })
505
- end
506
-
507
- after_create do |doc, schema_name|
508
- # [重要] docへの破壊的な変更をしてください。
509
- # [重要] railsが提供するメソッドを使用する事ができます。
510
- doc.merge!({
511
- # Something ....
512
- })
513
- end
514
- end
515
- ```
516
-
517
- ドキュメント生成時にcomponents/requestBodies名を上書きしたい場合は以下の様にします。
518
-
519
- ```ruby
520
- class CustomComponentsRequestBodyObject < R2OAS::Schema::V3::Components::RequestBodyObject
521
- def components_request_body_name(doc, path_component, tag_name, verb, schema_name)
522
- # [重要] 返値は文字列であるべきです。
523
- # 初期値はschema_name
524
- schema_name
525
- end
526
-
527
- def components_schema_name(doc, path_component, tag_name, verb, schema_name)
528
- # [重要] 返値は文字列であるべきです。
529
- # 初期値はschema_name
530
- schema_name
531
- end
532
- end
533
- ```
534
-
535
- そして最後に設定を書きます。
536
-
537
- ```ruby
538
- # もし、InfoObjectとPathItemObjectをカスタムのものにしたい場合は以下の様にします。
539
- R2OAS.configure do |config|
540
- #
541
- # omission ...
542
- #
543
- config.use_object_classes.merge!({
544
- info_object: CustomInfoObject,
545
- path_item_object: CustomPathItemObject
546
- })
547
- end
548
- ```
549
-
550
- これだけです。
148
+ 公式ドキュメントはこちら => https://yukihirop.github.io/r2-oas/#/usage/use_hook_methods
551
149
 
552
150
  ## 🔩 CORS
553
151