Skip to content

Commit

Permalink
Merge pull request apiflask#339 from apiflask/elements-router
Browse files Browse the repository at this point in the history
  • Loading branch information
greyli authored Aug 13, 2022
2 parents 954e372 + 3732526 commit 0ee3a91
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
7 changes: 7 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@
Released: -


## Version 1.1.2

Released: 2022/8/13

- Set default Elements router to `hash` to fix incorrect path updates.


## Version 1.1.1

Released: 2022/8/3
Expand Down
6 changes: 6 additions & 0 deletions src/apiflask/ui_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,12 @@
<elements-api
apiDescriptionUrl="{{ url_for('openapi.spec') }}"
layout="{{ config.ELEMENTS_LAYOUT }}"
{% if config.ELEMENTS_CONFIG and 'router' in config.ELEMENTS_CONFIG %}
{% set router = config.ELEMENTS_CONFIG['router'] %}
{% else %}
{% set router = 'hash' %}
{% endif %}
router={{ router | tojson }}
{% if config.ELEMENTS_CONFIG %}
{% for key, value in config.ELEMENTS_CONFIG.items() %}
{{ key }}={{ value | tojson }}
Expand Down
6 changes: 6 additions & 0 deletions tests/test_settings_api_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ def test_swagger_ui_oauth_config(app, client):

def test_elements_config():
app = APIFlask(__name__, docs_ui='elements')

rv = app.test_client().get('/docs')
assert rv.status_code == 200
# test default router
assert b'router="hash"' in rv.data

app.config['ELEMENTS_CONFIG'] = {
'hideTryIt': False,
'router': 'memory'
Expand Down

0 comments on commit 0ee3a91

Please sign in to comment.