From fa1934c08d505df970dafd840cb7604c9f4b9e46 Mon Sep 17 00:00:00 2001 From: Yonel Ceruto Date: Sun, 7 Apr 2024 12:02:21 -0400 Subject: [PATCH] Documenting items type in the MapRequestPayload attribute --- controller.rst | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/controller.rst b/controller.rst index c44f0dafdac..2edf6affb2f 100644 --- a/controller.rst +++ b/controller.rst @@ -555,6 +555,32 @@ if you want to map a nested array of specific DTOs:: ) {} } +Nevertheless, if you want to send the array of payloads directly like this: + +.. code-block:: json + + [ + { + "firstName": "John", + "lastName": "Smith", + "age": 28 + }, + { + "firstName": "Jane", + "lastName": "Doe", + "age": 30 + } + ] + +Map the parameter as an array and configure the type of each element in the attribute:: + + public function dashboard( + #[MapRequestPayload(type: UserDTO::class)] array $users + ): Response + { + // ... + } + Managing the Session --------------------