Skip to content

Commit a69ccbd

Browse files
authored
Configurable asset package (#1186)
1 parent 10d8d81 commit a69ccbd

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

core/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ api_platform:
2525
# Specify a name converter to use.
2626
name_converter: ~
2727

28+
# Specify an asset package name to use.
29+
asset_package: null
30+
2831
# Specify a path name generator to use.
2932
path_segment_name_generator: 'api_platform.path_segment_name_generator.underscore'
3033

core/openapi.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,31 @@ swagger_ui:
402402
403403
Change `/docs` to the URI you wish Swagger to be accessible on.
404404

405+
## Using a custom Asset Package in Swagger UI
406+
407+
Sometimes you may want to use a different [Asset Package](https://symfony.com/doc/current/reference/configuration/framework.html#packages) for the Swagger UI. In this way you'll have more fine-grained control over the asset url generations. This is useful i.e. if you want to use different base path, base url or asset versioning strategy.
408+
409+
Specify a custom asset package name:
410+
411+
```yaml
412+
# config/packages/api_platform.yaml
413+
api_platform:
414+
asset_package: 'api_platform'
415+
```
416+
417+
Set or override asset properties per package:
418+
419+
```yaml
420+
# config/packages/framework.yaml
421+
framework:
422+
# ...
423+
assets:
424+
base_path: '/custom_base_path' # the default
425+
packages:
426+
api_platform:
427+
base_path: '/'
428+
```
429+
405430
## Overriding the UI Template
406431

407432
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:

0 commit comments

Comments
 (0)