lib/napa/ext/swagger_doc.rb in napa-ext-0.0.4 vs lib/napa/ext/swagger_doc.rb in napa-ext-0.0.5
- old
+ new
@@ -29,12 +29,16 @@
def enabled?
ENV.key? 'SWAGGER_UI_URL'
end
def target_swagger_url env
- swagger_api_uri = env['REQUEST_URI'].gsub api_doc_path, '/swagger_doc'
+ swagger_api_uri = "#{base_url}/swagger_doc"
"#{ENV['SWAGGER_UI_URL']}?swagger_doc=#{swagger_api_uri}"
+ end
+
+ def base_url
+ @base_url ||= "#{env['rack.url_scheme']}://#{env['HTTP_HOST']}"
end
end
end
end