As proof this controller action will throw because Product isn't a service, and action can't be auto-wired, exactly what I want:
Cannot autowire argument $product of "App\Controller\ApiController::createProductAction()": it references class "App\Entity\Product" but no such service exists.
/**
* @Rest\Post("/products", name="_api_post_product")
* @Rest\View()
*/
public function createProductAction(Product $product, ConstraintViolationListInterface $validationErrors)
{
}
Now I want to use the param converter from FOSRestBundle so POST request body will be deserialized into a fresh new Product object and validated:
I'm spending the entire day on this.
I've configured SensioFrameworkExtraBundle to enable converters but disable auto convert feature:
As proof this controller action will throw because
Product
isn't a service, and action can't be auto-wired, exactly what I want:Now I want to use the param converter from FOSRestBundle so
POST
request body will be deserialized into a fresh newProduct
object and validated:The problem is that the converter is fetching a valid record from the database, when
POST
payload is a validid
like this:What's going on here? I don't want to update an existing object, i just want all the values to be deserialized into a new object to be persisted.