I'm looking for approach to find out retrieve an resource not depending on it's id but something like username, GET /api/user/{username}.
So I did something like this:
/**
* @ApiRessource({
*     itemOperations={
*         "get"={
*             "normalization_context"={"groups"={"user:read"}},
*             "path"="/user/{username}", "read"=false,
*             "controller"=ApiUser::class,
*             "openapi_context"={
*                  "summary" = "Récupérer un freehelper en particulier par son nom"
*              },
*          },
})
*/
class User{
{
    /**
     * @Groups({"user:read"})
     * @ORM\Id()
     * @ORM\GeneratedValue()
     * @ORM\Column(type="integer")
     * @ApiProperty(identifier=false)
     */
    private $id;
    /**
     * @Groups({"user:read"})
     * @ORM\Column(type="string", length=56, unique=true)
     * @ApiProperty(identifier=true)
     */
    private $username;
....
}
and then I write and dataproider as described here, so I got this error
"detail": "Unable to generate an IRI for \"App\\Entity\\User\".",
Can you help me understanding how to do that?
 
                        
You can create a function in ApiUser controller like that: