diff --git a/fda-units-service/app.py b/fda-units-service/app.py index 19c57396d93b7c06b43d42eed266076d0dfeb146..e997cdb527177e88896a4a2d848e30d15bf50848 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 cefbb9c04aa70e2bf86cbfa0f1bd2c0d3fb9cdb3..b79cf9032756db339a57ad2b7e76ae57da57e13b 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 bd92c5cb29715274338bf0efe5b59c3ac78f05f8..01cbb337c1a66d5356e99214c4ca59215fc00f5f 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"