NelmioApiDocBundle icon indicating copy to clipboard operation
NelmioApiDocBundle copied to clipboard

@JMS\VirtualProperty not working when using @JMS\Groups

Open lukepass opened this issue 5 years ago • 7 comments

Hello, I noticed a bug today: when looking at the API documentation if I have a model with @JMS\VirtualProperty and @JMS\Groups the virtual property is not correctly displayed in the documentation.

The property is correctly serialized when calling the web service, the problem is just in the documentation:

/**
 * Returns the posting user.
 *
 * @JMS\VirtualProperty
 * @JMS\Type("AppBundle\Entity\User")
 * @JMS\Groups({"homepage"})
 * @JMS\Expose
 */
public function getUser()
{
    return $this->challengeEntry->getUser();
}

Thanks!

lukepass avatar Jul 02 '20 13:07 lukepass

You may look at this issue: https://github.com/nelmio/NelmioApiDocBundle/issues/1412

NicolasGuilloux avatar Jul 06 '20 14:07 NicolasGuilloux

@lukepass can you please explain in detail what it means "the virtual property is not correctly displayed in the documentation"?

goetas avatar Jul 13 '20 09:07 goetas

Hello @goetas! I mean that the property is not shown in the "preview" below the Description section for the responses. Here:

image

Thanks!

lukepass avatar Jul 14 '20 12:07 lukepass

Did you specify in the controller @Model(type=User::class, groups={"homepage"}) ?

goetas avatar Jul 14 '20 13:07 goetas

In my controller I am setting the view correctly but as I said the controller's output is correct, the property is serialized. It's just the documentation that isn't updated with the value.

lukepass avatar Jul 14 '20 13:07 lukepass

I am not able to reproduce this issue, could you give us some more details about your controller and your entity ? A small reproducer would also help if you have some time to create one :)

GuilhemN avatar Jul 18 '20 08:07 GuilhemN