r2-oas 0.2.0 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
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
data/Rakefile DELETED
@@ -1,8 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
8
- task default: :spec
@@ -1,12 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'bundler/setup'
5
- require 'r2-oas'
6
-
7
- # You can add fixtures and/or initialization code here to make experimenting
8
- # with your gem easier. You can also use a different console, if you like.
9
-
10
- # (If you use this, don't forget to add pry to your Gemfile!)
11
- require 'pry'
12
- Pry.start
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
File without changes
@@ -1,173 +0,0 @@
1
- # R2-OAS
2
-
3
- [![Gem Version](https://badge.fury.io/rb/r2-oas.svg)](https://badge.fury.io/rb/r2-oas)
4
- [![Build Status](https://travis-ci.org/yukihirop/r2-oas.svg?branch=master)](https://travis-ci.org/yukihirop/r2-oas)
5
- [![Coverage Status](https://coveralls.io/repos/github/yukihirop/r2-oas/badge.svg)](https://coveralls.io/github/yukihirop/r2-oas)
6
- [![Maintainability](https://api.codeclimate.com/v1/badges/f8c3846f350bb412fd63/maintainability)](https://codeclimate.com/github/yukihirop/r2-oas/maintainability)
7
-
8
- Generate api docment(OpenAPI) side only from `Rails` routing.
9
-
10
- Provides a rake command to help `generate` , `view` , and `edit` OpenAPI documents.
11
-
12
- ```bash
13
- bundle exec rake routes:oas:docs # generate
14
- bundle exec rake routes:oas:ui # view
15
- bundle exec rake routes:oas:editor # edit
16
- bundle exec rake routes:oas:monitor # monitor
17
- bundle exec rake routes:oas:dist # distribute
18
- bundle exec rake routes:oas:clean # clean
19
- bundle exec rake routes:oas:analyze # analyze
20
- bundle exec rake routes:oas:deploy # deploy
21
- ```
22
-
23
- ## 💎 Installation
24
-
25
- Add this line to your application's Gemfile:
26
-
27
- ```ruby
28
- group :development do
29
- gem 'r2-oas'
30
- end
31
- ```
32
-
33
- And then execute:
34
-
35
- $ bundle
36
-
37
- Or install it yourself as:
38
-
39
- $ gem install r2-oas
40
-
41
- ## 🔦 Requirements
42
-
43
- If you want to view with `Swagger UI` or edit with `Swagger Editor`, This gem needs the following:
44
-
45
- - [`swaggerapi/swagger-ui:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-ui/)
46
- - [`swaggerapi/swagger-editor:latest` docker image](https://hub.docker.com/r/swaggerapi/swagger-editor/)
47
- - [`chromedriver`](http://chromedriver.chromium.org/downloads)
48
-
49
- If you do not have it download as below.
50
-
51
- ```
52
- $ docker pull swaggerapi/swagger-editor:latest
53
- $ docker pull swaggerapi/swagger-ui:latest
54
- $ brew cask install chromedriver
55
- ```
56
-
57
- ## 🚀 Tutorial
58
-
59
- After requiring a gem,
60
-
61
- ```bash
62
- bundle exec routes:oas:docs
63
- bundle exec routes:oas:editor
64
- ```
65
-
66
- #### Generate docs
67
-
68
- ![oas_docs](https://user-images.githubusercontent.com/11146767/80856236-0b839a80-8c83-11ea-888f-d0e659e0c251.gif)
69
-
70
-
71
- #### Edit docs
72
-
73
- ![oas_editor](https://user-images.githubusercontent.com/11146767/80856240-15a59900-8c83-11ea-9dbd-4382528944f2.gif)
74
-
75
- ## 📖 Usage
76
-
77
-
78
- You can execute the following command in the root directory of rails.
79
-
80
- ```bash
81
- $ # Generate docs
82
- $ bundle exec rake routes:oas:docs # Generate docs
83
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:docs # Generate docs by specify unit paths
84
-
85
- $ # Start swagger editor
86
- $ bundle exec rake routes:oas:editor # Start swagger editor
87
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:editor # Start swagger editor by specify unit paths
88
- $ # Start swagger ui
89
- $ bundle exec rake routes:oas:ui # Start swagger ui
90
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:ui # Start swagger ui by specify unit paths
91
- $ # Monitor swagger document
92
- $ bundle exec rake routes:oas:monitor # Monitor swagger document
93
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:monitor # Monitor swagger by specify unit paths
94
-
95
- $ # Analyze docs
96
- $ OAS_FILE="~/Desktop/swagger.yml" bundle exec rake routes:oas:analyze
97
- $ # Clean docs
98
- $ bundle exec rake routes:oas:clean
99
- $ # Deploy docs
100
- $ bundle exec rake routes:oas:deploy
101
- $ # Distribute swagger document
102
- $ bundle exec rake routes:oas:dist
103
- $ # Distribute swagger document
104
- $ PATHS_FILE="oas_docs/schema/paths/api/v1/task.yml" bundle exec rake routes:oas:dist # Distribute swagger document by specify unit paths
105
-
106
- # Display paths list
107
- $ bundle exec rake routes:oas:paths_ls
108
- # Display paths stats
109
- $ bundle exec rake routes:oas:paths_stats
110
- ```
111
-
112
- ## ❤️ Support Rails Version
113
-
114
- - Rails (>= 4.2.5.1)
115
-
116
- ## ❤️ Support Ruby Version
117
-
118
- - Ruby (>= 2.3.3p222 (2016-11-21 revision 56859) [x86_64-darwin18])
119
-
120
- ## ❤️ Support Rouging
121
-
122
- - Rails Engine Routing
123
- - Rails Normal Routing
124
-
125
- ## ❗️ Convention over Configuration (CoC)
126
-
127
- - `tag name` represents `controller name` and determine `paths file name`.
128
- - For example, If `controller name` is `Api::V1::UsersController`, `tag_name` is `api/v1/user`. and `paths file name` is `api/v1/user.yml`
129
-
130
- - `_` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
131
- - For example, If `components/schemas name` is `Api_V1_User`, `components/schemas file name` is `api/v1/user.yml`.
132
- - `_` is supposed to be used to express `namespace`.
133
- - format is `Namespace1_Namespace2_Model`.
134
-
135
- - `.` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
136
- - For example, If `components/schemas name` is `api.v1.User`, `components/schemas file name` is `api/v1/user.yml`.
137
- - `.` is supposed to be used to express `namespace`.
138
- - format is `namespace1.namespace2.Model`.
139
-
140
- ## 🔩 CORS
141
-
142
- Use [rack-cors](https://github.com/cyu/rack-cors) to enable CORS.
143
-
144
- ```ruby
145
- require 'rack/cors'
146
- use Rack::Cors do
147
- allow do
148
- origins '*'
149
- resource '*', headers: :any, methods: [ :get, :post, :put, :delete, :options ]
150
- end
151
- end
152
- ```
153
-
154
- Alternatively you can set CORS headers in a `before` block.
155
-
156
- ```ruby
157
- before do
158
- header['Access-Control-Allow-Origin'] = '*'
159
- header['Access-Control-Request-Method'] = '*'
160
- end
161
- ```
162
-
163
- ## 📝 License
164
-
165
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
166
-
167
- ## 🤝 Contributing
168
-
169
- 1. Fork it ( http://github.com/yukihirop/r2-oas/fork )
170
- 2. Create your feature branch (`git checkout -b my-new-feature`)
171
- 3. Commit your changes (`git commit -am 'Add some feature'`)
172
- 4. Push to the branch (`git push origin my-new-feature`)
173
- 5. Create new Pull Request
@@ -1,23 +0,0 @@
1
- <!-- docs/_sidebar.md -->
2
- * **Attention**
3
- * [If Clash](/attention/if_clash)
4
- * **Usage**
5
- * [Generate Docs](/usage/generate_docs)
6
- * [Edit docs](/usage/edit_docs)
7
- * [View docs](/usage/view_docs)
8
- * [Monitor Docs](/usage/monitor_docs)
9
- * [Analyze Docs](/usage/analyze_docs)
10
- * [Use Hook to Generate Docs](/usage/use_hook_to_generate_docs)
11
- * [Use schema namespace](/usage/use_schema_namespace)
12
- * [Use tag namespace](/usage/use_tag_namespace)
13
- * [Use hook methods](/usage/use_hook_methods)
14
- * [Deploy docs](/usage/deploy_docs)
15
- * [Clean Docs](/usage/clean_docs)
16
- * [Display Paths Lists](/usage/display_paths_list)
17
- * [Display Paths Stats](/usage/display_paths_stats)
18
- * **Configure**
19
- * [COC](/setting/COC)
20
- * [Configure](/setting/configure)
21
- * [CORS](/setting/CORS)
22
- * **Support Schema**
23
- * [3.0.0](/schema/3.0.0)
@@ -1,19 +0,0 @@
1
- # If clash
2
-
3
- Unfortunately, if you do the paste operation with Swagger Editor running, it may occasionally crash.
4
-
5
- f you crash while Swagger Editor is running, you can execute the following command to reflect the editing status up to a few seconds before in the local file.
6
-
7
- ```bash
8
- bundle exec rake routes:oas:analyze
9
- ```
10
-
11
- It is a file generated by parsing the generated file oas_doc.yml and dividing it into each file.
12
-
13
- ## Attention
14
-
15
- Please be aware that if you execute the following command immediately after the crash, the change history will be `lost`.
16
-
17
- ```bash
18
- bundle exec rake routes:oas:editor
19
- ```
@@ -1,29 +0,0 @@
1
- <!DOCTYPE html>
2
- <html lang="en">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>Document</title>
6
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
7
- <meta name="description" content="Description">
8
- <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
9
- <link rel="stylesheet" href="//unpkg.com/docsify/lib/themes/vue.css">
10
- </head>
11
- <body>
12
- <div id="app"></div>
13
- <script>
14
- window.$docsify = {
15
- auto2top: true,
16
- name: '<span>r2-oas</span>',
17
- repo: 'https://github.com/yukihirop/r2-oas',
18
- loadSidebar: true,
19
- subMaxLevel: 2
20
- }
21
- </script>
22
- <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
23
- <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
24
- <script src="//unpkg.com/docsify/lib/plugins/emoji.min.js"></script>
25
- <script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-ruby.min.js"></script>
26
- <script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-bash.min.js"></script>
27
- <script src="//cdn.jsdelivr.net/npm/prismjs/components/prism-diff.min.js"></script>
28
- </body>
29
- </html>
@@ -1,155 +0,0 @@
1
- # 3.0.0
2
-
3
- ## Support Schema
4
-
5
- Generate schema yaml like this:
6
-
7
- - Schema
8
- - openapi
9
- - info
10
- - tags
11
- - paths
12
- - externalDocs
13
- - servers
14
- - security
15
- - components
16
- - schemas
17
- - requestBodies
18
- - securitySchemes
19
- - parameters
20
- - responses (experimental)
21
- - examples (experimental)
22
- - headers (experimental)
23
- - links (experimental)
24
- - callbacks (experimental)
25
-
26
- ## openapi
27
-
28
- Support field like this:
29
-
30
- |field name|field type|
31
- |----------|----------|
32
- |`openapi`|`string`|
33
-
34
- [show more...](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#openapi-object)
35
-
36
- ## info
37
-
38
- Support field like this:
39
-
40
- |field name|field type|
41
- |----------|----------|
42
- |`title`|`string`|
43
- |`description`|`string`|
44
- |`termsOfService`|`string`|
45
- |`contact`|`Contact Object`|
46
- |`license`|`License Object`|
47
- |`version`|`string`|
48
-
49
- [show more...](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#info-object)
50
-
51
- ## tags
52
-
53
- Support field like this:
54
-
55
- |field name|field type|
56
- |----------|----------|
57
- |`name`|`string`|
58
- |`description`|`string`|
59
- |`externalDocs`|`External Document Object`|
60
-
61
- [show more...](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#tagObject)
62
-
63
- ## paths
64
-
65
- Support field like this:
66
-
67
- |field name|field type|
68
- |----------|----------|
69
- |`/{path}`|`Path Item Object`|
70
-
71
- [show more...](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#paths-object)
72
-
73
- for example:
74
- ```
75
- paths:
76
- "/users":
77
- post:
78
- tags:
79
- - user
80
- summary: post summary
81
- description: post description
82
- responses:
83
- default:
84
- description: ''
85
- deprecated: false
86
- "/{model_name}/{id}":
87
- get:
88
- tags:
89
- - rails_admin/main
90
- summary: get summary
91
- description: get description
92
- responses:
93
- default:
94
- description: ''
95
- '200':
96
- description: rails_admin/main description
97
- content:
98
- application/json:
99
- schema:
100
- "$ref": "#/components/schemas/Main"
101
- deprecated: false
102
- parameters:
103
- - name: model_name
104
- in: path
105
- description: model_name
106
- required: true
107
- schema:
108
- type: string
109
- - name: id
110
- in: path
111
- description: id
112
- required: true
113
- schema:
114
- type: integer
115
- ```
116
-
117
- ## externalDocs
118
-
119
- Support field like this:
120
-
121
- |field name|field type|
122
- |----------|----------|
123
- |`description`|`string`|
124
- |`url`|`string`|
125
-
126
- [show more...](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#external-documentation-object)
127
-
128
- ## servers
129
-
130
- Support field like this:
131
-
132
- |field name|field type|
133
- |----------|----------|
134
- |`url`|`string`|
135
- |`description`|`string`|
136
-
137
- [show more...](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#server-object)
138
-
139
- ## components
140
-
141
- Support field like this:
142
-
143
- |field name|field type|
144
- |----------|----------|
145
- |`schemas`| `Schema Object` |
146
- |`requestBodies`| `Request Body Object`|
147
- |`securitySchemes`| `Security Schemes Object` |
148
- |`parameters`| `Parameter Object` |
149
- |`responses`| `Response Object` |
150
- |`examples`| `Example Object` |
151
- |`headers`| `Header Object` |
152
- |`links`|`Link Object` |
153
- |`callbacks`| `Callback Object`|
154
-
155
- [show more...](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#components-object)
@@ -1,14 +0,0 @@
1
- # ❗️Convention over Configuration (CoC)
2
-
3
- - `tag name` represents `controller name` and determine `paths file name`.
4
- - For example, If `controller name` is `Api::V1::UsersController`, `tag_name` is `api/v1/user`. and `paths file name` is `api/v1/user.yml`
5
-
6
- - `_` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
7
- - For example, If `components/schemas name` is `Api_V1_User`, `components/schemas file name` is `api/v1/user.yml`.
8
- - `_` is supposed to be used to express `namespace`.
9
- - format is `Namespace1_Namespace2_Model`.
10
-
11
- - `.` of `components/{schemas,requestBodies, ...} name` convert `/` when save file.
12
- - For example, If `components/schemas name` is `api.v1.User`, `components/schemas file name` is `api/v1/user.yml`.
13
- - `.` is supposed to be used to express `namespace`.
14
- - format is `namespace1.namespace2.Model`.