r2-oas 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +7 -0
  2. data/.github/ISSUE_TEMPLATE.md +12 -0
  3. data/.github/PULL_REQUEST_TEMPLATE.md +12 -0
  4. data/.gitignore +12 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +7 -0
  7. data/.rubocop_todo.yml +224 -0
  8. data/.travis.yml +22 -0
  9. data/CHANGELOG.md +3 -0
  10. data/CODE_OF_CONDUCT.md +74 -0
  11. data/Gemfile +12 -0
  12. data/Gemfile.lock +207 -0
  13. data/LICENSE.txt +21 -0
  14. data/README.ja.md +585 -0
  15. data/README.md +582 -0
  16. data/Rakefile +8 -0
  17. data/bin/console +12 -0
  18. data/bin/setup +8 -0
  19. data/docs/HOW_TO_ANALYZE_DOCS.md +875 -0
  20. data/docs/HOW_TO_CLEAN_DOCS.md +19 -0
  21. data/docs/HOW_TO_DEPLOY_SWAGGER_DOC.md +839 -0
  22. data/docs/HOW_TO_DISPLAY_PATHS_LIST.md +28 -0
  23. data/docs/HOW_TO_DISPLAY_PATHS_STATS.md +53 -0
  24. data/docs/HOW_TO_GENERATE_DOCS.md +256 -0
  25. data/docs/HOW_TO_MONITOR_SWAGGER_DOC.md +219 -0
  26. data/docs/HOW_TO_START_SWAGGER_EDITOR.md +218 -0
  27. data/docs/HOW_TO_START_SWAGGER_UI.md +262 -0
  28. data/docs/HOW_TO_USE_HOOK_WHEN_GENERATE_DOC.md +244 -0
  29. data/docs/HOW_TO_USE_SCHEMA_NAMESPACE.md +176 -0
  30. data/docs/HOW_TO_USE_TAG_NAMESPACE.md +176 -0
  31. data/docs/versions/v3.md +155 -0
  32. data/lib/r2-oas.rb +36 -0
  33. data/lib/r2-oas/app_configuration.rb +102 -0
  34. data/lib/r2-oas/app_configuration/server.rb +35 -0
  35. data/lib/r2-oas/app_configuration/swagger.rb +35 -0
  36. data/lib/r2-oas/app_configuration/swagger/editor.rb +47 -0
  37. data/lib/r2-oas/app_configuration/swagger/ui.rb +45 -0
  38. data/lib/r2-oas/app_configuration/tool.rb +31 -0
  39. data/lib/r2-oas/app_configuration/tool/paths/stats.rb +43 -0
  40. data/lib/r2-oas/base.rb +48 -0
  41. data/lib/r2-oas/configuration.rb +69 -0
  42. data/lib/r2-oas/configuration/paths_config.rb +44 -0
  43. data/lib/r2-oas/deploy/client.rb +43 -0
  44. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-16x16.png +0 -0
  45. data/lib/r2-oas/deploy/swagger-ui/dist/favicon-32x32.png +0 -0
  46. data/lib/r2-oas/deploy/swagger-ui/dist/oauth2-redirect.html +68 -0
  47. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js +134 -0
  48. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-bundle.js.map +1 -0
  49. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js +22 -0
  50. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui-standalone-preset.js.map +1 -0
  51. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css +4 -0
  52. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.css.map +1 -0
  53. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js +9 -0
  54. data/lib/r2-oas/deploy/swagger-ui/dist/swagger-ui.js.map +1 -0
  55. data/lib/r2-oas/deploy/swagger-ui/index.html.erb +60 -0
  56. data/lib/r2-oas/errors.rb +7 -0
  57. data/lib/r2-oas/hooks/global_hook.rb +20 -0
  58. data/lib/r2-oas/hooks/hook.rb +77 -0
  59. data/lib/r2-oas/hooks/repository.rb +15 -0
  60. data/lib/r2-oas/logger/stdout_logger.rb +129 -0
  61. data/lib/r2-oas/pluggable_configuration.rb +33 -0
  62. data/lib/r2-oas/plugins/schema/v3/object/hookable_base_object.rb +100 -0
  63. data/lib/r2-oas/routing/adjustor.rb +44 -0
  64. data/lib/r2-oas/routing/base.rb +12 -0
  65. data/lib/r2-oas/routing/components/all.rb +5 -0
  66. data/lib/r2-oas/routing/components/base_component.rb +10 -0
  67. data/lib/r2-oas/routing/components/path_component.rb +67 -0
  68. data/lib/r2-oas/routing/components/request_component.rb +75 -0
  69. data/lib/r2-oas/routing/components/verb_component.rb +21 -0
  70. data/lib/r2-oas/routing/parser.rb +93 -0
  71. data/lib/r2-oas/schema/analyzer.rb +23 -0
  72. data/lib/r2-oas/schema/base.rb +11 -0
  73. data/lib/r2-oas/schema/cleaner.rb +23 -0
  74. data/lib/r2-oas/schema/editor.rb +120 -0
  75. data/lib/r2-oas/schema/generator.rb +23 -0
  76. data/lib/r2-oas/schema/manager/file/path_item_file_manager.rb +24 -0
  77. data/lib/r2-oas/schema/monitor.rb +52 -0
  78. data/lib/r2-oas/schema/squeezer.rb +23 -0
  79. data/lib/r2-oas/schema/ui.rb +74 -0
  80. data/lib/r2-oas/schema/v3/analyzer.rb +58 -0
  81. data/lib/r2-oas/schema/v3/analyzer/base_analyzer.rb +76 -0
  82. data/lib/r2-oas/schema/v3/analyzer/components/object_analyzer.rb +38 -0
  83. data/lib/r2-oas/schema/v3/analyzer/components_analyzer.rb +30 -0
  84. data/lib/r2-oas/schema/v3/analyzer/path_analyzer.rb +116 -0
  85. data/lib/r2-oas/schema/v3/analyzer/tag_analyzer.rb +38 -0
  86. data/lib/r2-oas/schema/v3/base.rb +28 -0
  87. data/lib/r2-oas/schema/v3/cleaner.rb +19 -0
  88. data/lib/r2-oas/schema/v3/cleaner/base_cleaner.rb +30 -0
  89. data/lib/r2-oas/schema/v3/cleaner/components_cleaner.rb +42 -0
  90. data/lib/r2-oas/schema/v3/generator.rb +28 -0
  91. data/lib/r2-oas/schema/v3/generator/base_generator.rb +88 -0
  92. data/lib/r2-oas/schema/v3/generator/components/object_generator.rb +83 -0
  93. data/lib/r2-oas/schema/v3/generator/components/request_body_generator.rb +45 -0
  94. data/lib/r2-oas/schema/v3/generator/components_generator.rb +38 -0
  95. data/lib/r2-oas/schema/v3/generator/doc_generator.rb +49 -0
  96. data/lib/r2-oas/schema/v3/generator/path_generator.rb +90 -0
  97. data/lib/r2-oas/schema/v3/generator/schema_generator.rb +78 -0
  98. data/lib/r2-oas/schema/v3/manager/diff/base_array_diff_manager.rb +60 -0
  99. data/lib/r2-oas/schema/v3/manager/diff/base_diff_manager.rb +29 -0
  100. data/lib/r2-oas/schema/v3/manager/diff/base_hash_diff_manager.rb +95 -0
  101. data/lib/r2-oas/schema/v3/manager/diff/components_diff_manager.rb +19 -0
  102. data/lib/r2-oas/schema/v3/manager/diff/tag_diff_manager.rb +17 -0
  103. data/lib/r2-oas/schema/v3/manager/file/base_file_manager.rb +60 -0
  104. data/lib/r2-oas/schema/v3/manager/file/components_file_manager.rb +22 -0
  105. data/lib/r2-oas/schema/v3/manager/file/include_ref_base_file_manager.rb +88 -0
  106. data/lib/r2-oas/schema/v3/manager/file/path_item_file_manager.rb +22 -0
  107. data/lib/r2-oas/schema/v3/manager/file_manager.rb +12 -0
  108. data/lib/r2-oas/schema/v3/manager/pathname_manager.rb +73 -0
  109. data/lib/r2-oas/schema/v3/object/base_object.rb +65 -0
  110. data/lib/r2-oas/schema/v3/object/components/request_body_object.rb +92 -0
  111. data/lib/r2-oas/schema/v3/object/components/schema_object.rb +55 -0
  112. data/lib/r2-oas/schema/v3/object/components_object.rb +81 -0
  113. data/lib/r2-oas/schema/v3/object/external_document_object.rb +19 -0
  114. data/lib/r2-oas/schema/v3/object/info_object.rb +34 -0
  115. data/lib/r2-oas/schema/v3/object/openapi_object.rb +58 -0
  116. data/lib/r2-oas/schema/v3/object/path_item_object.rb +167 -0
  117. data/lib/r2-oas/schema/v3/object/paths_object.rb +74 -0
  118. data/lib/r2-oas/schema/v3/object/public.rb +9 -0
  119. data/lib/r2-oas/schema/v3/object/server_object.rb +21 -0
  120. data/lib/r2-oas/schema/v3/object/tag_object.rb +36 -0
  121. data/lib/r2-oas/schema/v3/squeezer.rb +29 -0
  122. data/lib/r2-oas/schema/v3/squeezer/base_squeezer.rb +37 -0
  123. data/lib/r2-oas/schema/v3/squeezer/path_squeezer.rb +28 -0
  124. data/lib/r2-oas/schema/v3/squeezer/tag_squeezer.rb +19 -0
  125. data/lib/r2-oas/shared/all.rb +3 -0
  126. data/lib/r2-oas/shared/sortable.rb +23 -0
  127. data/lib/r2-oas/task.rb +11 -0
  128. data/lib/r2-oas/task_logging.rb +39 -0
  129. data/lib/r2-oas/tasks/common.rake +26 -0
  130. data/lib/r2-oas/tasks/main.rake +117 -0
  131. data/lib/r2-oas/tasks/tool.rake +79 -0
  132. data/lib/r2-oas/tool/paths/ls.rb +15 -0
  133. data/lib/r2-oas/tool/paths/stats.rb +84 -0
  134. data/lib/r2-oas/version.rb +5 -0
  135. data/r2-oas.gemspec +56 -0
  136. metadata +373 -0
