From 9379c44da4b4e6ef36a81f3135d3d158838a7c16 Mon Sep 17 00:00:00 2001 From: HypeMC <2445045+HypeMC@users.noreply.github.com> Date: Wed, 29 May 2024 09:12:15 +0200 Subject: [PATCH] Respect assets mode config in controller (#2280) | Q | A | |---------------|---------------------------------------------------------------------------------------------------------------------------| | Bug fix? | yes | New feature? | no | Deprecations? | no | Issues | - Currently the `SwaggerUiController` doesn't respect the `assets_mode` configuration added in #2251. ```yaml nelmio_api_doc: html_config: assets_mode: cdn ``` As far as I can tell, there's no reason for the default any more as it can be set through the configuration and overridden in the `DumpCommand` command using the `html-config` option. --- src/Controller/SwaggerUiController.php | 2 -- tests/Functional/TestKernel.php | 4 ++++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Controller/SwaggerUiController.php b/src/Controller/SwaggerUiController.php index dac206ac4..02cbfa6cc 100644 --- a/src/Controller/SwaggerUiController.php +++ b/src/Controller/SwaggerUiController.php @@ -12,7 +12,6 @@ namespace Nelmio\ApiDocBundle\Controller; use Nelmio\ApiDocBundle\Exception\RenderInvalidArgumentException; -use Nelmio\ApiDocBundle\Render\Html\AssetsMode; use Nelmio\ApiDocBundle\Render\RenderOpenApi; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -35,7 +34,6 @@ public function __invoke(Request $request, string $area = 'default'): Response try { $response = new Response( $this->renderOpenApi->renderFromRequest($request, RenderOpenApi::HTML, $area, [ - 'assets_mode' => AssetsMode::BUNDLE, 'ui_renderer' => $this->uiRenderer, ]), Response::HTTP_OK, diff --git a/tests/Functional/TestKernel.php b/tests/Functional/TestKernel.php index 863792b43..2e6d96b08 100644 --- a/tests/Functional/TestKernel.php +++ b/tests/Functional/TestKernel.php @@ -18,6 +18,7 @@ use Hateoas\Configuration\Embedded; use JMS\SerializerBundle\JMSSerializerBundle; use Nelmio\ApiDocBundle\NelmioApiDocBundle; +use Nelmio\ApiDocBundle\Render\Html\AssetsMode; use Nelmio\ApiDocBundle\Tests\Functional\Entity\BazingaUser; use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex80; use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex81; @@ -242,6 +243,9 @@ protected function configureContainer(ContainerBuilder $c, LoaderInterface $load // Filter routes $c->loadFromExtension('nelmio_api_doc', [ + 'html_config' => [ + 'assets_mode' => AssetsMode::BUNDLE, + ], 'use_validation_groups' => boolval(self::USE_VALIDATION_GROUPS === $this->flag), 'documentation' => [ 'info' => [