Skip to content

Commit

Permalink
Remove swagger ui
Browse files Browse the repository at this point in the history
  • Loading branch information
micafer committed Jun 7, 2024
1 parent fe5a0a9 commit 3ec1a9f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 24 deletions.
13 changes: 0 additions & 13 deletions IM/REST.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import os
import yaml

from flask_swagger_ui import get_swaggerui_blueprint
from cheroot.wsgi import Server as WSGIServer, PathInfoDispatcher
from cheroot.ssl.builtin import BuiltinSSLAdapter
from werkzeug.middleware.proxy_fix import ProxyFix
Expand Down Expand Up @@ -63,13 +62,6 @@
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_port=1, x_prefix=1)
flask_server = None

# Add the swagger UI
swaggerui_blueprint = get_swaggerui_blueprint(
'/api/docs', # Swagger UI static files will be mapped to '{SWAGGER_URL}/dist/'
'/swagger.json'
)
app.register_blueprint(swaggerui_blueprint)


def run_in_thread(host, port):
flask_thr = threading.Thread(target=run, args=(host, port))
Expand Down Expand Up @@ -951,11 +943,6 @@ def RESTGetVersion():

@app.route('/')
def RESTIndex():
return flask.redirect('/api/docs')


@app.route('/swagger.json')
def RESTSwagger():
rest_path = os.path.dirname(os.path.abspath(__file__))
abs_file_path = os.path.join(rest_path, 'swagger_api.yaml')
api_docs = yaml.safe_load(open(abs_file_path, 'r'))
Expand Down
3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ dependencies = [
"requests-cache >= 1.0.0",
"packaging",
"werkzeug",
"xmltodict",
"flask-swagger-ui"
"xmltodict"
]
license = {text = "GPL version 3, http://www.gnu.org/licenses/gpl-3.0.txt"}
dynamic = ["version", "readme"]
Expand Down
7 changes: 7 additions & 0 deletions test/integration/TestREST_JSON.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,13 @@ def wait_inf_state(self, state, timeout, incorrect_states=None, vm_ids=None):

return all_ok

def test_07_index(self):
resp = self.create_request("GET", "/")
self.assertEqual(resp.status_code, 200,
msg="ERROR getting IM index:" + resp.text)
res = json.loads(resp.text)
self.assertEqual(res['openapi'], '3.0.0')

def test_20_create(self):
radl = read_file_as_string('../files/test_simple.json')
resp = self.create_request("POST", "/infrastructures",
Expand Down
11 changes: 2 additions & 9 deletions test/unit/REST.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,15 +570,8 @@ def test_GeVersion(self):

def test_Index(self):
res = self.client.get('/')
self.assertEqual(res.status_code, 302)
self.assertEqual(res.headers['Location'], '/api/docs')
res = self.client.get('http://localhost/api/docs/')
self.assertEqual(res.status_code, 200)
self.assertIn("Swagger UI", res.text)
self.assertIn('"url": "/swagger.json"', res.text)
res = self.client.get('/swagger.json')
self.assertEqual(res.status_code, 200)
self.assertEqual(res.json["openapi"], "3.0.0")
self.assertEqual(res.json['openapi'], '3.0.0')
self.assertEqual(res.json['servers'][0]['url'], 'http://localhost/')

@patch("IM.InfrastructureManager.InfrastructureManager.CreateDiskSnapshot")
def test_CreateDiskSnapshot(self, CreateDiskSnapshot):
Expand Down

0 comments on commit 3ec1a9f

Please sign in to comment.