From 62f62ec21e9350d6b6716ad538cc8cfdde90a871 Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 5 Feb 2021 23:05:01 +0100 Subject: [PATCH 1/4] OpenApi: fix #3997 do not use a name converter --- .../Bundle/Resources/config/openapi.xml | 22 ++++++++++++++++++- .../ApiPlatformExtensionTest.php | 2 ++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml b/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml index 8d2fc23d4ab..d09cba4a57a 100644 --- a/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml +++ b/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml @@ -5,8 +5,28 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> + + null + null + + + + + + + + + + + + + + + + - + + diff --git a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php index 96c0fea8597..e9f0cd8a86a 100644 --- a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php +++ b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php @@ -1329,6 +1329,8 @@ private function getBaseContainerBuilderProphecy(array $doctrineIntegrationsToLo $definitions[] = 'api_platform.swagger.normalizer.api_gateway'; $definitions[] = 'api_platform.swagger.normalizer.documentation'; $definitions[] = 'api_platform.openapi.options'; + $definitions[] = 'api_platform.openapi.object_normalizer'; + $definitions[] = 'api_platform.openapi.serializer'; $definitions[] = 'api_platform.openapi.normalizer'; $definitions[] = 'api_platform.openapi.normalizer.api_gateway'; $definitions[] = 'api_platform.openapi.factory'; From 2b9661fa520c455140a922c78b132981a6084b61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dunglas?= Date: Fri, 5 Feb 2021 23:39:02 +0100 Subject: [PATCH 2/4] simplify api_platform.openapi.normalizer service definition --- .../Bundle/Resources/config/openapi.xml | 37 +++++++++---------- .../ApiPlatformExtensionTest.php | 2 - 2 files changed, 17 insertions(+), 22 deletions(-) diff --git a/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml b/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml index d09cba4a57a..ec63780de2c 100644 --- a/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml +++ b/src/Bridge/Symfony/Bundle/Resources/config/openapi.xml @@ -5,27 +5,24 @@ xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd"> - - null - null - - - - - - - - - - - - - - - - - + + + + + + null + null + + + + + + + + + + diff --git a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php index e9f0cd8a86a..96c0fea8597 100644 --- a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php +++ b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php @@ -1329,8 +1329,6 @@ private function getBaseContainerBuilderProphecy(array $doctrineIntegrationsToLo $definitions[] = 'api_platform.swagger.normalizer.api_gateway'; $definitions[] = 'api_platform.swagger.normalizer.documentation'; $definitions[] = 'api_platform.openapi.options'; - $definitions[] = 'api_platform.openapi.object_normalizer'; - $definitions[] = 'api_platform.openapi.serializer'; $definitions[] = 'api_platform.openapi.normalizer'; $definitions[] = 'api_platform.openapi.normalizer.api_gateway'; $definitions[] = 'api_platform.openapi.factory'; From 53c5068cdb2b799d276a634c138f8e61fad8f700 Mon Sep 17 00:00:00 2001 From: soyuka Date: Sat, 6 Feb 2021 00:00:10 +0100 Subject: [PATCH 3/4] fix tests --- .../Bundle/DependencyInjection/ApiPlatformExtensionTest.php | 4 ++++ tests/OpenApi/Serializer/OpenApiNormalizerTest.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php index 96c0fea8597..91dc99b210d 100644 --- a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php +++ b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php @@ -1335,6 +1335,10 @@ private function getBaseContainerBuilderProphecy(array $doctrineIntegrationsToLo $definitions[] = 'api_platform.openapi.command'; $definitions[] = 'api_platform.swagger_ui.context'; $definitions[] = 'api_platform.swagger_ui.action'; + + $containerBuilderProphecy->setDefinition(Argument::that(static function ($arg) { + return 0 === strpos($arg, '.'); + }), Argument::type(Definition::class))->shouldBeCalled(); } // has jsonld diff --git a/tests/OpenApi/Serializer/OpenApiNormalizerTest.php b/tests/OpenApi/Serializer/OpenApiNormalizerTest.php index 84bae5bdb59..d3354d9759b 100644 --- a/tests/OpenApi/Serializer/OpenApiNormalizerTest.php +++ b/tests/OpenApi/Serializer/OpenApiNormalizerTest.php @@ -185,5 +185,7 @@ public function testNormalize() // Make sure things are sorted $this->assertEquals(array_keys($openApiAsArray['paths']), ['/dummies', '/dummies/{id}', '/zorros', '/zorros/{id}']); + // Test name converter doesn't rename this property + $this->assertArrayHasKey('requestBody', $openApiAsArray['paths']['/dummies']['post']); } } From cb9b2e53b95fdbf1978d69ff91c4571dc1b72969 Mon Sep 17 00:00:00 2001 From: soyuka Date: Sat, 6 Feb 2021 00:01:32 +0100 Subject: [PATCH 4/4] fix tests --- .../DependencyInjection/ApiPlatformExtensionTest.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php index 91dc99b210d..38f379dd726 100644 --- a/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php +++ b/tests/Bridge/Symfony/Bundle/DependencyInjection/ApiPlatformExtensionTest.php @@ -1335,10 +1335,6 @@ private function getBaseContainerBuilderProphecy(array $doctrineIntegrationsToLo $definitions[] = 'api_platform.openapi.command'; $definitions[] = 'api_platform.swagger_ui.context'; $definitions[] = 'api_platform.swagger_ui.action'; - - $containerBuilderProphecy->setDefinition(Argument::that(static function ($arg) { - return 0 === strpos($arg, '.'); - }), Argument::type(Definition::class))->shouldBeCalled(); } // has jsonld @@ -1366,6 +1362,13 @@ private function getBaseContainerBuilderProphecy(array $doctrineIntegrationsToLo $definitions[] = 'api_platform.jsonld.normalizer.object'; } + // Ignore inlined services + $containerBuilderProphecy->setDefinition(Argument::that(static function (string $arg) { + return 0 === strpos($arg, '.'); + }), Argument::type(Definition::class))->should(function () { + return true; + }); + foreach ($definitions as $definition) { $containerBuilderProphecy->setDefinition($definition, Argument::type(Definition::class))->shouldBeCalled(); }