Closed garak closed 2 years ago
Are https://github.com/FriendsOfSymfony/FOSRestBundle/blob/3.x/View/View.php#L34
View takes as second parameter the status code, isn't that what you need?
That parameter is overridden by the handler
When it's Symfony Form
instance this bundle follows this config to return the status code:
fos_rest:
view:
failed_validation: 422
In other cases, the status code you've passed to the View
instance will be taken into account.
However, I think the one passed to the View
instance should have priority over the default config:
https://github.com/FriendsOfSymfony/FOSRestBundle/blob/b888195589d245002880d07073ef23ab60e3795d/View/ViewHandler.php#L217-L224
@garak does this answer your question?
@garak does this answer your question?
it does, but the option is not documented. You know the old saying: "if it isn't documented, it doesn't exist"
You know the old saying: "if it isn't documented, it doesn't exist"
feel free to create a pull request with the docs, it is very welcomed
for now i'm closing this ticket
The current code is passed to
ViewHandler::create()
with a default value of 400 (took fromResponse::HTTP_BAD_REQUEST
). I guess this was decided after the discussion in #19Could we reconsider that decision, taking into account that Symfony opted for 422 (
Response::HTTP_UNPROCESSABLE_ENTITY
) a few times ago? Or, as a possible alternative, could we make this code configurable by the user?