blob: c3b27ce315ba4b6dd8c75d47f883877b66ff8970 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
get "/api" do
api_file = File.join("api", "api.json")
halt 400, "API Documentation in Swagger JSON is not implemented." unless File.exists?(api_file)
case @accept
when "text/html"
response['Content-Type'] = "text/html"
index_file = File.join(ENV['HOME'],"swagger-ui/dist/index.html")
File.read(index_file)
when "application/json"
response['Content-Type'] = "application/json"
api_hash = JSON.parse(File.read(api_file))
api_hash["host"] = request.env['HTTP_HOST']
return api_hash.to_json
else
halt 400, "unknown MIME type '#{@accept}'"
end
end
get "/api/api.json" do
response['Content-Type'] = "text/html"
index_file = File.join(ENV['HOME'],"swagger-ui/dist/index.html")
File.read(index_file)
end
|