Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[Serializer] Add support for discriminator map in property normalizer#60511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:6.4
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Fixessymfony#60214Currently it's not possible to serialize an object using the PropertyNormalizer when aDiscriminatorMap attribute is used.It produces the following error:> Symfony\Component\Serializer\Exception\NotNormalizableValueException: Type property "type" not found> for the abstract object "Symfony\Component\Serializer\Tests\Fixtures\DummyMessageInterface".The ObjectNormalizer overrides the `getAllowedAttributes` from AbstractNormalizer and adds support fordiscriminators. But the PropertyNormalizer does not do this. Therefore it doesn't work.For now, we copy the logic from ObjectNormalizer to PropertyNormalizer and the problem goes away.
This comment was marked as resolved.
This comment was marked as resolved.
@derrabus You're probably very busy, but I'm really curious to hear your feedback on this 😊 |
@mtarld@nicolas-grekas Friendly ping to pick your brain on this topic, since you worked on the discriminator mapping in#52681. I'm curious to hear if my approach makes sense, or that I should investigate time in finding an alternative solution. Any advice is much appreciated, thanks 😊 |
Currently it's not possible to serialize an object using the PropertyNormalizer when a DiscriminatorMap attribute is used.
It produces the following error:
The ObjectNormalizer overrides the
getAllowedAttributes
from AbstractNormalizer and adds support for discriminators. But the PropertyNormalizer does not do this. Therefore it doesn't work.For now, we copy the logic from ObjectNormalizer to PropertyNormalizer and the problem goes away.