From 7d0750d3988e54e151bd731469f4f558889f092a Mon Sep 17 00:00:00 2001
From: Cornelia Michlits <cornelia.michlits@tuwien.ac.at>
Date: Tue, 29 Nov 2022 23:57:57 +0100
Subject: [PATCH] update readme, flasgger

---
 fda-units-service/README.md                 | 78 +++++++++++++++++++--
 fda-units-service/us-yml/getconcept.yml     |  3 +-
 fda-units-service/us-yml/geturi.yml         |  3 +-
 fda-units-service/us-yml/ontologies.yml     |  6 +-
 fda-units-service/us-yml/ontologybyname.yml |  9 +--
 fda-units-service/us-yml/validate.yml       |  4 +-
 6 files changed, 87 insertions(+), 16 deletions(-)

diff --git a/fda-units-service/README.md b/fda-units-service/README.md
index da7b0ba16e..e9950b9d8a 100644
--- a/fda-units-service/README.md
+++ b/fda-units-service/README.md
@@ -1,6 +1,6 @@
-# Units Service
+# Units and Ontology Service
 
-Suggest and validates units of measurements defined in Ontology of units of Measure (OM) [1] is used. 
+Suggest and validates units of measurements defined in Ontology of Units of Measure (OM) [1]. Moreover, it stores ontologies in DB-Repo, list them and finds suitable concepts over all ontologies within the Repository. Note: In Flasgger switch between "/api-units.json" and "/api-ontologies.json". 
 
 [1] https://github.com/HajoRijgersberg/OM
 
@@ -98,9 +98,13 @@ Content-Length: 97
 }
 ```
 
-The response is a postgres status message, e.g., 
+The response is a status message and a JSON with the URI of the created concept
 
-"\"INSERT 0 1\""
+```JSON
+{
+	"uri": "http://www.ontology-of-units-of-measure.org/resource/om-2/centimetre"
+}
+```
 
 ## `POST /api/units/savecolumnsconcept'
 Saves values in the entity 'mdb\_columns\_concepts', which realizes the relation between 'mdb\_columns' and 'mdb\_concepts'. Make sure the concept is contained in 'mdb\_concepts'. 
@@ -120,6 +124,68 @@ Content-Length: 122
 }
 ```
 
-The response is a postgres status message, e.g., 
+The response is a postgres status message: 
+* 201: created 
+* 409: conflict
+
+## `GET /api/ontologies/listontologies'
+List the name of all ontologies stored in DB-Repo. 
+
+Example http request: 
+GET /api/ontologies/listontologies HTTP/1.1
+Host: localhost:5010
+
+## `GET /api/ontologies/getconcept/<cname>'
+Lists concepts contained in all stored ontologies in DB-Repo ('string matching')
+
+Example http request: 
+GET /api/ontologies/getconcept/Curve HTTP/1.1
+Host: localhost:5010
+
+The response is a JSON: 
+
+```JSON
+[
+	{
+		"O": "Multicourbe",
+		"P": "http://www.w3.org/2000/01/rdf-schema#label",
+		"S-URI": "http://data.ign.fr/def/geometrie#MultiCurve"
+	},
+	{
+		"O": "http://www.opengis.net/ont/sf#Curve",
+		"P": "http://www.w3.org/2000/01/rdf-schema#subClassOf",
+		"S-URI": "http://data.ign.fr/def/geometrie#Curve"
+	}
+]
+```
+
+## `POST /api/ontologies/upload'
+
+In order to upload new ontologies (.ttl, .nt files) to DB-Repo. 
+
+Example http request: 
+POST /api/ontologies/upload HTTP/1.1
+Content-Type: multipart/form-data; boundary=---011000010111000001101001
+Host: localhost:5010
+Content-Length: 166
 
-"\"INSERT 0 1\""
+-----011000010111000001101001
+Content-Disposition: form-data; name="file"; filename="geometrie.ttl"
+Content-Type: text/turtle
+
+
+-----011000010111000001101001--
+
+The response is 
+* 201: created 
+* 400: no file selected
+* 409: conflict 
+* 500: internal server error
+
+## `GET /api/ontologies/<o_name>'
+
+Is an endpoint for downloading an ontology contained in DB-Repo. 
+
+Example http request:
+GET /api/ontologies/VOCAB_QUDT-UNITS-ALL-v2.1 HTTP/1.1
+Host: localhost:5010
diff --git a/fda-units-service/us-yml/getconcept.yml b/fda-units-service/us-yml/getconcept.yml
index 1a2e13c264..8561b406c5 100644
--- a/fda-units-service/us-yml/getconcept.yml
+++ b/fda-units-service/us-yml/getconcept.yml
@@ -6,10 +6,11 @@ produces:
 - "application/json"
 parameters:
 - in: "path"
-  type: "string"
   name: "cname"
   description: "Enter a concept name."
   required: true
+  schema:
+    type: "string"
 responses:
   200: 
     description: "OK"
diff --git a/fda-units-service/us-yml/geturi.yml b/fda-units-service/us-yml/geturi.yml
index 8519087dcd..0521ea26cf 100644
--- a/fda-units-service/us-yml/geturi.yml
+++ b/fda-units-service/us-yml/geturi.yml
@@ -6,10 +6,11 @@ produces:
 - "application/json"
 parameters:
 - in: "path"
-  type: "string"
   name: "uname"
   description: "Name of a unit in OM"
   required: true
+  schema:
+    type: "string"
 responses:
   200: 
     description: "OK"
diff --git a/fda-units-service/us-yml/ontologies.yml b/fda-units-service/us-yml/ontologies.yml
index 2934080935..ece3dc3ec8 100644
--- a/fda-units-service/us-yml/ontologies.yml
+++ b/fda-units-service/us-yml/ontologies.yml
@@ -5,10 +5,10 @@ consumes:
 produces:
 - "application/json"
 parameters:
-- name: file
+- in: "formData"
+  name: "file"
   required: false
-  in: formData
-  type: file
+  type: "file"
 responses:
   200:
     description: "OK"
diff --git a/fda-units-service/us-yml/ontologybyname.yml b/fda-units-service/us-yml/ontologybyname.yml
index ccccc3fee9..8ae6e93d5b 100644
--- a/fda-units-service/us-yml/ontologybyname.yml
+++ b/fda-units-service/us-yml/ontologybyname.yml
@@ -5,11 +5,12 @@ consumes:
 produces:
 - "application/json"
 parameters:
-  - name: o_name
-    in: path
+  - in: "path"
+    name: "o_name"
     required: true
-    type: string
-    default: "VOCAB_QUDT-UNITS-ALL-v2.1"
+    schema:
+      type: "string"
+      example: "VOCAB_QUDT-UNITS-ALL-v2.1"
 responses:
   200:
     description: "OK"
diff --git a/fda-units-service/us-yml/validate.yml b/fda-units-service/us-yml/validate.yml
index 81ac877ead..8e05d14012 100644
--- a/fda-units-service/us-yml/validate.yml
+++ b/fda-units-service/us-yml/validate.yml
@@ -6,10 +6,12 @@ produces:
 - "application/json"
 parameters:
 - in: "path"
-  type: "string"
   name: "unit"
   description: "Validates unit against om-2."
   required: true
+  schema:
+    type: "string"
+    example: "metre"
 responses:
   200: 
     description: "OK"
-- 
GitLab