nelmio / NelmioApiDocBundle

Generates documentation for your REST API from annotations
MIT License
2.23k stars 836 forks source link

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

Open lukepass opened 4 years ago

lukepass commented 4 years ago

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!

NicolasGuilloux commented 4 years ago

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

goetas commented 4 years ago

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

lukepass commented 4 years ago

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

image

Thanks!

goetas commented 4 years ago

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

lukepass commented 4 years ago

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.

GuilhemN commented 4 years ago

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 :)