Skip to content

Since Symfony 7.3, arrays of IRIs in inputs are not converted to their respective objects when defined in a promoted constructor #7197

Closed
@simondaigre

Description

@simondaigre

API Platform version(s) affected: 4.1.15

Description
In my project, I only use DTOs. Before Symfony 7.3, with the following example, I retrieved the object with the property $users filled with UserDTOs in my processor. Since Symfony 7.3, and without any other changes on my part, I only retrieve an array of IRIs.

phpdocumentor/reflection-docblock is still installed.

Let me know if you want a reproducer.

How to reproduce

DTO :

#[ApiResource(
    shortName: 'Location',
    operations: [
        new Post(
            uriTemplate: '/locations',
        ),
    ],
    openapi: new Operation(
        tags: ['Location']
    ),
    processor: LocationProcessor::class,
    stateOptions: new Options(entityClass: Location::class),
)]
readonly class LocationInputDto
{
    public function __construct(
        #[Assert\NotBlank]
        public ?string $name = null,
        /** @var UserDto[] */
        public ?array $users = [],
    ) {
    }
}

Example request payload :

{
    "name": "Tour Eiffel",
    "users": [
        "/api/users/1",
        "/api/users/2"
    ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions