From 8fe78725735dc2399cbf63a0a2a7b728b332dfde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Crist=C3=B2fol=20Torrens?= Date: Wed, 9 Jun 2021 19:15:48 +0200 Subject: [PATCH] feat: Allow using custom Swagger template for SwaggerView. (#1639) --- docs/config.rst | 2 ++ flask_appbuilder/api/manager.py | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/config.rst b/docs/config.rst index bde01df34b..b579c26b9f 100755 --- a/docs/config.rst +++ b/docs/config.rst @@ -241,6 +241,8 @@ Use config.py to configure the following parameters. By default it will use SQLL +----------------------------------------+--------------------------------------------+-----------+ | FAB_API_SWAGGER_UI | Enables a Swagger UI view (Boolean) | No | +----------------------------------------+--------------------------------------------+-----------+ +| FAB_API_SWAGGER_TEMPLATE | Path of your custom Swagger Template | No | ++----------------------------------------+--------------------------------------------+-----------+ | FAB_API_ALLOW_JSON_QS | Allow query string parameters to be JSON | | | | Default is True (Boolean) | No | +----------------------------------------+--------------------------------------------+-----------+ diff --git a/flask_appbuilder/api/manager.py b/flask_appbuilder/api/manager.py index 09f14579f0..8097592604 100644 --- a/flask_appbuilder/api/manager.py +++ b/flask_appbuilder/api/manager.py @@ -86,7 +86,9 @@ class SwaggerView(BaseView): @has_access def show(self, version): return self.render_template( - "appbuilder/swagger/swagger.html", + self.appbuilder.app.config.get( + "FAB_API_SWAGGER_TEMPLATE", "appbuilder/swagger/swagger.html" + ), openapi_uri=self.openapi_uri.format(version), )