Circular reference trying to decorate api_platform.swagger.normalizer.documentation
See original GitHub issueHello,
I tried to decorate api_platform.swagger.normalizer.documentation, as seen here https://api-platform.com/docs/core/swagger/ and ran into a circular reference :
Circular reference detected for service "App\Swagger\SwaggerDecorator", path: "App\Swagger\SwaggerDecorator -> serializer -> App\Swagger\SwaggerDecorator".
Im using symfony4 and api-pack v1.0.1
services:
App\Swagger\SwaggerDecorator:
decorates: 'api_platform.swagger.normalizer.documentation'
arguments: [ '@App\Swagger\SwaggerDecorator.inner' ]
autoconfigure: false
namespace App\Swagger;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
final class SwaggerDecorator implements NormalizerInterface
{
private $decorated;
public function __construct(NormalizerInterface $decorated)
{
$this->decorated = $decorated;
}
public function normalize($object, $format = null, array $context = [])
{
$docs = $this->decorated->normalize($object, $format, $context);
return $docs;
}
public function supportsNormalization($data, $format = null)
{
return $this->decorated->supportsNormalization($data, $format);
}
}
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:7
Top Results From Across the Web
Circular reference problem with decorated service
This is an issue with Symfony Dependency Injection component on version 5.3.7. https://github.com/symfony/symfony/issues/42792.
Read more >The Serialization Process - API Platform
The API Platform Serializer is extendable. You can register custom normalizers and encoders in order to support other formats. You can also decorate...
Read more >Problem Swagger with Circular Reference | Layer7 API ...
When I make a cyclic reference in swagger, and try to open the documentation in the developer menu, an error occurs on the...
Read more >api-platform/api-platform - Gitter
I used SonataMediaBundle and I have a circular reference when I try to get a Gallery Entity. Anyone know how to use SonataMediaBundle...
Read more >Relating Resources > API Platform - SymfonyCasts
Let's try it! Move over and refresh the docs. But before we look at CheeseListing , let's create a User so we have...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I found the issue, the service was autowired, i moved the service declaration in service.yaml instead of an imported file
Hi @coldic3,
I think it is important to configure decorators after “_defaults” and “App” sections (autoconfigure + autowiring + src classes as services) into services.yaml file :
This configuration works :
In your example, your external configurations were imported before “_defaults” section and it could not work.