Skip to content

Commit 63e94f9

Browse files
cduran433dunglas
authored andcommitted
Add how to override swagger templates (#435)
* Add how to override swagger templates * Improve the "Overriding the UI Template" section
1 parent a326611 commit 63e94f9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

core/swagger.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,20 @@ $ docker-compose exec php bin/console api:swagger:export
261261
$ docker-compose exec php bin/console api:swagger:export --yaml
262262
# Swagger documentation in YAML format...
263263
```
264+
265+
## Overriding the UI Template
266+
267+
As described [in the Symfony documentation](https://symfony.com/doc/current/templating/overriding.html), it's possible to override the Twig template that loads Swagger UI and renders the documentation:
268+
269+
```twig
270+
{# templates/bundles/ApiPlatformBundle/SwaggerUi/index.html.twig #}
271+
<!DOCTYPE html>
272+
<html>
273+
<head>
274+
<meta charset="UTF-8">
275+
<title>{% if title %}{{ title }} {% endif %}My custom template</title>
276+
{# ... #}
277+
</html>
278+
```
279+
280+
You may want to copy the [one shipped with API Platform](https://github.com/api-platform/core/blob/master/src/Bridge/Symfony/Bundle/Resources/views/SwaggerUi/index.html.twig) and customize it.

0 commit comments

Comments
 (0)