-
-
Notifications
You must be signed in to change notification settings - Fork 976
Description
I have a Product entity having a OneToMany relation with a ProductTranslation entity without the "@ApiResource" annotation. I set up the relevant serialization groups for both the normalization_context and the denormalization_context so a GET to /products/ returns as expected:
{
"id": 2,
"code": "sku123",
"translations": [{
"id": 12,
"name": "Pen",
"description": "it is a pen",
"locale": "en"
}, {
"id": 14,
"name": "Stylo",
"description": "il est un stylo",
"locale": "fr"
}]
}
It is working as expected when creating a new object via POST too. My problem is when I try to update a translation via PUT to /products/2:
{
"code": "sku123",
"translations": [{
"id": 12,
"name": "Biro",
"description": "it is still a pen",
"locale": "en"
}]
}
this would not update the existing relation but just add a new one (another ProductTranslation with another ID).
It works as expected if I add the "@ApiResource" annotation to the ProductTranslation entity (and change the translation id to something like "/product_translations/12") but that would also create an end point for this entity and that is wrong because it is never required to be used directly.
So my question is: is there a way to make the PUT update work for an embedded relation which does not have its own routing / end point?