Fix the JMSModelDescriber

This commit is contained in:
Guilhem Niot 2020-09-09 08:35:01 +02:00
parent 429d809f41
commit c1903db109
3 changed files with 11 additions and 4 deletions

View File

@ -93,14 +93,17 @@ class JMSModelDescriber implements ModelDescriberInterface, ModelRegistryAwareIn
$reflections[] = new \ReflectionProperty($item->class, $item->name);
}
try {
if (null !== $item->getter) {
try {
$reflections[] = new \ReflectionMethod($item->class, $item->getter);
} catch (\ReflectionException $ignored) {
}
}
if (null !== $item->setter) {
try {
$reflections[] = new \ReflectionMethod($item->class, $item->setter);
} catch (\ReflectionException $ignored) {
}
} catch (\ReflectionExceptions $ignored) {
}
$groups = $this->computeGroups($context, $item->type);

View File

@ -40,6 +40,7 @@ class VirtualProperty
/**
* @Serializer\Accessor(getter="getFoo", setter="setFoo")
* @Serializer\Type("string")
* @Serializer\Expose
*
* Ensures https://github.com/nelmio/NelmioApiDocBundle/issues/1708 is fixed.
*/

View File

@ -280,6 +280,9 @@ class JMSFunctionalTest extends WebTestCase
'email' => [
'type' => 'string',
],
'virtualprop' => [
'type' => 'string',
],
],
], $this->getModel('VirtualProperty')->toArray());
}