summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgebele <gebele@in-silico.ch>2018-06-28 14:35:20 +0000
committergebele <gebele@in-silico.ch>2018-06-28 14:35:20 +0000
commit395506ca3fe4daa5689fd197e57f7ab944beb1d7 (patch)
treed840d4678eada31dc9937da7dd85ee60a714d4c4
parentba65db7e62264b94a7303681e30db4ac415b4822 (diff)
updated API and request path handling
-rw-r--r--api/api.json95
-rw-r--r--application.rb53
2 files changed, 118 insertions, 30 deletions
diff --git a/api/api.json b/api/api.json
index 9976569..6aa95ad 100644
--- a/api/api.json
+++ b/api/api.json
@@ -19,7 +19,7 @@
"title": "Lazar & Nano-Lazar REST Service",
"contact": {
"name": "in silico toxicology gmbh",
- "email": "info@in-silico.ch",
+ "email": "service@in-silico.ch",
"url": "https://in-silico.ch"
},
"license": {
@@ -268,8 +268,34 @@
],
"responses": {
"200": {
- "$ref": "#/components/responses/200"
- },
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "x-orn:returns": "application/json",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "text/csv": {
+ "x-orn:returns": "text/csv",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "application/csv": {
+ "x-orn:returns": "text/csv",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ }
+ }
+ },
"400": {
"$ref": "#/components/responses/400"
},
@@ -813,10 +839,71 @@
],
"responses": {
"200": {
- "$ref": "#/components/responses/200"
+ "description": "OK",
+ "content": {
+ "application/json": {
+ "x-orn:returns": "application/json",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "chemical/x-daylight-smiles": {
+ "x-orn:returns": "chemical/x-daylight-smiles",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "chemical/x-inchi": {
+ "x-orn:returns": "chemical/x-inchi",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "chemical/x-mdl-sdfile": {
+ "x-orn:returns": "chemical/x-mdl-sdfile",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "image/png": {
+ "x-orn:returns": "image/png",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "image/svg+xml": {
+ "x-orn:returns": "image/svg+xml",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ },
+ "text/plain": {
+ "x-orn:returns": "text/plain",
+ "schema": {
+ "x-orn:property": "InChI",
+ "type": "string",
+ "example": "InChI=1S/C6H6/c1-2-4-6-5-3-1/h1-6H"
+ }
+ }
+ }
},
"400": {
"$ref": "#/components/responses/400"
+ },
+ "500": {
+ "$ref": "#/components/responses/500"
}
}
}
diff --git a/application.rb b/application.rb
index 96e564b..ebcb0af 100644
--- a/application.rb
+++ b/application.rb
@@ -2,6 +2,20 @@ require 'rdiscount'
require_relative 'qmrf_report.rb'
include OpenTox
+[
+ "aa.rb",
+ "api.rb",
+ "compound.rb",
+ "dataset.rb",
+ "feature.rb",
+ "model.rb",
+ "nanoparticle.rb",
+ "report.rb",
+ "substance.rb",
+ "swagger.rb",
+ "validation.rb"
+].each{ |f| require_relative "./lib/#{f}" }
+
configure :production do
$logger = Logger.new(STDOUT)
@@ -15,18 +29,19 @@ end
before do
paths = [
- "/aa",
- "/api",
- "/compound",
- "/dataset",
- "/feature",
- "/model",
- "/nanoparticle",
- "/report",
- "/substance",
- "/swagger",
- "/validation"]
- if paths.include?(request.path)
+ "/",
+ "aa",
+ "api",
+ "compound",
+ "dataset",
+ "feature",
+ "model",
+ "nanoparticle",
+ "report",
+ "substance",
+ "swagger",
+ "validation"]
+ if request.path == "/" || paths.include?(request.path.split("/")[1])
@accept = request.env['HTTP_ACCEPT']
response['Content-Type'] = @accept
else
@@ -50,20 +65,6 @@ options "*" do
200
end
-[
- "aa.rb",
- "api.rb",
- "compound.rb",
- "dataset.rb",
- "feature.rb",
- "model.rb",
- "nanoparticle.rb",
- "report.rb",
- "substance.rb",
- "swagger.rb",
- "validation.rb"
-].each{ |f| require_relative "./lib/#{f}" }
-
get '/predict/?' do
@models = OpenTox::Model::Validation.all
@models = @models.delete_if{|m| m.model.name =~ /\b(Net cell association)\b/}