FOSRestBundle
FOSRestBundle copied to clipboard
Request Body Converter with Param Converter
I would expect to have the following feature:
/**
* @View()
* @ParamConverter(null, converter="fos_rest.request_body", options={"object_to_populate" = "post"})
*/
public function putAction(Post post) {
return $post;
}
When doing an HTTP PUT to /posts/{id} where {id} is a valid ID of a post, the body converter would automatically use the object_to_populate
option of the Serializer component to update the post
parameter in place, after retrieving the post
from the ParamConverter.
I did not get the time to look into how difficult this would be to implement but any suggestions would be welcome.
having the same nightmare since days as well
any solution for this ?
I came around the problem by creating my own decorator converter for RequestBodyParamConverter
. This converter looks for an already converted attribute (e.g. the doctrine object you want to patch), sets the object_to_populate
option in RequestBodyParamConverter
's deserializationContext
before letting RequestBodyParamConverter
do the work.
I can provide a pull request to integrate it into FOSRestBundle if desired.