Skip to content

Nested DTO not deserialized #3295

@MichaelKubovic

Description

@MichaelKubovic

API Platform version(s) affected: 2.5.3

Description

Having a resource that uses DTO for input and that class contains property that contains array of DTOs of other class.

Generated documentation says that the property has type of array of strings.

Sending a request actually makes the data of the nested dto available as an associative array, although I'd expect it to be deserialized into an object.

How to reproduce

/**
 * @ApiResource(
 *     collectionOperations={
 *          "post"={
 *              "status"=202,
 *              "input"=App\Command\CreateFoo::class,
 *              "output"=false
 *          },
 *     },
 *     itemOperations={},
 *     messenger="input",
 *     output=false,
 * )
 */
class TestResource
{
    // not important
    public $foo;
}
final class CreateFoo
{
   // not important
    public $name;

    /** @var CreateBar[] */
    public $bars = [];
}
final class CreateBar
{
    public $baz;
}

Possible Solution

Additional Context

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions