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 2aedc6a + d9aae0b commit 48c9e5cCopy full SHA for 48c9e5c
controller.rst
@@ -505,9 +505,16 @@ the validation fails as well as supported payload formats::
505
// ...
506
}
507
508
-
509
The default status code returned if the validation fails is 422.
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
518
Make sure to install `phpstan/phpdoc-parser`_ and `phpdocumentor/type-resolver`_
519
if you want to map a nested array of specific DTOs::
520
0 commit comments