Merge pull request #2045 from manowark/fix-error-in-symfony-constraint-annotation-reader

Fix type error in SymfonyConstraintAnnotationReader
This commit is contained in:
Guilhem Niot 2022-10-23 21:05:25 +02:00 committed by GitHub
commit f331441521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 1 deletions

View File

@ -225,7 +225,7 @@ class SymfonyConstraintAnnotationReader
{ {
return count(array_intersect( return count(array_intersect(
$validationGroups ?: [Constraint::DEFAULT_GROUP], $validationGroups ?: [Constraint::DEFAULT_GROUP],
$annotation->groups (array) $annotation->groups
)) > 0; )) > 0;
} }
} }

View File

@ -11,6 +11,7 @@
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity; namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
use OpenApi\Annotations as OA;
use Symfony\Component\Serializer\Annotation\Groups; use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert; use Symfony\Component\Validator\Constraints as Assert;
@ -31,4 +32,12 @@ class SymfonyConstraintsWithValidationGroups
* @Assert\Range(min=1, max=100) * @Assert\Range(min=1, max=100)
*/ */
public $propertyInDefaultGroup; public $propertyInDefaultGroup;
/**
* @var array
*
* @OA\Property(type="array", @OA\Items(type="string"))
* @Assert\Valid
*/
public $propertyArray;
} }

View File

@ -66,6 +66,12 @@ class ValidationGroupsFunctionalTest extends WebTestCase
'maximum' => 100, 'maximum' => 100,
'minimum' => 1, 'minimum' => 1,
], ],
'propertyArray' => [
'type' => 'array',
'items' => [
'type' => 'string',
],
],
], ],
'type' => 'object', 'type' => 'object',
'schema' => 'SymfonyConstraintsDefaultGroup', 'schema' => 'SymfonyConstraintsDefaultGroup',