diff options
author | rautenberg <rautenberg@in-silico.ch> | 2015-05-21 13:03:13 +0200 |
---|---|---|
committer | rautenberg <rautenberg@in-silico.ch> | 2015-05-21 13:03:13 +0200 |
commit | a2090d5f5489c8366bc3db66da63af1ba941f1f0 (patch) | |
tree | cfa4c0be02452fb24ddb09fea1e4680668ede9b5 | |
parent | a176fea6d081263b93a122ba5f377b8d21c19722 (diff) |
add generic route /SERVICE/api to swagger.json file
-rw-r--r-- | lib/opentox.rb | 10 |
1 files changed, 9 insertions, 1 deletions
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}") |