From 1f36d6247578273197a4ba64b58b02b1ed837171 Mon Sep 17 00:00:00 2001 From: xudan Date: Thu, 27 Jun 2019 04:37:55 -0400 Subject: Add Swagger UI for dovetail API Change-Id: If8f515b02f0372955739dd580967a3198930e98b Signed-off-by: xudan --- dovetail/api/app/routes.py | 2 ++ dovetail/api/boot.sh | 12 +++++++++++ dovetail/api/swagger.yaml | 54 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 dovetail/api/swagger.yaml (limited to 'dovetail') diff --git a/dovetail/api/app/routes.py b/dovetail/api/app/routes.py index c235cb48..6c327323 100644 --- a/dovetail/api/app/routes.py +++ b/dovetail/api/app/routes.py @@ -1,10 +1,12 @@ #!flask/bin/python from flask import Flask, jsonify +from flask_cors import CORS import server app = Flask(__name__) +CORS(app) @app.route('/api/v1/scenario/nfvi/testsuites', methods=['GET']) diff --git a/dovetail/api/boot.sh b/dovetail/api/boot.sh index dc49876a..9fbb5484 100755 --- a/dovetail/api/boot.sh +++ b/dovetail/api/boot.sh @@ -1,4 +1,16 @@ #!/bin/sh +mkdir -p /var/www/html/dovetail-api +cp -r /home/opnfv/swagger-ui/dist/* /var/www/html/dovetail-api +cp /home/opnfv/dovetail/dovetail/api/swagger.yaml /var/www/html/dovetail-api +sed -i 's#url: "https://petstore.swagger.io/v2/swagger.json"#url: "swagger.yaml"#g' /var/www/html/dovetail-api/index.html +sed -i '/deepLinking: true,/a\ validatorUrl: null,' /var/www/html/dovetail-api/index.html + +if [[ -n ${SWAGGER_HOST} ]]; then + sed -i "s/host: localhost:8888/host: ${SWAGGER_HOST}/g" /var/www/html/dovetail-api/swagger.yaml +fi + +/etc/init.d/apache2 start + cd $(dirname $(readlink -f $0)) exec gunicorn -b :5000 --access-logfile - --error-logfile - app.routes:app diff --git a/dovetail/api/swagger.yaml b/dovetail/api/swagger.yaml new file mode 100644 index 00000000..5df0dcc2 --- /dev/null +++ b/dovetail/api/swagger.yaml @@ -0,0 +1,54 @@ +swagger: "2.0" +info: + description: "This is the dovetail API." + version: "1.0.0" + title: "Dovetail API" + contact: + email: "xudan16@huawei.com" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +host: localhost:8888 +basePath: "/api/v1/scenario/nfvi" +tags: +- name: "testsuites" + description: "Operations about testsuites" +- name: "testcases" + description: "Operations about test cases" +schemes: +- "http" +paths: + /testsuites: + get: + tags: + - "testsuites" + summary: "Get all testsuites" + description: "" + operationId: "getTestsuites" + consumes: + - "application/json" + produces: + - "application/json" + parameters: [] + responses: + 200: + description: "successful operation" + default: + description: Unexpected error + /testcases: + get: + tags: + - "testcases" + summary: "Get all test cases" + description: "" + operationId: "getTestcases" + consumes: + - "application/json" + produces: + - "application/json" + parameters: [] + responses: + 200: + description: "successful operation" + default: + description: Unexpected error -- cgit 1.2.3-korg