Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MapRequestPayload and array type hint #60764

Open
@now-mar

Description

@now-mar

Description

I've noticed that MapRequestPayload cannot handle the array type hint.

Request payload:

[{"field": "value1"}, {"field": "value2"}]
public function someAction(
  #[MapRequestPayload]
  /** @param ItemDto[] $items */
  array $items
) {}

This is because the $type parameter passed to Serializer::denormalize() in RequestPayloadValueResolver is taken from ArgumentMetadata and the type there is taken from \ReflectionParameter so no DocBlocks are considered.

I was checking out if I can override the type with a serializer's context options (you can pass that to MapRequestPayload attribute) but it looks like it's not possible.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions