Skip to content

Commit 32e6c07

Browse files
ersin-demirtasdunglas
authored andcommitted
Allow custom stylesheets to be appended or replaced. (#2469)
I understand that there is a way to overwrite the twig bundle templates through Symfony but there no block element, proposing to add blocks to allow custom stylesheet and javascript. Let me know if I am thinking wrong.
1 parent a9bc507 commit 32e6c07

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/Bridge/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44
<meta charset="UTF-8">
55
<title>{% if title %}{{ title }} - {% endif %}API Platform</title>
66

7-
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700">
8-
<link rel="stylesheet" href="{{ asset('bundles/apiplatform/swagger-ui/swagger-ui.css') }}">
9-
<link rel="stylesheet" href="{{ asset('bundles/apiplatform/style.css') }}">
10-
7+
{% block stylesheet %}
8+
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:400,700|Source+Code+Pro:300,600|Titillium+Web:400,600,700">
9+
<link rel="stylesheet" href="{{ asset('bundles/apiplatform/swagger-ui/swagger-ui.css') }}">
10+
<link rel="stylesheet" href="{{ asset('bundles/apiplatform/style.css') }}">
11+
{% endblock %}
12+
1113
{# json_encode(65) is for JSON_UNESCAPED_SLASHES|JSON_HEX_TAG to avoid JS XSS #}
1214
<script id="swagger-data" type="application/json">{{ swagger_data|json_encode(65)|raw }}</script>
1315
</head>
@@ -74,14 +76,16 @@
7476
</div>
7577
</div>
7678

77-
{% if (reDocEnabled and not swaggerUiEnabled) or (reDocEnabled and 're_doc' == active_ui) %}
78-
<script src="{{ asset('bundles/apiplatform/redoc/redoc.standalone.js') }}"></script>
79-
<script src="{{ asset('bundles/apiplatform/init-redoc-ui.js') }}"></script>
80-
{% elseif (swaggerUiEnabled) %}
81-
<script src="{{ asset('bundles/apiplatform/swagger-ui/swagger-ui-bundle.js') }}"></script>
82-
<script src="{{ asset('bundles/apiplatform/swagger-ui/swagger-ui-standalone-preset.js') }}"></script>
83-
<script src="{{ asset('bundles/apiplatform/init-swagger-ui.js') }}"></script>
84-
{% endif %}
79+
{% block javascript %}
80+
{% if (reDocEnabled and not swaggerUiEnabled) or (reDocEnabled and 're_doc' == active_ui) %}
81+
<script src="{{ asset('bundles/apiplatform/redoc/redoc.standalone.js') }}"></script>
82+
<script src="{{ asset('bundles/apiplatform/init-redoc-ui.js') }}"></script>
83+
{% elseif (swaggerUiEnabled) %}
84+
<script src="{{ asset('bundles/apiplatform/swagger-ui/swagger-ui-bundle.js') }}"></script>
85+
<script src="{{ asset('bundles/apiplatform/swagger-ui/swagger-ui-standalone-preset.js') }}"></script>
86+
<script src="{{ asset('bundles/apiplatform/init-swagger-ui.js') }}"></script>
87+
{% endif %}
88+
{% endblock %}
8589

8690
</body>
8791
</html>

0 commit comments

Comments
 (0)