-
-
Notifications
You must be signed in to change notification settings - Fork 960
Description
API Platform version(s) affected: 4.2.17 or 4.2.18
Related to the fixes (cc @soyuka)
#7779
#7787
With something like
#[ApiResource]
class Locale { private string $id; }
class MyInput { private Locale $locale }
When calling the endpoint with the data ['locale' => 'en'] it's expected to not denormalize the Locale since it's not an IRI.
But I wrote my custom LocaleDenormalizer which basically does $this->entityManager->getRepository(Locale::class)->find($data); and it worked find before the upgrade.
Looking at how it worked,
- The serializer used the ItemNormalizer
- The class is changed, and now it used the ObjectNormalizer from Symfony (cf analyze from Input DTOs are not being passed through the name converter #7705 (comment)) for $locale field.
Now, it use the ItemNormalizer and keep using it for the locale field. But then since this field is a string, it tries to resolve the IRI without calling the denormalizer on it. And I get a Invalid IRI error.
I think rather than always using the iriConverter, the ItemNormalizer should call serializer::normalize on the string value:
- If a denormalizer has a higher priority it will be used
- If not, it will fallback on the ItemNormalizer again which already handle string value with the IriConverter the right way.
A fix like #7830