Skip to content

Commit d667690

Browse files
authored
fix(symfony): load swagger_ui when enabled (#6424)
1 parent ff53356 commit d667690

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Symfony/Bundle/DependencyInjection/ApiPlatformExtension.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,9 @@ private function registerSwaggerConfiguration(ContainerBuilder $container, array
536536
$loader->load('symfony/swagger_ui.xml');
537537
}
538538

539-
$loader->load('state/swagger_ui.xml');
539+
if ($config['enable_swagger_ui']) {
540+
$loader->load('state/swagger_ui.xml');
541+
}
540542

541543
if (!$config['enable_swagger_ui'] && !$config['enable_re_doc']) {
542544
// Remove the listener but keep the controller to allow customizing the path of the UI

tests/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php

+10
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,16 @@ public function testSwaggerConfiguration(): void
507507
$this->assertServiceHasTags('api_platform.swagger.listener.ui', ['kernel.event_listener']);
508508
}
509509

510+
public function testSwaggerUiDisabled(): void
511+
{
512+
$config = self::DEFAULT_CONFIG;
513+
$config['api_platform']['enable_swagger_ui'] = false;
514+
515+
(new ApiPlatformExtension())->load($config, $this->container);
516+
517+
$this->assertNotContainerHasService('api_platform.swagger_ui.provider');
518+
}
519+
510520
public function testJsonApiConfiguration(): void
511521
{
512522
$config = self::DEFAULT_CONFIG;

0 commit comments

Comments
 (0)