Chore: Swagger Docs V1 (#546)
This commit is contained in:
18
app/controllers/swagger_controller.rb
Normal file
18
app/controllers/swagger_controller.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
class SwaggerController < ApplicationController
|
||||
def respond
|
||||
if Rails.env.development? || Rails.env.test?
|
||||
render inline: File.read(Rails.root.join('swagger', derived_path))
|
||||
else
|
||||
head 404
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def derived_path
|
||||
params[:path] ||= 'index.html'
|
||||
path = params[:path]
|
||||
path << ".#{params[:format]}" unless path.ends_with?(params[:format].to_s)
|
||||
path
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user