Skip to content

#[SerializedName] ignored for methods #7572

@huelsmc

Description

@huelsmc

API Platform version(s) affected: 4.2.6

Description
We used to use #[SerializedName] attribute to tell GraphQL API how to name properties.

We have cases like this:

    #[SerializedName(serializedName: 'currentListPrice')]
    public function getCurrentListPriceObject(): ?Price
    {
        // ....
        return null;
    }

However ApiPlatform doesn't recognize these anymore as expected.

With 4.1.7 + Symfony 7.2 this used to work.

Today we updated to 4.6.2 (ApiPlaform) and Symfony 7.4.0

I tried to identify the change that actually caused that but wasn't able to 100%.
Also I tested default serializer where this attribute is respected and properly rerwritten to currentListPriceObject as expected.

According to your docs I'd have expected that this should still work:
https://api-platform.com/docs/core/serialization/#name-conversion-for-symfony

We did not define anything else for serialization and as mentioned using the normal SerializerInterface works fine.

How to reproduce
See above use any method and try to override serialized name via #[SerializedName] attribute

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions