From 3cb8358090824e72e845fa829780699f161e0c60 Mon Sep 17 00:00:00 2001 From: Dimitri Huisman Date: Fri, 23 Dec 2022 13:56:19 +0000 Subject: [PATCH] Process review comments PR#2464 - When visiting root of WEB_API, the swaggerui is shown - simplify the condition for endpoint WEB_API --- core/admin/mailu/api/__init__.py | 7 ++++--- core/admin/mailu/api/v1/__init__.py | 2 +- core/nginx/conf/nginx.conf | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/core/admin/mailu/api/__init__.py b/core/admin/mailu/api/__init__.py index 3fd9d495..da7325ae 100644 --- a/core/admin/mailu/api/__init__.py +++ b/core/admin/mailu/api/__init__.py @@ -1,8 +1,7 @@ -from flask import redirect, url_for +from flask import redirect, url_for, Blueprint from flask_restx import apidoc from . import v1 as APIv1 - def register(app, web_api_root): APIv1.app = app @@ -12,9 +11,11 @@ def register(app, web_api_root): app.register_blueprint(APIv1.blueprint, url_prefix=f'{web_api_root}/v{int(APIv1.VERSION)}') # add redirect to current api version - @app.route(f'{web_api_root}/') + redirect_api = Blueprint('redirect_api', __name__) + @redirect_api.route('/') def redir(): return redirect(url_for(f'{APIv1.blueprint.name}.root')) + app.register_blueprint(redirect_api, url_prefix=f'{web_api_root}') # swagger ui config app.config.SWAGGER_UI_DOC_EXPANSION = 'list' diff --git a/core/admin/mailu/api/v1/__init__.py b/core/admin/mailu/api/v1/__init__.py index 5cb1fc82..44b6ec57 100644 --- a/core/admin/mailu/api/v1/__init__.py +++ b/core/admin/mailu/api/v1/__init__.py @@ -21,7 +21,7 @@ api = Api( validate=True, authorizations=authorization, security='Bearer', - doc='/swaggerui/' + doc='/' ) response_fields = api.model('Response', { diff --git a/core/nginx/conf/nginx.conf b/core/nginx/conf/nginx.conf index 722e5e50..463cee20 100644 --- a/core/nginx/conf/nginx.conf +++ b/core/nginx/conf/nginx.conf @@ -244,7 +244,7 @@ http { {% endif %} {% endif %} - {% if API == 'true' %} + {% if API %} location ~ {{ WEB_API }} { include /etc/nginx/proxy.conf; proxy_pass http://$admin;