Skip to content

Commit 7daef8e

Browse files
authored
chore: only support swagger.versions 3 in configuration (#4870)
1 parent 28f690e commit 7daef8e

File tree

3 files changed

+6
-31
lines changed

3 files changed

+6
-31
lines changed

src/Symfony/Bundle/Command/OpenApiCommand.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
use ApiPlatform\OpenApi\Factory\OpenApiFactoryInterface;
1717
use Symfony\Component\Console\Command\Command;
18-
use Symfony\Component\Console\Input\ArrayInput;
1918
use Symfony\Component\Console\Input\InputInterface;
2019
use Symfony\Component\Console\Input\InputOption;
2120
use Symfony\Component\Console\Output\OutputInterface;
@@ -52,19 +51,6 @@ protected function configure(): void
5251
*/
5352
protected function execute(InputInterface $input, OutputInterface $output): int
5453
{
55-
// Backwards compatibility
56-
if (2 === $specVersion = (int) $input->getOption('spec-version')) {
57-
$command = $this->getApplication()->find('api:swagger:export');
58-
59-
return $command->run(new ArrayInput([
60-
'command' => 'api:swagger:export',
61-
'--spec-version' => $specVersion,
62-
'--yaml' => $input->getOption('yaml'),
63-
'--output' => $input->getOption('output'),
64-
'--api-gateway' => $input->getOption('api-gateway'),
65-
]), $output);
66-
}
67-
6854
$filesystem = new Filesystem();
6955
$io = new SymfonyStyle($input, $output);
7056
$data = $this->normalizer->normalize($this->openApiFactory->__invoke(), 'json');

src/Symfony/Bundle/DependencyInjection/Configuration.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -248,16 +248,16 @@ private function addGraphQlSection(ArrayNodeDefinition $rootNode): void
248248

249249
private function addSwaggerSection(ArrayNodeDefinition $rootNode): void
250250
{
251-
$defaultVersions = [2, 3];
251+
$supportedVersions = [3];
252252

253253
$rootNode
254254
->children()
255255
->arrayNode('swagger')
256256
->addDefaultsIfNotSet()
257257
->children()
258258
->arrayNode('versions')
259-
->info('The active versions of Open API to be exported or used in the swagger_ui. The first value is the default.')
260-
->defaultValue($defaultVersions)
259+
->info('The active versions of OpenAPI to be exported or used in Swagger UI. The first value is the default.')
260+
->defaultValue($supportedVersions)
261261
->beforeNormalization()
262262
->always(static function ($v): array {
263263
if (!\is_array($v)) {
@@ -272,8 +272,8 @@ private function addSwaggerSection(ArrayNodeDefinition $rootNode): void
272272
})
273273
->end()
274274
->validate()
275-
->ifTrue(static fn($v): bool => $v !== array_intersect($v, $defaultVersions))
276-
->thenInvalid(sprintf('Only the versions %s are supported. Got %s.', implode(' and ', $defaultVersions), '%s'))
275+
->ifTrue(static fn($v): bool => $v !== array_intersect($v, $supportedVersions))
276+
->thenInvalid(sprintf('Only the versions %s are supported. Got %s.', implode(' and ', $supportedVersions), '%s'))
277277
->end()
278278
->prototype('scalar')->end()
279279
->end()

tests/Symfony/Bundle/DependencyInjection/ConfigurationTest.php

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private function runDefaultConfigTests(array $doctrineIntegrationsToLoad = ['orm
143143
'pkce' => false,
144144
],
145145
'swagger' => [
146-
'versions' => [2, 3],
146+
'versions' => [3],
147147
'api_keys' => [],
148148
'swagger_ui_extra_configuration' => [],
149149
],
@@ -330,17 +330,6 @@ public function testSwaggerVersionConfig(): void
330330
$this->assertArrayHasKey('versions', $config['swagger']);
331331
$this->assertEquals([3], $config['swagger']['versions']);
332332

333-
$config = $this->processor->processConfiguration($this->configuration, [
334-
'api_platform' => [
335-
'swagger' => [
336-
'versions' => 2,
337-
],
338-
],
339-
]);
340-
341-
$this->assertArrayHasKey('versions', $config['swagger']);
342-
$this->assertEquals([2], $config['swagger']['versions']);
343-
344333
$this->expectException(InvalidConfigurationException::class);
345334
$this->expectExceptionMessageMatches('/Only the versions .+ are supported. Got .+./');
346335

0 commit comments

Comments
 (0)