You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description
When using API Platform combined with Elasticsearch, it will prioritize the ItemNormalizer to allow documents from Elastic to be normalized as well. However, the method signature of this class does not comply with its parents, which means that if somewhere else you use a normalizer through the NormalizerInterface DI, you could end up with this error:
ApiPlatform\Elasticsearch\Serializer\ItemNormalizer::normalize(): Return value must be of type array, string returned
How to reproduce
Use API Platform with Elasticsearch enabled
Inject the normalizer in a random controller using DI: private readonly NormalizerInterface $normalizer
Try to normalize an entity manually: $this->normalizer->normalize($entity, null, ['groups' => ['example']]);
Possible Solution
Change the method signature of the ElasticSearch ItemNormalizer. Located at ApiPlatform\Elasticsearch\Serializer\ItemNormalizer.
The text was updated successfully, but these errors were encountered:
Koenstell
changed the title
ElasticSearch ItemNormalizer has incorrect method signature on normalize
ElasticSearch ItemNormalizer has incorrect return type on normalize
Jul 24, 2024
API Platform version(s) affected: 3.3.11
Description
When using API Platform combined with Elasticsearch, it will prioritize the
ItemNormalizer
to allow documents from Elastic to be normalized as well. However, the method signature of this class does not comply with its parents, which means that if somewhere else you use a normalizer through theNormalizerInterface
DI, you could end up with this error:How to reproduce
private readonly NormalizerInterface $normalizer
$this->normalizer->normalize($entity, null, ['groups' => ['example']]);
Possible Solution
Change the method signature of the ElasticSearch ItemNormalizer. Located at
ApiPlatform\Elasticsearch\Serializer\ItemNormalizer
.Like so:
BEFORE
AFTER:
The text was updated successfully, but these errors were encountered: