Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Open
ruudk wants to merge1 commit intosymfony:6.4
base:6.4
Choose a base branch
Loading
fromruudk:fix-60214

Conversation

ruudk
Copy link
Contributor

QA
Branch?6.4
Bug fix?yes
New feature?no
Deprecations?no
IssuesFix#60214
LicenseMIT

Currently it's not possible to serialize an object using the PropertyNormalizer when a DiscriminatorMap 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 thegetAllowedAttributes 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.

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.
@carsonbot

This comment was marked as resolved.

@ruudk
Copy link
ContributorAuthor

@derrabus You're probably very busy, but I'm really curious to hear your feedback on this 😊

@ruudk
Copy link
ContributorAuthor

@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 😊

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@dunglasdunglasAwaiting requested review from dunglasdunglas is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
6.4
Development

Successfully merging this pull request may close these issues.

[Serializer] Discriminator is removed when#[Ignore] attribute used on unrelated method
3 participants
@ruudk@carsonbot@alexandre-daubois

[8]ページ先頭

©2009-2025 Movatter.jp