Skip to content

Commit

Permalink
Respect assets mode config in controller (#2280)
Browse files Browse the repository at this point in the history
| 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.
  • Loading branch information
HypeMC committed May 29, 2024
1 parent 2d45e53 commit 9379c44
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/Controller/SwaggerUiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions tests/Functional/TestKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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' => [
Expand Down

0 comments on commit 9379c44

Please sign in to comment.