mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-03 08:09:25 +03:00
c771c684a8
* Allow to override certain parts of the template * Twig template can be defined via config * Blocks can be used to override/extend only parts of the template * Fix spelling in documentation * Fix extension configuration tree * Fix unit tests by making constructor argument optional * Add fonts block and split swagger initialization into own block * Fix code style * Remove Google fonts, remove configuration and add changelog entry * Remove template argument from service definition * Add correct path for overriding template * Move re-add of Google Fonts to FAQ section in documentation. * Remove unused class import
39 lines
1.4 KiB
ReStructuredText
39 lines
1.4 KiB
ReStructuredText
Customization
|
|
=============
|
|
|
|
The look and feel of the Swagger UI can be customized.
|
|
|
|
|
|
Overwrite Twig Template
|
|
-----------------------
|
|
|
|
If you want to customize parts of the template, you can create your own Twig template.
|
|
This allows to change the title, the header, add additional or replace existing styles or scripts.
|
|
|
|
Take a look at the Twig documentation `how to extend templates <https://twig.symfony.com/doc/2.x/tags/extends.html>`_.
|
|
|
|
The following example will add additional scripts and a custom style to the template.
|
|
Just create a file ``templates/bundles/NelmioApiDocBundle/SwaggerUI/index.html.twig``.
|
|
|
|
.. code-block:: twig
|
|
|
|
{# templates/bundles/NelmioApiDocBundle/views/SwaggerUI/index.html.twig #}
|
|
|
|
{#
|
|
To avoid a "reached nested level" error an exclamation mark `!` has to be added
|
|
See https://symfony.com/blog/new-in-symfony-3-4-improved-the-overriding-of-templates
|
|
#}
|
|
{% extends '@!NelmioApiDoc/SwaggerUi/index.html.twig' %}
|
|
|
|
{% block stylesheets %}
|
|
{{ parent() }}
|
|
<link rel="stylesheet" href="{{ asset('css/custom-swagger-styles.css') }}">
|
|
{% endblock stylesheets %}
|
|
|
|
{% block javascripts %}
|
|
{{ parent() }}
|
|
<script type="text/javascript" src="{{ asset('js/custom-request-signer.js') }}"></script>
|
|
{% endblock javascripts %}
|
|
|
|
You can have a look at the original template to see which blocks can be overridden.
|