diff --git a/docs/changelog.rst b/docs/changelog.rst index 832a721..a2e3958 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -11,6 +11,7 @@ Changelog - **ADDED:** added the ``SPEC_URL`` setting for controlling the download link in ``swagger-ui`` and ``ReDoc`` - **ADDED:** updated ``ReDoc`` settings (added ``NATIVE_SCROLLBARS`` and ``REQUIRED_PROPS_FIRST``) +- **ADDED:** added ``extra_styles`` and ``extra_scripts`` blocks to ui templates (:issue:`178`) - **IMPROVED:** updated ``swagger-ui`` to version 3.18.2 - **IMPROVED:** updated ``ReDoc`` to version 2.0.0-alpha.37 - **FIXED:** stopped generating invalid OpenAPI by improper placement of ``readOnly`` Schemas diff --git a/docs/custom_ui.rst b/docs/custom_ui.rst index ed5c3d5..c81d5ad 100644 --- a/docs/custom_ui.rst +++ b/docs/custom_ui.rst @@ -2,6 +2,17 @@ Customizing the web UI ###################### -There is currently no pluggable way of customizing the web UI apart from the settings available in -:ref:`swagger-ui-settings` and :ref:`redoc-ui-settings`. If you really need to, you can override one of the -``drf-yasg/swagger-ui.html`` or ``drf-yasg/redoc.html`` templates that are used for rendering. +The web UI can be customized using the settings available in :ref:`swagger-ui-settings` and :ref:`redoc-ui-settings`. + +You can also extend one of the ``drf-yasg/swagger-ui.html`` or ``drf-yasg/redoc.html`` templates that are used for +rendering. The customizable blocks are currently limited to: + +{% block extra_styles %} + additional stylesheets + +{% block extra_scripts %} + additional scripts + +{% block user_context_message %} + *(swagger-ui session auth only)* + logged in user message diff --git a/src/drf_yasg/templates/drf-yasg/redoc.html b/src/drf_yasg/templates/drf-yasg/redoc.html index 5a5b527..34f4a2f 100644 --- a/src/drf_yasg/templates/drf-yasg/redoc.html +++ b/src/drf_yasg/templates/drf-yasg/redoc.html @@ -7,12 +7,18 @@ + {% block extra_styles %} + {# -- Add any additional CSS scripts here -- #} + {% endblock %}
- + - - - + + + +{% block extra_scripts %} + {# -- Add any additional scripts here -- #} +{% endblock %}