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
|
# File 'lib/ruby-swagger/io/paths.rb', line 20
def self.write_paths(paths)
return if paths.nil?
l = (Swagger::IO::FileSystem.default_path + '/paths').length
Swagger::IO::FileSystem.all_files("paths/**/*.yml").each do |file|
def_name = file[l..file.length]
if paths[File.dirname(file[l..file.length])].nil? || paths[File.dirname(file[l..file.length])][File.basename(file, ".yml")].nil?
STDERR.puts "#{def_name} is not present anymore, removing #{file}"
Swagger::IO::FileSystem.delete_file(file)
end
end
paths.each do |path, path_obj|
path_obj.each do |action, action_obj|
file = "paths/#{path}/#{action}.yml"
if Swagger::IO::FileSystem.file_exists?(file)
old_action = Swagger::IO::FileSystem.read_file(file)
Swagger::IO::Comparable.copy_description_old_definition(action_obj, old_action)
end
Swagger::IO::FileSystem.write_file(action_obj.to_yaml, file, true)
end
end
end
|