From 444c4608addbafb51da7458c6e81d15203bbf6e8 Mon Sep 17 00:00:00 2001 From: Guilhem Niot Date: Sat, 17 Mar 2018 14:16:00 +0100 Subject: [PATCH] Fix Api-Platform support --- Describer/ApiPlatformDescriber.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Describer/ApiPlatformDescriber.php b/Describer/ApiPlatformDescriber.php index f36ebdf..88fc6cf 100644 --- a/Describer/ApiPlatformDescriber.php +++ b/Describer/ApiPlatformDescriber.php @@ -12,13 +12,18 @@ namespace Nelmio\ApiDocBundle\Describer; use ApiPlatform\Core\Documentation\Documentation; +use ApiPlatform\Core\Swagger\Serializer\ApiGatewayNormalizer; use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer; use Symfony\Component\Routing\Generator\UrlGeneratorInterface; final class ApiPlatformDescriber extends ExternalDocDescriber { - public function __construct(Documentation $documentation, DocumentationNormalizer $normalizer, UrlGeneratorInterface $urlGenerator) + public function __construct(Documentation $documentation, $normalizer, UrlGeneratorInterface $urlGenerator) { + if (!$normalizer instanceof ApiGatewayNormalizer && !$normalizer instanceof DocumentationNormalizer) { + throw new \LogicException(sprintf('Argument $normalizer of %s must be an instance of %s or %s. %s provided.', __METHOD__, ApiGatewayNormalizer::class, DocumentationNormalizer::class, get_class($normalizer))); + } + parent::__construct(function () use ($documentation, $normalizer, $urlGenerator) { $documentation = (array) $normalizer->normalize($documentation); unset($documentation['basePath']);