From 4b906847a09f26896a3770ecd5254ab9de78d445 Mon Sep 17 00:00:00 2001
From: Cornelia Michlits <cornelia.michlits@tuwien.ac.at>
Date: Thu, 10 Feb 2022 23:36:26 +0100
Subject: [PATCH] 104 - ontology change endpoint types as suggested

Former-commit-id: 441933e63cb29d5f3cab617e34aaa2b7178c6d21
---
 fda-units-service/app.py              | 16 ++++++----------
 fda-units-service/us-yml/geturi.yml   | 13 ++++---------
 fda-units-service/us-yml/validate.yml | 13 ++++---------
 3 files changed, 14 insertions(+), 28 deletions(-)

diff --git a/fda-units-service/app.py b/fda-units-service/app.py
index 19c57396d9..e997cdb527 100644
--- a/fda-units-service/app.py
+++ b/fda-units-service/app.py
@@ -48,26 +48,22 @@ def suggest():
         res = {"success": False, "message": str(e)}
         return jsonify(res), 500
 
-@app.route('/api/units/validate', methods=["POST"], endpoint='validate')
+@app.route('/api/units/validate/<unit>', methods=["GET"], endpoint='validate')
 @swag_from('validate.yml')
-def valitate():
-    input_json = request.get_json()
+def valitate(unit):
     try:
-        unit = str(input_json['ustring'])
-        res = validator(stringmapper(unit))
+        res = validator(unit)
         return str(res), 200
     except Exception as e:
         print(e)
         res = {"success": False, "message": str(e)}
         return jsonify(res)
 
-@app.route('/api/units/uri', methods=["GET"], endpoint='uri')
+@app.route('/api/units/uri/<uname>', methods=["GET"], endpoint='uri')
 @swag_from('geturi.yml')
-def geturi():
-    input_json = request.get_json()
+def geturi(uname):
     try:
-        name = str(input_json['uname'])
-        res = get_uri(name)
+        res = get_uri(uname)
         return jsonify(res), 200
     except Exception as e:
         print(e)
diff --git a/fda-units-service/us-yml/geturi.yml b/fda-units-service/us-yml/geturi.yml
index cefbb9c04a..b79cf90327 100644
--- a/fda-units-service/us-yml/geturi.yml
+++ b/fda-units-service/us-yml/geturi.yml
@@ -5,18 +5,13 @@ consumes:
 produces:
 - "application/json"
 parameters:
-- in: "body"
-  name: "body"
+- in: "path"
+  type: "string"
+  name: "uname"
   description: "to-do description"
   required: true
-  schema:
-    type: "object"
-    properties:
-      uname:
-        type: "string"
-        example : "metre"
 responses:
   200: 
     description: "OK"
   405:
-    description: "Invalid input"
\ No newline at end of file
+    description: "Invalid input"
diff --git a/fda-units-service/us-yml/validate.yml b/fda-units-service/us-yml/validate.yml
index bd92c5cb29..01cbb337c1 100644
--- a/fda-units-service/us-yml/validate.yml
+++ b/fda-units-service/us-yml/validate.yml
@@ -5,18 +5,13 @@ consumes:
 produces:
 - "application/json"
 parameters:
-- in: "body"
-  name: "body"
+- in: "path"
+  type: "string"
+  name: "unit"
   description: "to-do description"
   required: true
-  schema:
-    type: "object"
-    properties:
-      ustring:
-        type: "string"
-        example : "metre"
 responses:
   200: 
     description: "OK"
   405:
-    description: "Invalid input"
\ No newline at end of file
+    description: "Invalid input"
-- 
GitLab