-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathRakefile
56 lines (44 loc) · 1.7 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true
require 'bundler/gem_tasks'
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
task default: :spec
namespace :swagger do
swagger_file_name = 'tmp/swagger.json'
task :environment do
require 'json'
require 'orangedata'
end
file swagger_file_name => :environment do
puts "Downloading swagger.json"
`curl https://apip.orangedata.ru:2443/swagger/v2/swagger.json > #{swagger_file_name}`
end
desc "compare upstream swagger spec"
task diff: [:environment, swagger_file_name] do
swagger = JSON.parse(File.read(swagger_file_name))
new_definitions = swagger['definitions']
old_definitions = OrangeData::PAYLOAD_SCHEMA['definitions']
if new_definitions.keys == old_definitions.keys
puts "No top-level definitions changed"
else
puts "New schema definitions: #{new_definitions.keys - old_definitions.keys}"
puts "Removed schema definitions: #{old_definitions.keys - new_definitions.keys}"
end
new_definitions.each_pair do |key, new_schema|
old_schema = old_definitions[key]
next unless old_schema
if old_schema['properties'].keys != new_schema['properties'].keys
if old_schema['properties'].keys.sort == new_schema['properties'].keys.sort
puts "\t#{key} property order changed:"
puts "\t\told:#{old_schema['properties'].keys}"
puts "\t\tnew:#{new_schema['properties'].keys}"
else
puts "\t#{key} added: #{new_schema['properties'].keys - old_schema['properties'].keys}"
puts "\t#{key} removed: #{old_schema['properties'].keys - new_schema['properties'].keys}"
end
# else
# TODO: deep compare
end
end
end
end