Skip to content

Commit 48c9e5c

Browse files
committed
Merge branch '6.4' into 7.0
* 6.4: hint for mapping request payload error messages
2 parents 2aedc6a + d9aae0b commit 48c9e5c

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

controller.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,16 @@ the validation fails as well as supported payload formats::
505505
// ...
506506
}
507507

508-
509508
The default status code returned if the validation fails is 422.
510509

510+
.. tip::
511+
512+
If you build a JSON API, make sure to declare your route as using the JSON
513+
:ref:`format <routing-format-parameter>`. This will make the error handling
514+
output a JSON response in case of validation errors, rather than an HTML page::
515+
516+
#[Route('/dashboard', name: 'dashboard', format: 'json')]
517+
511518
Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_
512519
if you want to map a nested array of specific DTOs::
513520

0 commit comments

Comments
 (0)