Skip to content

Commit a45ac1a

Browse files
committed
Fix potential undefined variable in swagger-ui.html (python-restx#565)
* Add jinja test for potentially undefined variable in `swagger-ui.html`. Compatibility with jinja's StrictUndefined mode. * Add CHANGELOG.rst entry
1 parent b38a7d9 commit a45ac1a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

CHANGELOG.rst

+12
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ Releases prior to 0.3.0 were “best effort” filled out, but are missing
2525
some info. If you see your contribution missing info, please open a PR
2626
on the Changelog!
2727

28+
.. _section-1.3.1:
29+
1.3.1
30+
-----
31+
.. _bug_fixes-1.3.1
32+
Bug Fixes
33+
~~~~~~~~~
34+
35+
::
36+
37+
* Add jinja test for potentially undefined variable in `swagger-ui.html`. Compatibility with jinja's StrictUndefined mode. (#565) [sloschert]
38+
39+
2840
.. _section-1.3.0:
2941
1.3.0
3042
-----

flask_restx/templates/swagger-ui.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
window.onload = function() {
5252
const ui = window.ui = new SwaggerUIBundle({
5353
url: "{{ specs_url }}",
54-
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
54+
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID is defined and config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
5555
oauth2RedirectUrl: "{{ url_for('restx_doc.static', filename='oauth2-redirect.html', _external=True) }}",
5656
{%- endif %}
5757
validatorUrl: "{{ config.SWAGGER_VALIDATOR_URL }}" || null,
@@ -71,7 +71,7 @@
7171
docExpansion: "{{ config.SWAGGER_UI_DOC_EXPANSION | default('none') }}"
7272
})
7373

74-
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
74+
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID is defined and config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
7575
ui.initOAuth({
7676
clientId: "{{ config.SWAGGER_UI_OAUTH_CLIENT_ID }}",
7777
realm: "{{ config.SWAGGER_UI_OAUTH_REALM }}",

0 commit comments

Comments
 (0)