Closed
Description
Symfony version(s) affected: 5.0.9, 5.1.0
Description
Entity User
class User implements UserInterface {
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer", options={"unsigned": true})
* @Groups("main")
*/
private int $id;
// ...
/**
* @ORM\ManyToMany(targetEntity=Department::class)
* @ORM\JoinColumn(onDelete="CASCADE")
* @Groups("main")
*/
private $departments;
My controller
public function getUser(User $id) {
return $this->json($user, 200, [], ['groups' => ['main']);
}
Expected:
{
"id": 2,
// ...
"departments": []
}
Actual result:
{
"id": 2,
// ...
"departments": {}
}
How to reproduce
Just upgraded symfony/serializer to 5.0.9