From a2090d5f5489c8366bc3db66da63af1ba941f1f0 Mon Sep 17 00:00:00 2001 From: rautenberg Date: Thu, 21 May 2015 13:03:13 +0200 Subject: add generic route /SERVICE/api to swagger.json file --- lib/opentox.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/opentox.rb b/lib/opentox.rb index 2adc04c..c14d352 100644 --- a/lib/opentox.rb +++ b/lib/opentox.rb @@ -32,7 +32,7 @@ module OpenTox config.allow do |allow| allow.origins '*' allow.resource "/#{SERVICE}/*", - :methods => [:get, :post, :put ], + :methods => [:head, :get, :post, :put, :options], :headers => :any, :max_age => 0 end @@ -196,6 +196,14 @@ module OpenTox } ORDER BY ?o ", @accept) end + # generic route to swagger API file + get "/#{SERVICE}/api/?" do + response['Content-Type'] = "application/json" + api_file = File.join('api', 'swagger.json') + bad_request_error "API Documentation in Swagger JSON is not implemented.", uri("/#{SERVICE}/api") unless File.exists?(api_file) + File.read(api_file) + end + # Create a new resource post "/#{SERVICE}/?" do @uri = uri("/#{SERVICE}/#{SecureRandom.uuid}") -- cgit v1.2.3