rswag_schema_export 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +60 -37
- data/lib/rswag_schema_export/capistrano.rb +1 -1
- data/lib/rswag_schema_export/client.rb +2 -1
- data/lib/rswag_schema_export/tasks/rswag.rake +7 -8
- data/lib/rswag_schema_export/version.rb +1 -1
- data/lib/tasks/rswag_tasks.rake +10 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ece302cfc94feecbe4036c53b240af0e2fc95d53969f8224a3fd411510f6b6b
|
4
|
+
data.tar.gz: 6d7d15132174d2108961ee218f92bcb53d1f419b874572e186430921cac4d939
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8219a08a4582429b6a1cdbebbc1e02a47268bebe098485b82fea4c82c1e711d480c68002868a896d48a4dec02f7c9574fd7fe9151346abd2a7fb8af6565ba86
|
7
|
+
data.tar.gz: 8ea02fe62ff0def8ca211c22107ce82b3bdd34f90984b637715a392313d23d2d722d59df84055a5c93b5c76d03e71360cc8e9e7b93ceb57549f39ccd55b576b8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
#
|
1
|
+
# Rswag::Schema::Export
|
2
2
|
|
3
3
|
[](https://circleci.com/gh/MLSDev/rswag_schema_export)
|
4
4
|
|
5
5
|
|
6
|
-
Export your schema.json file to AWS
|
6
|
+
Export your schema.json file to **AWS S3**/**Azure Blob** storage and import back after deploy.
|
7
7
|
|
8
8
|
## Installation
|
9
9
|
|
@@ -22,40 +22,73 @@ Or install it yourself as:
|
|
22
22
|
$ gem install rswag_schema_export
|
23
23
|
$ rails g rswag_schema_export:install
|
24
24
|
|
25
|
-
##
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
## Set up
|
26
|
+
```diff
|
27
|
+
# config/initializers/rswag_schema_export.rb
|
28
|
+
RswagSchemaExport.configure do |c|
|
29
|
+
+ c.schemas = ['swagger/client/swagger.json', 'swagger/backoffice/swagger.json']
|
30
|
+
+ c.client = :aws
|
31
|
+
end
|
32
|
+
```
|
33
|
+
## Lifecycle
|
34
|
+
```
|
35
|
+
swaggerize -> export to cloud storage -> deploy -> import from cloud storage
|
36
|
+
```
|
31
37
|
|
32
|
-
##
|
33
|
-
```
|
34
|
-
|
38
|
+
## Export example with CI
|
39
|
+
```yaml
|
40
|
+
.gitlab-ci.yml
|
35
41
|
stages:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
+
- test
|
43
|
+
- export_api_doc
|
44
|
+
- deploy
|
45
|
+
test:
|
46
|
+
tags:
|
47
|
+
- shell-ruby
|
48
|
+
before_script:
|
49
|
+
- RAILS_ENV=test bundle exec rails db:create db:migrate
|
50
|
+
script:
|
51
|
+
- rspec
|
52
|
+
artifacts:
|
53
|
+
paths:
|
54
|
+
- coverage/
|
55
|
+
after_script:
|
56
|
+
- RAILS_ENV=test bundle exec rails db:drop
|
57
|
+
rswag_schema_export:
|
58
|
+
dependencies: []
|
59
|
+
stage: export_api_doc
|
60
|
+
before_script:
|
61
|
+
- RAILS_ENV=test bundle exec rails db:create
|
62
|
+
tags:
|
63
|
+
- shell-ruby
|
64
|
+
script:
|
65
|
+
- rails db:schema:load rswag:specs:swaggerize RAILS_ENV=test
|
66
|
+
- STAGE=develop rails rswag:schema_export
|
67
|
+
develop:
|
68
|
+
dependencies: []
|
69
|
+
stage: deploy
|
70
|
+
tags:
|
71
|
+
- shell-ruby
|
72
|
+
script:
|
73
|
+
- bundle exec cap develop deploy
|
74
|
+
only:
|
75
|
+
- develop
|
42
76
|
```
|
43
77
|
|
44
|
-
|
78
|
+
|
79
|
+
## Import example with Capistrano
|
80
|
+
|
81
|
+
```diff
|
82
|
+
# Capfile
|
83
|
+
require 'rswag_schema_export/capistrano'
|
84
|
+
```
|
45
85
|
|
46
86
|
```diff
|
47
87
|
# config/deploy.rb
|
48
|
-
+
|
49
|
-
namespace :deploy do
|
50
|
-
after :restart, :clear_cache do
|
51
|
-
on roles(:web), in: :groups, limit: 3, wait: 10 do
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
55
|
-
+ after :finishing, 'rswag:schema_import'
|
56
|
-
end
|
88
|
+
+ append :linked_dirs, "swagger"
|
57
89
|
````
|
58
90
|
|
91
|
+
|
59
92
|
## Configuration
|
60
93
|
|
61
94
|
Set up ENVIRONMENT VARIABLES on your CI
|
@@ -82,16 +115,6 @@ APP_NAME='' # Default: app
|
|
82
115
|
|
83
116
|

|
84
117
|
|
85
|
-
## rswag_schema_export
|
86
|
-
```diff
|
87
|
-
# config/initializers/rswag_schema_export.rb
|
88
|
-
RswagSchemaExport.configure do |c|
|
89
|
-
+ c.schemas = ['swagger/client/swagger.json', 'swagger/backoffice/swagger.json']
|
90
|
-
+ c.client = :aws
|
91
|
-
end
|
92
|
-
|
93
|
-
```
|
94
|
-
|
95
118
|
## rswag-api
|
96
119
|
```diff
|
97
120
|
# config/initializers/rswag_api.rb
|
@@ -1 +1 @@
|
|
1
|
-
load File.expand_path("tasks/rswag.rake",
|
1
|
+
load File.expand_path("../tasks/rswag.rake", __FILE__)
|
@@ -52,7 +52,7 @@ module RswagSchemaExport
|
|
52
52
|
def copy_latest_version_to_root(last_schema_key, schema_id)
|
53
53
|
if aws_client?
|
54
54
|
bucket.object(last_schema_key)
|
55
|
-
.copy_to("#{ENV['
|
55
|
+
.copy_to("#{ENV['RSWAG_AWS_BUCKET']}/schemas/#{app_name}/#{stage}_#{schema_id}/schema.json")
|
56
56
|
else
|
57
57
|
client.copy_blob(ENV["RSWAG_AZURE_CONTAINER"], "schemas/#{app_name}/#{stage}_#{schema_id}/schema.json",
|
58
58
|
ENV["RSWAG_AZURE_CONTAINER"], last_schema_key)
|
@@ -60,6 +60,7 @@ module RswagSchemaExport
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def download_file(schema_id, path)
|
63
|
+
FileUtils.mkdir_p(path.split('/')[0...-1].join('/'))
|
63
64
|
if aws_client?
|
64
65
|
bucket.object("schemas/#{app_name}/#{stage}_#{schema_id}/schema.json").download_file(path)
|
65
66
|
else
|
@@ -1,15 +1,14 @@
|
|
1
|
-
require "rswag_schema_export/schema_import"
|
2
|
-
|
3
1
|
namespace :rswag do
|
4
|
-
desc
|
2
|
+
desc 'schema_import'
|
5
3
|
task :schema_import do
|
6
|
-
on roles(:
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
upload!(schema, "#{current_path}/#{schema}")
|
4
|
+
on roles(fetch(:rswag_schema_export_roles, :app)) do
|
5
|
+
within release_path do
|
6
|
+
with rails_env: fetch(:rails_env) do
|
7
|
+
execute :rake, 'rswag:schema_import'
|
11
8
|
end
|
12
9
|
end
|
13
10
|
end
|
14
11
|
end
|
15
12
|
end
|
13
|
+
|
14
|
+
after 'deploy:finishing', 'rswag:schema_import'
|
data/lib/tasks/rswag_tasks.rake
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
namespace :rswag do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
2
|
+
desc "Export schema.json to cloud storage"
|
3
|
+
task schema_export: :environment do
|
4
|
+
RswagSchemaExport::Export.new.run
|
5
|
+
end
|
6
|
+
|
7
|
+
desc "Import latest schema.json to app"
|
8
|
+
task schema_import: :environment do
|
9
|
+
RswagSchemaExport::Import.new.run
|
10
|
+
end
|
11
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rswag_schema_export
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ruslan Tolstov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|