Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential undefined variable in swagger-ui.html (#565) #591

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ Releases prior to 0.3.0 were “best effort” filled out, but are missing
some info. If you see your contribution missing info, please open a PR
on the Changelog!

.. _section-1.3.1:
1.3.1
-----
.. _bug_fixes-1.3.1
Bug Fixes
~~~~~~~~~

::

* Add jinja test for potentially undefined variable in `swagger-ui.html`. Compatibility with jinja's StrictUndefined mode. (#565) [sloschert]


.. _section-1.3.0:
1.3.0
-----
Expand Down
4 changes: 2 additions & 2 deletions flask_restx/templates/swagger-ui.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
window.onload = function() {
const ui = window.ui = new SwaggerUIBundle({
url: "{{ specs_url }}",
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID is defined and config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
oauth2RedirectUrl: "{{ url_for('restx_doc.static', filename='oauth2-redirect.html', _external=True) }}",
{%- endif %}
validatorUrl: "{{ config.SWAGGER_VALIDATOR_URL }}" || null,
Expand All @@ -71,7 +71,7 @@
docExpansion: "{{ config.SWAGGER_UI_DOC_EXPANSION | default('none') }}"
})

{% if config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
{% if config.SWAGGER_UI_OAUTH_CLIENT_ID is defined and config.SWAGGER_UI_OAUTH_CLIENT_ID -%}
ui.initOAuth({
clientId: "{{ config.SWAGGER_UI_OAUTH_CLIENT_ID }}",
realm: "{{ config.SWAGGER_UI_OAUTH_REALM }}",
Expand Down