Fix the JMSModelDescriber

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

View File

@ -98,14 +98,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

@ -298,6 +298,9 @@ class JMSFunctionalTest extends WebTestCase
'email' => [
'type' => 'string',
],
'virtualprop' => [
'type' => 'string',
],
],
'schema' => 'VirtualProperty',
], json_decode($this->getModel('VirtualProperty')->toJson(), true));