I've a composer.json with these packages:
"php": ">=7.4",
"ext-xml": "*",
"api-platform/core": "^2.7",
"beberlei/doctrineextensions": "1.0.19",
"doctrine/annotations": "^1.0",
"doctrine/collections": "~1.0",
"doctrine/doctrine-bundle": "~1.4",
"doctrine/doctrine-migrations-bundle": "^2.0",
"doctrine/event-manager": "~1.0",
"doctrine/orm": "^2.4.8",
"doctrine/persistence": "~1.0",
"exercise/htmlpurifier-bundle": "~3.0",
"fig/link-util": "^1.0",
"nelmio/api-doc-bundle": "4.11.1",
"nelmio/cors-bundle": "^2.3",
"php-imap/php-imap": "3.0.6",
"phpdocumentor/reflection-docblock": "^5.3",
"predis/predis": "^1.0",
"psr/cache": "~1.0",
"psr/container": "^1.0",
"psr/link": "^1.0",
"psr/log": "~1.0",
"psr/simple-cache": "^1.0",
"seld/jsonlint": "^1.9",
"sensio/framework-extra-bundle": "~6.0",
"snc/redis-bundle": "^2.0",
"symfony/asset": "~4.0",
"symfony/browser-kit": "~4.0",
"symfony/cache": "~4.0",
"symfony/css-selector": "~4.0",
"symfony/dom-crawler": "~4.0",
"symfony/dotenv": "^4.4|^5.0|^6.0",
"symfony/expression-language": "~4.0",
"symfony/flex": "^1.18",
"symfony/form": "~4.0",
"symfony/framework-bundle": "~4.0",
"symfony/http-client": "^5.2",
"symfony/lock": "~4.0",
"symfony/mailer": "~4.0",
"symfony/mime": "^4.0",
"symfony/monolog-bundle": "~3.0",
"symfony/polyfill-ctype": "~1.8",
"symfony/polyfill-intl-icu": "~1.0",
"symfony/polyfill-mbstring": "~1.0",
"symfony/polyfill-php72": "~1.5",
"symfony/polyfill-php74": "^1.24",
"symfony/property-access": "~4.0",
"symfony/property-info": "~4.0",
"symfony/security-bundle": "~4.0",
"symfony/serializer": "^4.0",
"symfony/swiftmailer-bundle": "^3.5",
"symfony/templating": "~4.0",
"symfony/translation": "~4.0",
"symfony/twig-bundle": "~4.0",
"symfony/ux-chartjs": "^2.6",
"symfony/validator": "~4.0",
"symfony/webpack-encore-bundle": "^1.8",
"twig/extensions": "~1.2",
"twig/twig": "^2.9"
},
So with "api-platform/core": "^2.7" and "nelmio/api-doc-bundle": "4.11.1". Api platform is already working, but I've added nelmio/api-doc-bundle now.
When I clear the production cache however, php gives the following error:
php -d memory_limit=800M bin/console cache:clear --env=prod
// Clearing the cache for the prod environment with debug false
In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
The service "nelmio_api_doc.describers.api_platform" has a dependency on a non-existent service "api_platform.openapi.normalizer".
According to php bin/console debug:container, api_platform.openapi.normalizer indeed does not exist, and nelmio_api_doc.describers.api_platform it points to this class:
nelmio_api_doc.describers.api_platform Nelmio\ApiDocBundle\Describer\ApiPlatformDescriber
When I open this vendor class in projectdir/vendor/nelmio/api-doc-bundle/Describer/ApiPlatformDescriber.php, all use statements do exist.
<?php
/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nelmio\ApiDocBundle\Describer;
use ApiPlatform\Core\Swagger\Serializer\DocumentationNormalizer;
use ApiPlatform\Documentation\DocumentationInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
final class ApiPlatformDescriber extends ExternalDocDescriber
{
public function __construct(DocumentationInterface $documentation, NormalizerInterface $normalizer)
{
if (!$normalizer->supportsNormalization($documentation, 'json')) {
throw new \InvalidArgumentException(sprintf('Argument 2 passed to %s() must implement %s and support normalization of %s. The normalizer provided is an instance of %s.', __METHOD__, NormalizerInterface::class, Documentation::class, get_class($normalizer)));
}
parent::__construct(function () use ($documentation, $normalizer) {
$documentation = (array) $normalizer->normalize(
$documentation,
null,
class_exists(DocumentationNormalizer::class) ? [DocumentationNormalizer::SPEC_VERSION => 3] : []
);
// TODO: remove this
// Temporary fix: zircote/swagger-php does no longer support 3.0.x with x > 0
unset($documentation['openapi']);
unset($documentation['basePath']);
unset($documentation['servers']);
return $documentation;
});
}
}
So why do I get the error message about the missing service? I can find nothing anywhre about this, except for decorating the service (https://github.com/api-platform/api-platform/issues/1729), which is not the case here.
It did mention at https://github.com/api-platform/api-platform/issues/1729 that api_platform.openapi.normalizer is an alias for api_platform.openapi.normalizer.api_gateway, so I added this to services.yaml:
api_platform:openapi:normalizer: '@api_platform.openapi.normalizer.api_gateway'
And now it appears as an alias in php bin/console debug:container, but still the exact same error message when I clear the cache.
In CheckExceptionOnInvalidReferenceBehaviorPass.php line 86:
The service "nelmio_api_doc.describers.api_platform" has a dependency on a non-existent service "api_platform.openapi.normalizer".
Any ideas?