rswag_schema_export 0.2.4 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +6 -0
- data/Gemfile.lock +63 -50
- data/README.md +7 -0
- data/lib/rswag_schema_export.rb +3 -0
- data/lib/rswag_schema_export/differ.rb +31 -0
- data/lib/rswag_schema_export/schema_import.rb +17 -0
- data/lib/rswag_schema_export/tasks/rswag.rake +1 -1
- data/lib/rswag_schema_export/version.rb +1 -1
- data/rswag_schema_export.gemspec +5 -3
- metadata +38 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f24a3d058e7de831bcb2c6d757e9c222a4c31b74ccf60bb40b78921c966cc047
|
4
|
+
data.tar.gz: e99c297dcdc2fa906d63218234996aea66cfe802f64e882c4f00371775ef3980
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec81ef26bf39543e9a25b7bae9a18ebc24f4057b1fa0523ae5d1ee6fac8dab961c2f78c0d76e43fad73e45633a81cfeb6fac1dcc87af68912217cca2aab07135
|
7
|
+
data.tar.gz: 79e0648d094184b35b966f64d03934ddffac74b8815fa82e23ebb6eac50eb83c7d54865c647487016ec1942059933ac87b31490f77b11dc3fcd93b89f74cfbcc
|
data/.circleci/config.yml
CHANGED
@@ -10,6 +10,12 @@ jobs:
|
|
10
10
|
keys:
|
11
11
|
- rswag_schema_export-{{ checksum "Gemfile.lock" }}
|
12
12
|
- rswag_schema_export-
|
13
|
+
- run:
|
14
|
+
name: Configure Bundler
|
15
|
+
command: |
|
16
|
+
echo 'export BUNDLER_VERSION=$(cat Gemfile.lock | tail -1 | tr -d " ")' >> $BASH_ENV
|
17
|
+
source $BASH_ENV
|
18
|
+
gem install bundler:2.0.2
|
13
19
|
|
14
20
|
- run:
|
15
21
|
name: install dependencies
|
data/Gemfile.lock
CHANGED
@@ -1,44 +1,49 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
rswag_schema_export (0.
|
4
|
+
rswag_schema_export (0.3.0)
|
5
5
|
aws-sdk-s3 (~> 1)
|
6
6
|
azure-storage-blob (~> 1.1)
|
7
|
+
slack-notifier (~> 2.3.2)
|
8
|
+
swagger-diff (~> 1.1.2)
|
7
9
|
|
8
10
|
GEM
|
9
11
|
remote: https://rubygems.org/
|
10
12
|
specs:
|
11
|
-
actionpack (
|
12
|
-
actionview (=
|
13
|
-
activesupport (=
|
13
|
+
actionpack (6.0.1)
|
14
|
+
actionview (= 6.0.1)
|
15
|
+
activesupport (= 6.0.1)
|
14
16
|
rack (~> 2.0)
|
15
17
|
rack-test (>= 0.6.3)
|
16
18
|
rails-dom-testing (~> 2.0)
|
17
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
18
|
-
actionview (
|
19
|
-
activesupport (=
|
19
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
20
|
+
actionview (6.0.1)
|
21
|
+
activesupport (= 6.0.1)
|
20
22
|
builder (~> 3.1)
|
21
23
|
erubi (~> 1.4)
|
22
24
|
rails-dom-testing (~> 2.0)
|
23
|
-
rails-html-sanitizer (~> 1.
|
24
|
-
activesupport (
|
25
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
26
|
+
activesupport (6.0.1)
|
25
27
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
26
28
|
i18n (>= 0.7, < 2)
|
27
29
|
minitest (~> 5.1)
|
28
30
|
tzinfo (~> 1.1)
|
31
|
+
zeitwerk (~> 2.2)
|
32
|
+
addressable (2.7.0)
|
33
|
+
public_suffix (>= 2.0.2, < 5.0)
|
29
34
|
ast (2.4.0)
|
30
35
|
aws-eventstream (1.0.3)
|
31
|
-
aws-partitions (1.
|
32
|
-
aws-sdk-core (3.
|
36
|
+
aws-partitions (1.251.0)
|
37
|
+
aws-sdk-core (3.84.0)
|
33
38
|
aws-eventstream (~> 1.0, >= 1.0.2)
|
34
|
-
aws-partitions (~> 1.0)
|
39
|
+
aws-partitions (~> 1, >= 1.239.0)
|
35
40
|
aws-sigv4 (~> 1.1)
|
36
41
|
jmespath (~> 1.0)
|
37
|
-
aws-sdk-kms (1.
|
38
|
-
aws-sdk-core (~> 3, >= 3.
|
42
|
+
aws-sdk-kms (1.26.0)
|
43
|
+
aws-sdk-core (~> 3, >= 3.71.0)
|
39
44
|
aws-sigv4 (~> 1.1)
|
40
|
-
aws-sdk-s3 (1.
|
41
|
-
aws-sdk-core (~> 3, >= 3.
|
45
|
+
aws-sdk-s3 (1.59.0)
|
46
|
+
aws-sdk-core (~> 3, >= 3.83.0)
|
42
47
|
aws-sdk-kms (~> 1)
|
43
48
|
aws-sigv4 (~> 1.1)
|
44
49
|
aws-sigv4 (1.1.0)
|
@@ -57,64 +62,67 @@ GEM
|
|
57
62
|
builder (3.2.3)
|
58
63
|
coderay (1.1.2)
|
59
64
|
concurrent-ruby (1.1.5)
|
60
|
-
crass (1.0.
|
65
|
+
crass (1.0.5)
|
61
66
|
diff-lcs (1.3)
|
62
67
|
docile (1.3.2)
|
63
|
-
erubi (1.
|
64
|
-
faraday (0.
|
68
|
+
erubi (1.9.0)
|
69
|
+
faraday (0.17.1)
|
65
70
|
multipart-post (>= 1.2, < 3)
|
66
71
|
faraday_middleware (0.13.1)
|
67
72
|
faraday (>= 0.7.4, < 1.0)
|
68
|
-
i18n (1.
|
73
|
+
i18n (1.7.0)
|
69
74
|
concurrent-ruby (~> 1.0)
|
70
|
-
jaro_winkler (1.5.
|
75
|
+
jaro_winkler (1.5.4)
|
71
76
|
jmespath (1.4.0)
|
72
77
|
json (2.2.0)
|
73
|
-
|
78
|
+
json-schema (2.8.1)
|
79
|
+
addressable (>= 2.4)
|
80
|
+
loofah (2.3.1)
|
74
81
|
crass (~> 1.0.2)
|
75
82
|
nokogiri (>= 1.5.9)
|
76
83
|
method_source (0.9.2)
|
77
84
|
mini_portile2 (2.4.0)
|
78
|
-
minitest (5.
|
85
|
+
minitest (5.13.0)
|
79
86
|
multipart-post (2.1.1)
|
80
|
-
nokogiri (1.10.
|
87
|
+
nokogiri (1.10.5)
|
81
88
|
mini_portile2 (~> 2.4.0)
|
82
|
-
parallel (1.
|
83
|
-
parser (2.6.
|
89
|
+
parallel (1.18.0)
|
90
|
+
parser (2.6.5.0)
|
84
91
|
ast (~> 2.4.0)
|
85
92
|
pry (0.12.2)
|
86
93
|
coderay (~> 1.1.0)
|
87
94
|
method_source (~> 0.9.0)
|
95
|
+
public_suffix (4.0.1)
|
88
96
|
rack (2.0.7)
|
89
97
|
rack-test (1.1.0)
|
90
98
|
rack (>= 1.0, < 3)
|
91
99
|
rails-dom-testing (2.0.3)
|
92
100
|
activesupport (>= 4.2.0)
|
93
101
|
nokogiri (>= 1.6)
|
94
|
-
rails-html-sanitizer (1.0
|
95
|
-
loofah (~> 2.
|
96
|
-
railties (
|
97
|
-
actionpack (=
|
98
|
-
activesupport (=
|
102
|
+
rails-html-sanitizer (1.3.0)
|
103
|
+
loofah (~> 2.3)
|
104
|
+
railties (6.0.1)
|
105
|
+
actionpack (= 6.0.1)
|
106
|
+
activesupport (= 6.0.1)
|
99
107
|
method_source
|
100
108
|
rake (>= 0.8.7)
|
101
|
-
thor (>= 0.
|
109
|
+
thor (>= 0.20.3, < 2.0)
|
102
110
|
rainbow (3.0.0)
|
103
|
-
rake (
|
104
|
-
rspec (3.
|
105
|
-
rspec-core (~> 3.
|
106
|
-
rspec-expectations (~> 3.
|
107
|
-
rspec-mocks (~> 3.
|
108
|
-
rspec-core (3.
|
109
|
-
rspec-support (~> 3.
|
110
|
-
rspec-expectations (3.
|
111
|
+
rake (13.0.1)
|
112
|
+
rspec (3.9.0)
|
113
|
+
rspec-core (~> 3.9.0)
|
114
|
+
rspec-expectations (~> 3.9.0)
|
115
|
+
rspec-mocks (~> 3.9.0)
|
116
|
+
rspec-core (3.9.0)
|
117
|
+
rspec-support (~> 3.9.0)
|
118
|
+
rspec-expectations (3.9.0)
|
111
119
|
diff-lcs (>= 1.2.0, < 2.0)
|
112
|
-
rspec-support (~> 3.
|
113
|
-
rspec-mocks (3.
|
120
|
+
rspec-support (~> 3.9.0)
|
121
|
+
rspec-mocks (3.9.0)
|
114
122
|
diff-lcs (>= 1.2.0, < 2.0)
|
115
|
-
rspec-support (~> 3.
|
116
|
-
rspec-support (3.
|
117
|
-
rubocop (0.
|
123
|
+
rspec-support (~> 3.9.0)
|
124
|
+
rspec-support (3.9.0)
|
125
|
+
rubocop (0.76.0)
|
118
126
|
jaro_winkler (~> 1.5.1)
|
119
127
|
parallel (~> 1.10)
|
120
128
|
parser (>= 2.6)
|
@@ -122,29 +130,34 @@ GEM
|
|
122
130
|
ruby-progressbar (~> 1.7)
|
123
131
|
unicode-display_width (>= 1.4.0, < 1.7)
|
124
132
|
ruby-progressbar (1.10.1)
|
125
|
-
simplecov (0.17.
|
133
|
+
simplecov (0.17.1)
|
126
134
|
docile (~> 1.1)
|
127
135
|
json (>= 1.8, < 3)
|
128
136
|
simplecov-html (~> 0.10.0)
|
129
137
|
simplecov-html (0.10.2)
|
138
|
+
slack-notifier (2.3.2)
|
139
|
+
swagger-diff (1.1.2)
|
140
|
+
json-schema (~> 2.6)
|
141
|
+
rspec-expectations (~> 3.3)
|
130
142
|
thor (0.20.3)
|
131
143
|
thread_safe (0.3.6)
|
132
144
|
tzinfo (1.2.5)
|
133
145
|
thread_safe (~> 0.1)
|
134
146
|
unicode-display_width (1.6.0)
|
147
|
+
zeitwerk (2.2.1)
|
135
148
|
|
136
149
|
PLATFORMS
|
137
150
|
ruby
|
138
151
|
|
139
152
|
DEPENDENCIES
|
140
|
-
bundler (~>
|
153
|
+
bundler (~> 2.0)
|
141
154
|
pry
|
142
|
-
railties (>= 3.1, <
|
143
|
-
rake (~>
|
155
|
+
railties (>= 3.1, < 7.0)
|
156
|
+
rake (~> 13.0)
|
144
157
|
rspec (~> 3.0)
|
145
158
|
rswag_schema_export!
|
146
159
|
rubocop
|
147
160
|
simplecov
|
148
161
|
|
149
162
|
BUNDLED WITH
|
150
|
-
|
163
|
+
2.0.2
|
data/README.md
CHANGED
@@ -93,6 +93,13 @@ require 'rswag_schema_export/capistrano'
|
|
93
93
|
+ set :rswag_schema_export_disable_import, true
|
94
94
|
```
|
95
95
|
|
96
|
+
## Slack notifications
|
97
|
+
|
98
|
+
```diff
|
99
|
+
# config/deploy/develop.rb
|
100
|
+
+ set :rswag_schema_export_slack_webhook_url, ENV.fetch('SLACK_WEBHOOK_URL')
|
101
|
+
```
|
102
|
+
|
96
103
|
## Configuration
|
97
104
|
|
98
105
|
Set up ENVIRONMENT VARIABLES on your CI
|
data/lib/rswag_schema_export.rb
CHANGED
@@ -4,6 +4,9 @@ require "rswag_schema_export/client"
|
|
4
4
|
require "rswag_schema_export/railtie" if defined?(Rails)
|
5
5
|
require "rswag_schema_export/schema_export"
|
6
6
|
require "rswag_schema_export/schema_import"
|
7
|
+
require "rswag_schema_export/differ"
|
8
|
+
require "swagger/diff"
|
9
|
+
require "slack-notifier"
|
7
10
|
|
8
11
|
module RswagSchemaExport
|
9
12
|
def self.configure
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module RswagSchemaExport
|
4
|
+
class Differ
|
5
|
+
def self.call(previews_schema, new_schema)
|
6
|
+
previews_schema_json = JSON.parse(File.read(previews_schema))
|
7
|
+
previews_schema_json["host"] = "localhost"
|
8
|
+
|
9
|
+
File.write(previews_schema, JSON.pretty_generate(previews_schema_json))
|
10
|
+
|
11
|
+
new_schema_json = JSON.parse(File.read(new_schema))
|
12
|
+
new_schema_json["host"] = "localhost"
|
13
|
+
|
14
|
+
File.write(new_schema, JSON.pretty_generate(new_schema_json))
|
15
|
+
|
16
|
+
diff = ::Swagger::Diff::Diff.new(previews_schema, new_schema)
|
17
|
+
changes = []
|
18
|
+
report = ""
|
19
|
+
|
20
|
+
diff.changes.map do |topic|
|
21
|
+
report += "#{topic.first}: #{topic.last} \n"
|
22
|
+
changes << topic.last unless topic.last.empty?
|
23
|
+
end
|
24
|
+
if changes.empty?
|
25
|
+
nil
|
26
|
+
else
|
27
|
+
report
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
1
3
|
module RswagSchemaExport
|
2
4
|
class Import
|
3
5
|
def run
|
@@ -6,6 +8,9 @@ module RswagSchemaExport
|
|
6
8
|
begin
|
7
9
|
client = ::RswagSchemaExport::Client.new(ENV["STAGE"])
|
8
10
|
RswagSchemaExport.config.schemas.map do |schema|
|
11
|
+
# Copy previous version
|
12
|
+
FileUtils.cp(schema, "#{schema}.previous") if File.exist?(schema)
|
13
|
+
|
9
14
|
schema_id = schema.gsub(/[^a-zA-Z0-9\-]/, "_")
|
10
15
|
|
11
16
|
# Copy latest version to root
|
@@ -19,6 +24,18 @@ module RswagSchemaExport
|
|
19
24
|
client.clean(versions)
|
20
25
|
|
21
26
|
puts("Schema has been successfully imported. Stage: #{client.stage} | Key: #{last_schema_key}")
|
27
|
+
if ENV["SLACK_WEBHOOK_URL"]
|
28
|
+
begin
|
29
|
+
changes = Differ.call("#{schema}.previous", schema)
|
30
|
+
|
31
|
+
unless changes.nil?
|
32
|
+
Slack::Notifier.new(ENV["SLACK_WEBHOOK_URL"], username: 'Swagger API Differ').post(
|
33
|
+
text: '', attachments: [{ color: 'good', text: "_Swagger schema has been updated:_ \n #{changes}"}])
|
34
|
+
end
|
35
|
+
rescue StandardError => e
|
36
|
+
puts("Slack notification error: #{e}")
|
37
|
+
end
|
38
|
+
end
|
22
39
|
end
|
23
40
|
yield if block_given?
|
24
41
|
puts("Import finished")
|
@@ -5,7 +5,7 @@ namespace :rswag do
|
|
5
5
|
on roles(fetch(:rswag_schema_export_roles, :app)) do
|
6
6
|
within current_path do
|
7
7
|
with rails_env: fetch(:rails_env) do
|
8
|
-
execute :rake, "rswag:schema_import STAGE=#{fetch(:stage)}"
|
8
|
+
execute :rake, "rswag:schema_import STAGE=#{fetch(:stage)} SLACK_WEBHOOK_URL=#{fetch(:rswag_schema_export_slack_webhook_url)}"
|
9
9
|
end
|
10
10
|
end
|
11
11
|
end
|
data/rswag_schema_export.gemspec
CHANGED
@@ -21,11 +21,13 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_dependency "aws-sdk-s3", "~> 1"
|
23
23
|
spec.add_dependency "azure-storage-blob", "~> 1.1"
|
24
|
+
spec.add_dependency "swagger-diff", "~> 1.1.2"
|
25
|
+
spec.add_dependency "slack-notifier", "~> 2.3.2"
|
24
26
|
|
25
|
-
spec.add_development_dependency "bundler", "~>
|
27
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
26
28
|
spec.add_development_dependency "pry"
|
27
|
-
spec.add_development_dependency "railties", ">= 3.1", "<
|
28
|
-
spec.add_development_dependency "rake", "~>
|
29
|
+
spec.add_development_dependency "railties", ">= 3.1", "< 7.0"
|
30
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
29
31
|
spec.add_development_dependency "rspec", "~> 3.0"
|
30
32
|
spec.add_development_dependency "rubocop"
|
31
33
|
spec.add_development_dependency "simplecov"
|
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.
|
4
|
+
version: 0.3.0
|
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-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-s3
|
@@ -38,20 +38,48 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: swagger-diff
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 1.1.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.1.2
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: slack-notifier
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 2.3.2
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 2.3.2
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: bundler
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
44
72
|
requirements:
|
45
73
|
- - "~>"
|
46
74
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
75
|
+
version: '2.0'
|
48
76
|
type: :development
|
49
77
|
prerelease: false
|
50
78
|
version_requirements: !ruby/object:Gem::Requirement
|
51
79
|
requirements:
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
82
|
+
version: '2.0'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: pry
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,7 +103,7 @@ dependencies:
|
|
75
103
|
version: '3.1'
|
76
104
|
- - "<"
|
77
105
|
- !ruby/object:Gem::Version
|
78
|
-
version: '
|
106
|
+
version: '7.0'
|
79
107
|
type: :development
|
80
108
|
prerelease: false
|
81
109
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -85,21 +113,21 @@ dependencies:
|
|
85
113
|
version: '3.1'
|
86
114
|
- - "<"
|
87
115
|
- !ruby/object:Gem::Version
|
88
|
-
version: '
|
116
|
+
version: '7.0'
|
89
117
|
- !ruby/object:Gem::Dependency
|
90
118
|
name: rake
|
91
119
|
requirement: !ruby/object:Gem::Requirement
|
92
120
|
requirements:
|
93
121
|
- - "~>"
|
94
122
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
123
|
+
version: '13.0'
|
96
124
|
type: :development
|
97
125
|
prerelease: false
|
98
126
|
version_requirements: !ruby/object:Gem::Requirement
|
99
127
|
requirements:
|
100
128
|
- - "~>"
|
101
129
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
130
|
+
version: '13.0'
|
103
131
|
- !ruby/object:Gem::Dependency
|
104
132
|
name: rspec
|
105
133
|
requirement: !ruby/object:Gem::Requirement
|
@@ -170,6 +198,7 @@ files:
|
|
170
198
|
- lib/rswag_schema_export/capistrano.rb
|
171
199
|
- lib/rswag_schema_export/client.rb
|
172
200
|
- lib/rswag_schema_export/configuration.rb
|
201
|
+
- lib/rswag_schema_export/differ.rb
|
173
202
|
- lib/rswag_schema_export/railtie.rb
|
174
203
|
- lib/rswag_schema_export/schema_export.rb
|
175
204
|
- lib/rswag_schema_export/schema_import.rb
|
@@ -196,7 +225,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
225
|
- !ruby/object:Gem::Version
|
197
226
|
version: '0'
|
198
227
|
requirements: []
|
199
|
-
rubygems_version: 3.0.
|
228
|
+
rubygems_version: 3.0.6
|
200
229
|
signing_key:
|
201
230
|
specification_version: 4
|
202
231
|
summary: Export/Import your rswag schema.json during deploy with CI
|