We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 419f5d7 + f205e2c commit d9aae0bCopy full SHA for d9aae0b
controller.rst
@@ -523,9 +523,16 @@ the validation fails as well as supported payload formats::
523
// ...
524
}
525
526
-
527
The default status code returned if the validation fails is 422.
528
+.. tip::
529
+
530
+ If you build a JSON API, make sure to declare your route as using the JSON
531
+ :ref:`format <routing-format-parameter>`. This will make the error handling
532
+ output a JSON response in case of validation errors, rather than an HTML page::
533
534
+ #[Route('/dashboard', name: 'dashboard', format: 'json')]
535
536
Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_
537
if you want to map a nested array of specific DTOs::
538
0 commit comments