Process review comments PR#2464

- When visiting root of WEB_API, the swaggerui is shown
- simplify the condition for endpoint WEB_API
main
Dimitri Huisman 2 years ago committed by Alexander Graf
parent 39b0d44079
commit 3cb8358090
No known key found for this signature in database
GPG Key ID: B8A9DC143E075629

@ -1,8 +1,7 @@
from flask import redirect, url_for from flask import redirect, url_for, Blueprint
from flask_restx import apidoc from flask_restx import apidoc
from . import v1 as APIv1 from . import v1 as APIv1
def register(app, web_api_root): def register(app, web_api_root):
APIv1.app = app 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)}') app.register_blueprint(APIv1.blueprint, url_prefix=f'{web_api_root}/v{int(APIv1.VERSION)}')
# add redirect to current api version # add redirect to current api version
@app.route(f'{web_api_root}/') redirect_api = Blueprint('redirect_api', __name__)
@redirect_api.route('/')
def redir(): def redir():
return redirect(url_for(f'{APIv1.blueprint.name}.root')) return redirect(url_for(f'{APIv1.blueprint.name}.root'))
app.register_blueprint(redirect_api, url_prefix=f'{web_api_root}')
# swagger ui config # swagger ui config
app.config.SWAGGER_UI_DOC_EXPANSION = 'list' app.config.SWAGGER_UI_DOC_EXPANSION = 'list'

@ -21,7 +21,7 @@ api = Api(
validate=True, validate=True,
authorizations=authorization, authorizations=authorization,
security='Bearer', security='Bearer',
doc='/swaggerui/' doc='/'
) )
response_fields = api.model('Response', { response_fields = api.model('Response', {

@ -244,7 +244,7 @@ http {
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if API == 'true' %} {% if API %}
location ~ {{ WEB_API }} { location ~ {{ WEB_API }} {
include /etc/nginx/proxy.conf; include /etc/nginx/proxy.conf;
proxy_pass http://$admin; proxy_pass http://$admin;

Loading…
Cancel
Save