Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf205e2c

Browse files
committed
minor#19121 hint for mapping request payload error messages (dbu)
This PR was merged into the 6.3 branch.Discussion----------hint for mapping request payload error messagesThe information is particularly important in the context of the `MapRequestPayload` but technically not related. It is about the behaviour of the symfony error handler. If there is more documentation about the error handler and output formats, i am happy to link to that if you point me to the right place.I think it is valuable to mention this here though, as it will happen when using the feature. I almost gave up and set up some custom exception listener or whatnot to output json. Stackoverflow is full of answers proposing those to output errors as JSON.Commits-------600b3b1 hint for mapping request payload error messages
2 parents1659563 +600b3b1 commitf205e2c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

‎controller.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,14 @@ payload formats::
502502
// ...
503503
}
504504

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp