Skip to content

Commit

Permalink
swagger setting
Browse files Browse the repository at this point in the history
  • Loading branch information
Askarpour committed Feb 12, 2020
1 parent ed8fcf9 commit bad7f7a
Show file tree
Hide file tree
Showing 3 changed files with 110 additions and 0 deletions.
13 changes: 13 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from flask import Flask, request
import shutil
from flask_swagger_ui import get_swaggerui_blueprint
import requests, os
import blueprint2json
from gevent.pywsgi import WSGIServer
Expand All @@ -8,6 +9,18 @@
import json
app = Flask(__name__)

SWAGGER_URL = '/docs'
API_URL = '/static/swagger.json'
SWAGGERUI_BLUEPRINT = get_swaggerui_blueprint(
SWAGGER_URL,
API_URL,
config={
'app_name': "SODALITE iac-blueprint-builder"
}
)
app.register_blueprint(SWAGGERUI_BLUEPRINT, url_prefix=SWAGGER_URL)


XOPERA_API = 'http://154.48.185.206:5000/manage'

@app.route('/parse', methods = ['POST'])
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Flask==1.1.1
gevent==1.4.0
requests
flask_swagger_ui
96 changes: 96 additions & 0 deletions static/swagger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
{
"openapi": "3.0.0",
"info": {
"description": "SODALITE iac-blueprint-builder component",
"version": "1.0.0",
"title": "iac-blueprint-builder",
"contact": {
"email": "[email protected]"
}
},
"servers": [
{
"url": "/"
}
],
"tags": [
{
"name": "iac-blueprint-builder",
"description": "SODALITE JSON parser"
}
],
"paths": {
"/parse": {
"post": {
"tags": [
"parse"
],
"summary": "Parse JSON file and save blueprint to xOpera",
"requestBody": {
"description": "parse",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/parseBody"
}
}
}
},
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/components/schemas/parseResponse"
}
}
}
}
}
},
"components": {
"schemas": {
"parseBody": {
"type": "object",
"properties": {
"name": {
"type": "string",
"format": "string"
},
"data": {
"type": "SODALITE JSON",
"format": "SODALITE JSON"
}
}
},
"parseResponse": {
"type": "object",
"properties": {
"blueprint_token": {
"type": "string",
"format": "string"
},
"id": {
"type": "string",
"format": "string"
},
"message": {
"type": "string",
"format": "string"
},
"timestamp": {
"type": "string",
"format": "string"
},
"version_id": {
"type": "number",
"format": "number"
}
}
}
}
}
}

0 comments on commit bad7f7a

Please sign in to comment.