I have two entities (take note of serialization groups on the child relation's id):
class Entity1
{
/**
* @var int
* @SWG\Property(type="integer", description="The ID of this entity", example=1)
* @Groups({"entity1_read"})
*/
private $id;
/**
* @var ArrayCollection
* @ORM\OneToOne(targetEntity="App\Entity\Entity2", mappedBy="entity2")
* @SWG\Property(type="object",
* ref=@Model(type=Entity2::class),
* description="Some thing",
* )
* @Groups({"entity1_read", "entity1_write"})
*/
private $entity2;
}
class Entity2
{
/**
* @var int
* @SWG\Property(type="integer", description="The ID of this entity", example=1)
* @Groups({"entity1_read", "entity2_read"}) <-- READ GROUP
*/
private $id;
/**
* @var string
* @SWG\Property(type="string", description="The name of this entity", example="fred")
* @Groups({"entity2_read", "entity2_write", "entity1_read", "entity1_write"})
*/
private $name;
}
And my controller annotations:
class myController extends Controller {
/**
* @SWG\Parameter(
* name="body",
* type="body",
* in="body",
* description="Some data",
* required=true,
* @Model(type=Entity1::class, groups={"entity1_write"}) <-- WRITE GROUP
* )
* @SWG\Response(
* response=201,
* description="Creates an entity1 with entity2",
* @Model(type=Entity1::class, groups={"entity1_read"}) <-- READ GROUP
* )
* @SWG\Response(
* response=400,
* description="validation error",
* )
/*
public function createEntity1()
{}
}
The EXAMPLE body for POST in /api/doc for entity1 shows all properties of relation (notice parent id has been omitted):
application/json
{
"entity2": [
{
"id":1, <-- Should be omitted as i specified "entity1_write" serialization group
"name":"fred"
}
]
}
I hope this makes sense
They are, are you using version 3.2?
According to my composer lock file I'm using 3.2.1. I will reproduce and post it here
Hello,
Same issue there. I can post a sample but it is exactly the same case and issue. I'm using 3.2.1.
I will try to investigate but I'm short in time. If possible, a PR with a failing test case would be greatly helpful.
I might be able to do that if I get a min.
Cheers for investigating
On Fri, 20 Jul 2018, 20:19 Guilhem N, notifications@github.com wrote:
I will try to investigate but I'm short in time. If possible, a PR with a
failing test case would be greatly helpful.—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/nelmio/NelmioApiDocBundle/issues/1337#issuecomment-406701992,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Af_3V9QpjZGvt_xPoJGETj8Uj6_xTBfEks5uIi0ngaJpZM4UZM4M
.
--
Consider the environment. Do you really need to print this email?
--
Catena Media is processing your personal data for example to
communicate with you and deliver our services. For further information
about our processing please see our privacy and cookie policy
https://www.catenamedia.com/privacy-and-cookie-policy/
https://www.catenamedia.com/privacy-and-cookie-policy/
the issue still exists for me (version 4.1.1)
but looks like fixed in current master branch.
Maybe it was related to the annotations cache then, we fixed an issue related to them.
I just released master, I hope it's all good now
Most helpful comment
I might be able to do that if I get a min.
Cheers for investigating
On Fri, 20 Jul 2018, 20:19 Guilhem N, notifications@github.com wrote:
--
Consider the environment. Do you really need to print this email?
--
Catena Media is processing your personal data for example to
communicate with you and deliver our services. For further information
about our processing please see our privacy and cookie policy
https://www.catenamedia.com/privacy-and-cookie-policy/
https://www.catenamedia.com/privacy-and-cookie-policy/