mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-02 23:59:26 +03:00
Fix choice annotation with callback method name without class
This commit is contained in:
parent
c805beb3f5
commit
a9d6b3fd46
@ -69,7 +69,7 @@ class SymfonyConstraintAnnotationReader
|
||||
$property->setMinItems($annotation->min);
|
||||
$property->setMaxItems($annotation->max);
|
||||
} elseif ($annotation instanceof Assert\Choice) {
|
||||
$property->setEnum($annotation->callback ? call_user_func($annotation->callback) : $annotation->choices);
|
||||
$property->setEnum($annotation->callback ? call_user_func(is_array($annotation->callback) ? $annotation->callback : [$reflectionProperty->class, $annotation->callback]) : $annotation->choices);
|
||||
} elseif ($annotation instanceof Assert\Expression) {
|
||||
$this->appendPattern($property, $annotation->message);
|
||||
}
|
||||
|
@ -64,6 +64,13 @@ class SymfonyConstraints
|
||||
*/
|
||||
private $propertyChoiceWithCallback;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
* @Assert\Choice(callback="fetchAllowedChoices")
|
||||
*/
|
||||
private $propertyChoiceWithCallbackWithoutClass;
|
||||
|
||||
/**
|
||||
* @var int
|
||||
*
|
||||
@ -130,6 +137,14 @@ class SymfonyConstraints
|
||||
$this->propertyChoiceWithCallback = $propertyChoiceWithCallback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $propertyChoiceWithCallbackWithoutClass
|
||||
*/
|
||||
public function setPropertyChoiceWithCallbackWithoutClass(int $propertyChoiceWithCallbackWithoutClass): void
|
||||
{
|
||||
$this->propertyChoiceWithCallbackWithoutClass = $propertyChoiceWithCallbackWithoutClass;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $propertyExpression
|
||||
*/
|
||||
|
@ -374,6 +374,10 @@ class FunctionalTest extends WebTestCase
|
||||
'type' => 'integer',
|
||||
'enum' => ['choice1', 'choice2'],
|
||||
],
|
||||
'propertyChoiceWithCallbackWithoutClass' => [
|
||||
'type' => 'integer',
|
||||
'enum' => ['choice1', 'choice2'],
|
||||
],
|
||||
'propertyExpression' => [
|
||||
'type' => 'integer',
|
||||
'pattern' => 'If this is a tech post, the category should be either php or symfony!',
|
||||
|
Loading…
x
Reference in New Issue
Block a user