Chatwoot/app/controllers/swagger_controller.rb

19 lines
418 B
Ruby
Raw Permalink Normal View History

2020-02-23 07:24:29 +00:00
class SwaggerController < ApplicationController
def respond
if Rails.env.development? || Rails.env.test?
render inline: File.read(Rails.root.join('swagger', derived_path))
else
head :not_found
2020-02-23 07:24:29 +00:00
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