Chore: Swagger Docs V1 (#546)

This commit is contained in:
Sony Mathew
2020-02-23 12:54:29 +05:30
committed by GitHub
parent eea92bd0ac
commit e2688d5176
25 changed files with 739 additions and 0 deletions

22
lib/tasks/swagger.rake Normal file
View File

@@ -0,0 +1,22 @@
namespace :swagger do
desc 'build combined swagger.json file from all the fragmented definitions and paths inside swagger folder'
task build: :environment do
require 'json_refs'
base_path = Rails.root.join('swagger')
Dir.chdir(base_path) do
swagger_index = YAML.safe_load(File.open('index.yml'))
final_build = JsonRefs.call(
swagger_index,
resolve_local_ref: false,
resolve_file_ref: true,
logging: true
)
File.write('swagger.json', JSON.pretty_generate(final_build))
puts 'Swagger build was succesful.'
puts "Generated #{base_path}/swagger.json"
puts 'Go to http://localhost:3000/swagger see the changes.'
end
end
end