@@ -0,0 +1,244 @@
1
+ ## BasicUsage
2
+
3
+ `custom_path_item_object.rb`
4
+
5
+ ```ruby
6
+ class CustomPathItemObject < R2OAS::Schema::V3::PathItemObject
7
+
8
+ # [Important] Please change doc destructively.
9
+ before_create do |doc, path|
10
+ # [Important] To be able to use methods in Rails !
11
+ #
12
+ # doc is {}.
13
+ doc.merge!({
14
+ })
15
+ end
16
+
17
+ # [Important] Please change doc destructively.
18
+ after_create do |doc, path|
19
+ # [Important] To be able to use methods in Rails !
20
+
21
+ # For example, doc (style is yaml) is like that:
22
+ # get:
23
+ # tags:
24
+ # - api/v1/post
25
+ # summary: get summary
26
+ # description: get description
27
+ # responses:
28
+ # default:
29
+ # description: ''
30
+ # '200':
31
+ # description: api/v1/post description
32
+ # content:
33
+ # application/json:
34
+ # schema:
35
+ # "$ref": "#/components/schemas/Post"
36
+ # deprecated: false
37
+ #
38
+
39
+ # If you want to merge `sort` query parameters when request is GET api/v1/post.
40
+ if doc['get'].present? && path == 'api/v1/post'
41
+ doc['get'].merge!({
42
+ 'parameters' => {
43
+ 'name' => 'sort',
44
+ 'in' => 'query',
45
+ 'description' => 'option to sort posts',
46
+ 'required' => false,
47
+ 'deprecated' => false
48
+ }
49
+ })
50
+ end
51
+ end
52
+ end
53
+ ```
54
+
55
+ ```ruby
56
+ require_relative 'custom_path_item_object'
57
+
58
+ R2OAS.configure do |config|
59
+ config.root_dir_path = "./oas_docs"
60
+ config.schema_save_dir_name = "src"
61
+ config.doc_save_file_name = "oas_doc.yml"
62
+ config.force_update_schema = false
63
+ config.use_tag_namespace = true
64
+ config.use_schema_namespace = false
65
+ config.server.data = [
66
+ {
67
+ url: "http://localhost:3000",
68
+ description: "localhost"
69
+ }
70
+ ]
71
+ config.interval_to_save_edited_tmp_schema = 15
72
+ config.use_object_classes.merge!({
73
+ path_item_object: CustomPathItemObject
74
+ })
75
+ end
76
+ ```
77
+
78
+ ```bash
79
+ $ bundle exec rake routes:oas:docs
80
+ ```
81
+
82
+ ## Example
83
+
84
+ if there is routing like this:
85
+
86
+ ```
87
+ $ bundle exec rake routes
88
+ Prefix Verb URI Pattern Controller#Action
89
+ rails_admin /admin RailsAdmin::Engine
90
+ api_v2_posts GET /api/v2/posts(.:format) api/v2/posts#index {:format=>:json}
91
+ POST /api/v2/posts(.:format) api/v2/posts#create {:format=>:json}
92
+ new_api_v2_post GET /api/v2/posts/new(.:format) api/v2/posts#new {:format=>:json}
93
+ edit_api_v2_post GET /api/v2/posts/:id/edit(.:format) api/v2/posts#edit {:format=>:json}
94
+ api_v2_post GET /api/v2/posts/:id(.:format) api/v2/posts#show {:format=>:json}
95
+ PATCH /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
96
+ PUT /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
97
+ DELETE /api/v2/posts/:id(.:format) api/v2/posts#destroy {:format=>:json}
98
+ api_v1_posts GET /api/v1/posts(.:format) api/v1/posts#index
99
+ POST /api/v1/posts(.:format) api/v1/posts#create
100
+ new_api_v1_post GET /api/v1/posts/new(.:format) api/v1/posts#new
101
+ edit_api_v1_post GET /api/v1/posts/:id/edit(.:format) api/v1/posts#edit
102
+ api_v1_post GET /api/v1/posts/:id(.:format) api/v1/posts#show
103
+ PATCH /api/v1/posts/:id(.:format) api/v1/posts#update
104
+ PUT /api/v1/posts/:id(.:format) api/v1/posts#update
105
+ DELETE /api/v1/posts/:id(.:format) api/v1/posts#destroy
106
+ api_v1_tasks GET /api/v1/tasks(.:format) api/v1/tasks#index
107
+ POST /api/v1/tasks(.:format) api/v1/tasks#create
108
+ new_api_v1_task GET /api/v1/tasks/new(.:format) api/v1/tasks#new
109
+ edit_api_v1_task GET /api/v1/tasks/:id/edit(.:format) api/v1/tasks#edit
110
+ api_v1_task GET /api/v1/tasks/:id(.:format) api/v1/tasks#show
111
+ PATCH /api/v1/tasks/:id(.:format) api/v1/tasks#update
112
+ PUT /api/v1/tasks/:id(.:format) api/v1/tasks#update
113
+ DELETE /api/v1/tasks/:id(.:format) api/v1/tasks#destroy
114
+ tasks GET /tasks(.:format) tasks#index
115
+ POST /tasks(.:format) tasks#create
116
+ new_task GET /tasks/new(.:format) tasks#new
117
+ edit_task GET /tasks/:id/edit(.:format) tasks#edit
118
+ task GET /tasks/:id(.:format) tasks#show
119
+ PATCH /tasks/:id(.:format) tasks#update
120
+ PUT /tasks/:id(.:format) tasks#update
121
+ DELETE /tasks/:id(.:format) tasks#destroy
122
+ users GET /users(.:format) users#index
123
+ POST /users(.:format) users#create
124
+ new_user GET /users/new(.:format) users#new
125
+ edit_user GET /users/:id/edit(.:format) users#edit
126
+ user GET /users/:id(.:format) users#show
127
+ PATCH /users/:id(.:format) users#update
128
+ PUT /users/:id(.:format) users#update
129
+ DELETE /users/:id(.:format) users#destroy
130
+
131
+ Routes for RailsAdmin::Engine:
132
+ dashboard GET / rails_admin/main#dashboard
133
+ index GET|POST /:model_name(.:format) rails_admin/main#index
134
+ new GET|POST /:model_name/new(.:format) rails_admin/main#new
135
+ export GET|POST /:model_name/export(.:format) rails_admin/main#export
136
+ bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
137
+ bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
138
+ show GET /:model_name/:id(.:format) rails_admin/main#show
139
+ edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
140
+ delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
141
+ show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
142
+ ```
143
+
144
+ #### First try
145
+
146
+ ```
147
+ $ bundle exec rake routes:oas:docs
148
+ I, [2019-06-02T22:12:41.530676 #61323] INFO -- : [R2-OAS] start
149
+ I, [2019-06-02T22:12:41.609492 #61323] INFO -- : [Generate Swagger schema files] start
150
+ I, [2019-06-02T22:12:41.609574 #61323] INFO -- : <From routes data>
151
+ I, [2019-06-02T22:12:41.609591 #61323] INFO -- : <Update schema files>
152
+ I, [2019-06-02T22:12:41.611183 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/openapi.yml
153
+ I, [2019-06-02T22:12:41.611676 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/info.yml
154
+ I, [2019-06-02T22:12:41.612596 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/tags.yml
155
+ I, [2019-06-02T22:12:41.612619 #61323] INFO -- : [Generate Swagger schema files (paths)] start
156
+ I, [2019-06-02T22:12:41.612765 #61323] INFO -- : <From routes data>
157
+ I, [2019-06-02T22:12:41.612782 #61323] INFO -- : <Update schema files (paths)>
158
+ I, [2019-06-02T22:12:41.614701 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/rails_admin/engine.yml
159
+ I, [2019-06-02T22:12:41.618979 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/api/v2/post.yml
160
+ I, [2019-06-02T22:12:41.623081 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/api/v1/post.yml
161
+ I, [2019-06-02T22:12:41.630184 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/api/v1/task.yml
162
+ I, [2019-06-02T22:12:41.633369 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/task.yml
163
+ I, [2019-06-02T22:12:41.636323 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/user.yml
164
+ I, [2019-06-02T22:12:41.642353 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/rails_admin/main.yml
165
+ I, [2019-06-02T22:12:41.642381 #61323] INFO -- : [Generate Swagger schema files (paths)] end
166
+ I, [2019-06-02T22:12:41.642664 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/externalDocs.yml
167
+ I, [2019-06-02T22:12:41.642993 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/servers.yml
168
+ I, [2019-06-02T22:12:41.643015 #61323] INFO -- : [Generate Swagger schema files (components)] start
169
+ I, [2019-06-02T22:12:41.643335 #61323] INFO -- : <From routes data>
170
+ I, [2019-06-02T22:12:41.643421 #61323] INFO -- : <Update Components schema files (components/schemas)>
171
+ I, [2019-06-02T22:12:41.645158 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/engine.yml
172
+ I, [2019-06-02T22:12:41.645613 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/post.yml
173
+ I, [2019-06-02T22:12:41.645987 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/task.yml
174
+ I, [2019-06-02T22:12:41.646443 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/user.yml
175
+ I, [2019-06-02T22:12:41.646833 #61323] INFO -- : Write schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/main.yml
176
+ I, [2019-06-02T22:12:41.646853 #61323] INFO -- : [Generate Swagger schema files (components)] end
177
+ I, [2019-06-02T22:12:41.646865 #61323] INFO -- : [Generate Swagger schema files] end
178
+ I, [2019-06-02T22:12:41.646874 #61323] INFO -- : [Generate Swagger docs from schema files] start
179
+ I, [2019-06-02T22:12:41.647400 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/openapi.yml
180
+ I, [2019-06-02T22:12:41.648404 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/user.yml
181
+ I, [2019-06-02T22:12:41.649983 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/api/v1/task.yml
182
+ I, [2019-06-02T22:12:41.651386 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/api/v1/post.yml
183
+ I, [2019-06-02T22:12:41.652608 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/api/v2/post.yml
184
+ I, [2019-06-02T22:12:41.654068 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/task.yml
185
+ I, [2019-06-02T22:12:41.654754 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/rails_admin/engine.yml
186
+ I, [2019-06-02T22:12:41.658028 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/paths/rails_admin/main.yml
187
+ I, [2019-06-02T22:12:41.658622 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/externalDocs.yml
188
+ I, [2019-06-02T22:12:41.659216 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/tags.yml
189
+ I, [2019-06-02T22:12:41.659715 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/user.yml
190
+ I, [2019-06-02T22:12:41.660165 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/task.yml
191
+ I, [2019-06-02T22:12:41.660528 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/engine.yml
192
+ I, [2019-06-02T22:12:41.660788 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/main.yml
193
+ I, [2019-06-02T22:12:41.661004 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/components/schemas/post.yml
194
+ I, [2019-06-02T22:12:41.661261 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/info.yml
195
+ I, [2019-06-02T22:12:41.661520 #61323] INFO -- : Use schema file: /Users/yukihirop/RubyProjects/r2-oas/oas_docs/src/servers.yml
196
+ I, [2019-06-02T22:12:41.686435 #61323] INFO -- : [Generate Swagger docs from schema files] end
197
+ I, [2019-06-02T22:12:41.686477 #61323] INFO -- : [R2-OAS] end
198
+ ```
199
+
200
+ `oas_docs/schema/paths/api/v1/post` is generated like that:
201
+
202
+ ```diff
203
+ ---
204
+ paths:
205
+ "/api/v1/posts":
206
+ get:
207
+ tags:
208
+ - api/v1/post
209
+ summary: get summary
210
+ description: get description
211
+ responses:
212
+ default:
213
+ description: ''
214
+ '200':
215
+ description: api/v1/post description
216
+ content:
217
+ application/json:
218
+ schema:
219
+ "$ref": "#/components/schemas/Post"
220
+ deprecated: false
221
+ + parameters:
222
+ + - name: sort
223
+ + in: query
224
+ + description: option to sort posts
225
+ + required: false
226
+ + deprecated: false
227
+ post:
228
+ tags:
229
+ - api/v1/post
230
+ summary: post summary
231
+ description: post description
232
+ responses:
233
+ default:
234
+ description: ''
235
+ '200':
236
+ description: api/v1/post description
237
+ content:
238
+ application/json:
239
+ schema:
240
+ "$ref": "#/components/schemas/Post"
241
+ deprecated: false
242
+ ```
243
+
244
+
@@ -0,0 +1,176 @@
1
+ ## Use Schema Namespace (default)
2
+
3
+ ```ruby
4
+
5
+ require 'r2-oas'
6
+
7
+ R2OAS.configure do |config|
8
+ # default setting
9
+ config.root_dir_path = "./oas_docs"
10
+ config.schema_save_dir_name = "src"
11
+ config.doc_save_file_name = "oas_doc.yml"
12
+ # default
13
+ config.use_tag_namespace = true
14
+ config.use_schema_namespace = true # write here
15
+ end
16
+ ```
17
+
18
+ ```bash
19
+ $ bundle exec rake routes:oas:docs
20
+ ```
21
+
22
+ ## Example
23
+
24
+ if there is routing like this:
25
+
26
+ ```
27
+ $ bundle exec rake routes
28
+ Prefix Verb URI Pattern Controller#Action
29
+ rails_admin /admin RailsAdmin::Engine
30
+ api_v2_posts GET /api/v2/posts(.:format) api/v2/posts#index {:format=>:json}
31
+ POST /api/v2/posts(.:format) api/v2/posts#create {:format=>:json}
32
+ new_api_v2_post GET /api/v2/posts/new(.:format) api/v2/posts#new {:format=>:json}
33
+ edit_api_v2_post GET /api/v2/posts/:id/edit(.:format) api/v2/posts#edit {:format=>:json}
34
+ api_v2_post GET /api/v2/posts/:id(.:format) api/v2/posts#show {:format=>:json}
35
+ PATCH /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
36
+ PUT /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
37
+ DELETE /api/v2/posts/:id(.:format) api/v2/posts#destroy {:format=>:json}
38
+ api_v1_posts GET /api/v1/posts(.:format) api/v1/posts#index
39
+ POST /api/v1/posts(.:format) api/v1/posts#create
40
+ new_api_v1_post GET /api/v1/posts/new(.:format) api/v1/posts#new
41
+ edit_api_v1_post GET /api/v1/posts/:id/edit(.:format) api/v1/posts#edit
42
+ api_v1_post GET /api/v1/posts/:id(.:format) api/v1/posts#show
43
+ PATCH /api/v1/posts/:id(.:format) api/v1/posts#update
44
+ PUT /api/v1/posts/:id(.:format) api/v1/posts#update
45
+ DELETE /api/v1/posts/:id(.:format) api/v1/posts#destroy
46
+ api_v1_tasks GET /api/v1/tasks(.:format) api/v1/tasks#index
47
+ POST /api/v1/tasks(.:format) api/v1/tasks#create
48
+ new_api_v1_task GET /api/v1/tasks/new(.:format) api/v1/tasks#new
49
+ edit_api_v1_task GET /api/v1/tasks/:id/edit(.:format) api/v1/tasks#edit
50
+ api_v1_task GET /api/v1/tasks/:id(.:format) api/v1/tasks#show
51
+ PATCH /api/v1/tasks/:id(.:format) api/v1/tasks#update
52
+ PUT /api/v1/tasks/:id(.:format) api/v1/tasks#update
53
+ DELETE /api/v1/tasks/:id(.:format) api/v1/tasks#destroy
54
+ tasks GET /tasks(.:format) tasks#index
55
+ POST /tasks(.:format) tasks#create
56
+ new_task GET /tasks/new(.:format) tasks#new
57
+ edit_task GET /tasks/:id/edit(.:format) tasks#edit
58
+ task GET /tasks/:id(.:format) tasks#show
59
+ PATCH /tasks/:id(.:format) tasks#update
60
+ PUT /tasks/:id(.:format) tasks#update
61
+ DELETE /tasks/:id(.:format) tasks#destroy
62
+ users GET /users(.:format) users#index
63
+ POST /users(.:format) users#create
64
+ new_user GET /users/new(.:format) users#new
65
+ edit_user GET /users/:id/edit(.:format) users#edit
66
+ user GET /users/:id(.:format) users#show
67
+ PATCH /users/:id(.:format) users#update
68
+ PUT /users/:id(.:format) users#update
69
+ DELETE /users/:id(.:format) users#destroy
70
+
71
+ Routes for RailsAdmin::Engine:
72
+ dashboard GET / rails_admin/main#dashboard
73
+ index GET|POST /:model_name(.:format) rails_admin/main#index
74
+ new GET|POST /:model_name/new(.:format) rails_admin/main#new
75
+ export GET|POST /:model_name/export(.:format) rails_admin/main#export
76
+ bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
77
+ bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
78
+ show GET /:model_name/:id(.:format) rails_admin/main#show
79
+ edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
80
+ delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
81
+ show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
82
+ ```
83
+
84
+ <img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/56959813-c1586c80-6b89-11e9-9903-da95d25858f0.png" width="546">
85
+
86
+ Generate like this:
87
+
88
+ ```
89
+ oas_docs
90
+ ├── schema
91
+ │   ├── components
92
+ │   │   └── schemas
93
+ │   │   ├── api
94
+ │   │   │   ├── v1
95
+ │   │   │   │   ├── post.yml
96
+ │   │   │   │   └── task.yml
97
+ │   │   │   └── v2
98
+ │   │   │   └── post.yml
99
+ │   │   ├── rails_admin
100
+ │   │   │   ├── engine.yml
101
+ │   │   │   └── main.yml
102
+ │   │   ├── task.yml
103
+ │   │   └── user.yml
104
+ │   ├── externalDocs.yml
105
+ │   ├── info.yml
106
+ │   ├── openapi.yml
107
+ │   ├── paths
108
+ │   │   ├── api
109
+ │   │   │   ├── v1
110
+ │   │   │   │   ├── post.yml
111
+ │   │   │   │   └── task.yml
112
+ │   │   │   └── v2
113
+ │   │   │   └── post.yml
114
+ │   │   ├── rails_admin
115
+ │   │   │   ├── engine.yml
116
+ │   │   │   └── main.yml
117
+ │   │   ├── task.yml
118
+ │   │   └── user.yml
119
+ │   ├── servers.yml
120
+ │   └── tags.yml
121
+ └── oas_doc.yml
122
+ ```
123
+
124
+ ## Do not Use Tag Namespace
125
+
126
+ ```ruby
127
+
128
+ require 'r2-oas'
129
+
130
+ R2OAS.configure do |config|
131
+ # default setting
132
+ config.root_dir_path = "./oas_docs"
133
+ config.schema_save_dir_name = "src"
134
+ config.doc_save_file_name = "oas_doc.yml"
135
+ config.use_tag_namespace = true
136
+ config.use_schema_namespace = false # write here
137
+ end
138
+ ```
139
+
140
+ ```bash
141
+ $ bundle exec rake routes:oas:docs
142
+ ```
143
+
144
+ <img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/57007768-134ed000-6c26-11e9-9b4e-60f58c78221e.png" width="546">
145
+
146
+ Generate like this:
147
+
148
+ ```
149
+ oas_docs
150
+ ├── schema
151
+ │   ├── components
152
+ │   │   └── schemas
153
+ │   │   ├── engine.yml
154
+ │   │   ├── main.yml
155
+ │   │   ├── post.yml
156
+ │   │   ├── task.yml
157
+ │   │   └── user.yml
158
+ │   ├── externalDocs.yml
159
+ │   ├── info.yml
160
+ │   ├── openapi.yml
161
+ │   ├── paths
162
+ │   │   ├── api
163
+ │   │   │   ├── v1
164
+ │   │   │   │   ├── post.yml
165
+ │   │   │   │   └── task.yml
166
+ │   │   │   └── v2
167
+ │   │   │   └── post.yml
168
+ │   │   ├── rails_admin
169
+ │   │   │   ├── engine.yml
170
+ │   │   │   └── main.yml
171
+ │   │   ├── task.yml
172
+ │   │   └── user.yml
173
+ │   ├── servers.yml
174
+ │   └── tags.yml
175
+ └── oas_doc.yml
176
+ ```
@@ -0,0 +1,176 @@
1
+ ## Use Tag Namespace (default)
2
+
3
+ ```ruby
4
+
5
+ require 'r2-oas'
6
+
7
+ R2OAS.configure do |config|
8
+ # default setting
9
+ config.root_dir_path = "./oas_docs"
10
+ config.schema_save_dir_name = "src"
11
+ config.doc_save_file_name = "oas_doc.yml"
12
+ # default
13
+ config.use_tag_namespace = true # write here
14
+ config.use_schema_namespace = true
15
+ end
16
+ ```
17
+
18
+ ```bash
19
+ $ bundle exec rake routes:oas:docs
20
+ ```
21
+
22
+ ## Example
23
+
24
+ if there is routing like this:
25
+
26
+ ```
27
+ $ bundle exec rake routes
28
+ Prefix Verb URI Pattern Controller#Action
29
+ rails_admin /admin RailsAdmin::Engine
30
+ api_v2_posts GET /api/v2/posts(.:format) api/v2/posts#index {:format=>:json}
31
+ POST /api/v2/posts(.:format) api/v2/posts#create {:format=>:json}
32
+ new_api_v2_post GET /api/v2/posts/new(.:format) api/v2/posts#new {:format=>:json}
33
+ edit_api_v2_post GET /api/v2/posts/:id/edit(.:format) api/v2/posts#edit {:format=>:json}
34
+ api_v2_post GET /api/v2/posts/:id(.:format) api/v2/posts#show {:format=>:json}
35
+ PATCH /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
36
+ PUT /api/v2/posts/:id(.:format) api/v2/posts#update {:format=>:json}
37
+ DELETE /api/v2/posts/:id(.:format) api/v2/posts#destroy {:format=>:json}
38
+ api_v1_posts GET /api/v1/posts(.:format) api/v1/posts#index
39
+ POST /api/v1/posts(.:format) api/v1/posts#create
40
+ new_api_v1_post GET /api/v1/posts/new(.:format) api/v1/posts#new
41
+ edit_api_v1_post GET /api/v1/posts/:id/edit(.:format) api/v1/posts#edit
42
+ api_v1_post GET /api/v1/posts/:id(.:format) api/v1/posts#show
43
+ PATCH /api/v1/posts/:id(.:format) api/v1/posts#update
44
+ PUT /api/v1/posts/:id(.:format) api/v1/posts#update
45
+ DELETE /api/v1/posts/:id(.:format) api/v1/posts#destroy
46
+ api_v1_tasks GET /api/v1/tasks(.:format) api/v1/tasks#index
47
+ POST /api/v1/tasks(.:format) api/v1/tasks#create
48
+ new_api_v1_task GET /api/v1/tasks/new(.:format) api/v1/tasks#new
49
+ edit_api_v1_task GET /api/v1/tasks/:id/edit(.:format) api/v1/tasks#edit
50
+ api_v1_task GET /api/v1/tasks/:id(.:format) api/v1/tasks#show
51
+ PATCH /api/v1/tasks/:id(.:format) api/v1/tasks#update
52
+ PUT /api/v1/tasks/:id(.:format) api/v1/tasks#update
53
+ DELETE /api/v1/tasks/:id(.:format) api/v1/tasks#destroy
54
+ tasks GET /tasks(.:format) tasks#index
55
+ POST /tasks(.:format) tasks#create
56
+ new_task GET /tasks/new(.:format) tasks#new
57
+ edit_task GET /tasks/:id/edit(.:format) tasks#edit
58
+ task GET /tasks/:id(.:format) tasks#show
59
+ PATCH /tasks/:id(.:format) tasks#update
60
+ PUT /tasks/:id(.:format) tasks#update
61
+ DELETE /tasks/:id(.:format) tasks#destroy
62
+ users GET /users(.:format) users#index
63
+ POST /users(.:format) users#create
64
+ new_user GET /users/new(.:format) users#new
65
+ edit_user GET /users/:id/edit(.:format) users#edit
66
+ user GET /users/:id(.:format) users#show
67
+ PATCH /users/:id(.:format) users#update
68
+ PUT /users/:id(.:format) users#update
69
+ DELETE /users/:id(.:format) users#destroy
70
+
71
+ Routes for RailsAdmin::Engine:
72
+ dashboard GET / rails_admin/main#dashboard
73
+ index GET|POST /:model_name(.:format) rails_admin/main#index
74
+ new GET|POST /:model_name/new(.:format) rails_admin/main#new
75
+ export GET|POST /:model_name/export(.:format) rails_admin/main#export
76
+ bulk_delete POST|DELETE /:model_name/bulk_delete(.:format) rails_admin/main#bulk_delete
77
+ bulk_action POST /:model_name/bulk_action(.:format) rails_admin/main#bulk_action
78
+ show GET /:model_name/:id(.:format) rails_admin/main#show
79
+ edit GET|PUT /:model_name/:id/edit(.:format) rails_admin/main#edit
80
+ delete GET|DELETE /:model_name/:id/delete(.:format) rails_admin/main#delete
81
+ show_in_app GET /:model_name/:id/show_in_app(.:format) rails_admin/main#show_in_app
82
+ ```
83
+
84
+ <img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/56959813-c1586c80-6b89-11e9-9903-da95d25858f0.png" width="546">
85
+
86
+ Generate like this:
87
+
88
+ ```
89
+ oas_docs
90
+ ├── schema
91
+ │   ├── components
92
+ │   │   └── schemas
93
+ │   │   ├── api
94
+ │   │   │   ├── v1
95
+ │   │   │   │   ├── post.yml
96
+ │   │   │   │   └── task.yml
97
+ │   │   │   └── v2
98
+ │   │   │   └── post.yml
99
+ │   │   ├── rails_admin
100
+ │   │   │   ├── engine.yml
101
+ │   │   │   └── main.yml
102
+ │   │   ├── task.yml
103
+ │   │   └── user.yml
104
+ │   ├── externalDocs.yml
105
+ │   ├── info.yml
106
+ │   ├── openapi.yml
107
+ │   ├── paths
108
+ │   │   ├── api
109
+ │   │   │   ├── v1
110
+ │   │   │   │   ├── post.yml
111
+ │   │   │   │   └── task.yml
112
+ │   │   │   └── v2
113
+ │   │   │   └── post.yml
114
+ │   │   ├── rails_admin
115
+ │   │   │   ├── engine.yml
116
+ │   │   │   └── main.yml
117
+ │   │   ├── task.yml
118
+ │   │   └── user.yml
119
+ │   ├── servers.yml
120
+ │   └── tags.yml
121
+ └── oas_doc.yml
122
+ ```
123
+
124
+ ## Do not Use Tag Namespace
125
+
126
+ ```ruby
127
+
128
+ require 'r2-oas'
129
+
130
+ R2OAS.configure do |config|
131
+ # default setting
132
+ config.root_dir_path = "./oas_docs"
133
+ config.schema_save_dir_name = "src"
134
+ config.doc_save_file_name = "oas_doc.yml"
135
+ config.use_tag_namespace = false # write here
136
+ config.use_schema_namespace = true
137
+ end
138
+ ```
139
+
140
+ ```bash
141
+ $ bundle exec rake routes:oas:docs
142
+ ```
143
+
144
+ <img alt="swagger_ui" src="https://user-images.githubusercontent.com/11146767/57007590-bdc5f380-6c24-11e9-9aa4-85f2fe97e463.png" width="546">
145
+
146
+ Generate like this:
147
+
148
+ ```
149
+ oas_docs
150
+ ├── schema
151
+ │   ├── components
152
+ │   │   └── schemas
153
+ │   │   ├── api
154
+ │   │   │   ├── v1
155
+ │   │   │   │   ├── post.yml
156
+ │   │   │   │   └── task.yml
157
+ │   │   │   └── v2
158
+ │   │   │   └── post.yml
159
+ │   │   ├── rails_admin
160
+ │   │   │   ├── engine.yml
161
+ │   │   │   └── main.yml
162
+ │   │   ├── task.yml
163
+ │   │   └── user.yml
164
+ │   ├── externalDocs.yml
165
+ │   ├── info.yml
166
+ │   ├── openapi.yml
167
+ │   ├── paths
168
+ │   │   ├── engine.yml
169
+ │   │   ├── main.yml
170
+ │   │   ├── post.yml
171
+ │   │   ├── task.yml
172
+ │   │   └── user.yml
173
+ │   ├── servers.yml
174
+ │   └── tags.yml
175
+ └── oas_doc.yml
176
+ ```