mirror of
https://github.com/retailcrm/NelmioApiDocBundle.git
synced 2025-02-10 11:39:25 +03:00
Fix CS
This commit is contained in:
parent
76949ca537
commit
477442588a
@ -176,7 +176,7 @@ final class NelmioApiDocExtension extends Extension implements PrependExtensionI
|
|||||||
new Reference('annotations.reader'),
|
new Reference('annotations.reader'),
|
||||||
$config['media_types'],
|
$config['media_types'],
|
||||||
$jmsNamingStrategy,
|
$jmsNamingStrategy,
|
||||||
$container->getParameter('nelmio_api_doc.use_validation_groups')
|
$container->getParameter('nelmio_api_doc.use_validation_groups'),
|
||||||
])
|
])
|
||||||
->addTag('nelmio_api_doc.model_describer', ['priority' => 50]);
|
->addTag('nelmio_api_doc.model_describer', ['priority' => 50]);
|
||||||
|
|
||||||
|
@ -184,11 +184,11 @@ class SymfonyConstraintAnnotationReader
|
|||||||
private function getAnnotations($reflection, ?array $validationGroups): iterable
|
private function getAnnotations($reflection, ?array $validationGroups): iterable
|
||||||
{
|
{
|
||||||
foreach ($this->locateAnnotations($reflection) as $annotation) {
|
foreach ($this->locateAnnotations($reflection) as $annotation) {
|
||||||
if (! $annotation instanceof Constraint) {
|
if (!$annotation instanceof Constraint) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $this->useValidationGroups || $this->isConstraintInGroup($annotation, $validationGroups)) {
|
if (!$this->useValidationGroups || $this->isConstraintInGroup($annotation, $validationGroups)) {
|
||||||
yield $annotation;
|
yield $annotation;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ class SymfonyConstraintAnnotationReader
|
|||||||
* default group. So even with a null $validationGroups passed here there still
|
* default group. So even with a null $validationGroups passed here there still
|
||||||
* has to be a check on the default group.
|
* has to be a check on the default group.
|
||||||
*/
|
*/
|
||||||
private function isConstraintInGroup(Constraint $annotation, ?array $validationGroups) : bool
|
private function isConstraintInGroup(Constraint $annotation, ?array $validationGroups): bool
|
||||||
{
|
{
|
||||||
return count(array_intersect(
|
return count(array_intersect(
|
||||||
$validationGroups ?: [Constraint::DEFAULT_GROUP],
|
$validationGroups ?: [Constraint::DEFAULT_GROUP],
|
||||||
|
@ -11,10 +11,8 @@
|
|||||||
|
|
||||||
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
namespace Nelmio\ApiDocBundle\Tests\Functional\Entity;
|
||||||
|
|
||||||
use Nelmio\ApiDocBundle\Tests\ModelDescriber\Annotations\Fixture as CustomAssert;
|
|
||||||
use Symfony\Component\Validator\Constraint;
|
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
|
||||||
use Symfony\Component\Serializer\Annotation\Groups;
|
use Symfony\Component\Serializer\Annotation\Groups;
|
||||||
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
class SymfonyConstraintsWithValidationGroups
|
class SymfonyConstraintsWithValidationGroups
|
||||||
{
|
{
|
||||||
|
@ -19,9 +19,9 @@ use JMS\SerializerBundle\JMSSerializerBundle;
|
|||||||
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
|
use Nelmio\ApiDocBundle\NelmioApiDocBundle;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\BazingaUser;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\BazingaUser;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\JMSComplex;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyConstraintsWithValidationGroups;
|
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSPicture;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\NestedGroup\JMSPicture;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\Entity\PrivateProtectedExposure;
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\PrivateProtectedExposure;
|
||||||
|
use Nelmio\ApiDocBundle\Tests\Functional\Entity\SymfonyConstraintsWithValidationGroups;
|
||||||
use Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\VirtualTypeClassDoesNotExistsHandlerDefinedDescriber;
|
use Nelmio\ApiDocBundle\Tests\Functional\ModelDescriber\VirtualTypeClassDoesNotExistsHandlerDefinedDescriber;
|
||||||
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
|
use Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle;
|
||||||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
|
||||||
@ -33,7 +33,6 @@ use Symfony\Component\DependencyInjection\Definition;
|
|||||||
use Symfony\Component\HttpKernel\Kernel;
|
use Symfony\Component\HttpKernel\Kernel;
|
||||||
use Symfony\Component\Routing\RouteCollectionBuilder;
|
use Symfony\Component\Routing\RouteCollectionBuilder;
|
||||||
use Symfony\Component\Serializer\Annotation\SerializedName;
|
use Symfony\Component\Serializer\Annotation\SerializedName;
|
||||||
use Symfony\Component\Validator\Constraint;
|
|
||||||
|
|
||||||
class TestKernel extends Kernel
|
class TestKernel extends Kernel
|
||||||
{
|
{
|
||||||
|
@ -12,12 +12,12 @@
|
|||||||
namespace Nelmio\ApiDocBundle\Tests\ModelDescriber\Annotations;
|
namespace Nelmio\ApiDocBundle\Tests\ModelDescriber\Annotations;
|
||||||
|
|
||||||
use Doctrine\Common\Annotations\AnnotationReader;
|
use Doctrine\Common\Annotations\AnnotationReader;
|
||||||
use Symfony\Component\Validator\Constraint;
|
|
||||||
use Nelmio\ApiDocBundle\ModelDescriber\Annotations\SymfonyConstraintAnnotationReader;
|
use Nelmio\ApiDocBundle\ModelDescriber\Annotations\SymfonyConstraintAnnotationReader;
|
||||||
use Nelmio\ApiDocBundle\Tests\Helper;
|
use Nelmio\ApiDocBundle\Tests\Helper;
|
||||||
use Nelmio\ApiDocBundle\Tests\ModelDescriber\Annotations\Fixture as CustomAssert;
|
use Nelmio\ApiDocBundle\Tests\ModelDescriber\Annotations\Fixture as CustomAssert;
|
||||||
use OpenApi\Annotations as OA;
|
use OpenApi\Annotations as OA;
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Validator\Constraint;
|
||||||
use Symfony\Component\Validator\Constraints as Assert;
|
use Symfony\Component\Validator\Constraints as Assert;
|
||||||
|
|
||||||
class SymfonyConstraintAnnotationReaderTest extends TestCase
|
class SymfonyConstraintAnnotationReaderTest extends TestCase
|
||||||
@ -488,7 +488,7 @@ class SymfonyConstraintAnnotationReaderTest extends TestCase
|
|||||||
$reader->updateProperty(
|
$reader->updateProperty(
|
||||||
new \ReflectionProperty($entity, 'property1'),
|
new \ReflectionProperty($entity, 'property1'),
|
||||||
$schema->properties[0],
|
$schema->properties[0],
|
||||||
["other"],
|
['other'],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame(OA\UNDEFINED, $schema->required, 'should not have read constraint in default group');
|
$this->assertSame(OA\UNDEFINED, $schema->required, 'should not have read constraint in default group');
|
||||||
@ -512,7 +512,7 @@ class SymfonyConstraintAnnotationReaderTest extends TestCase
|
|||||||
$reader->updateProperty(
|
$reader->updateProperty(
|
||||||
new \ReflectionProperty($entity, 'property1'),
|
new \ReflectionProperty($entity, 'property1'),
|
||||||
$schema->properties[0],
|
$schema->properties[0],
|
||||||
["other", Constraint::DEFAULT_GROUP],
|
['other', Constraint::DEFAULT_GROUP],
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->assertSame(['property1'], $schema->required, 'should have read constraint in default group');
|
$this->assertSame(['property1'], $schema->required, 'should have read constraint in default group');
|
||||||
@ -532,13 +532,13 @@ class SymfonyConstraintAnnotationReaderTest extends TestCase
|
|||||||
if (\PHP_VERSION_ID >= 80000) {
|
if (\PHP_VERSION_ID >= 80000) {
|
||||||
yield 'Attributes' => [new class() {
|
yield 'Attributes' => [new class() {
|
||||||
#[Assert\NotBlank()]
|
#[Assert\NotBlank()]
|
||||||
#[Assert\Range(min: 1, group: ["other"])]
|
#[Assert\Range(min: 1, group: ['other'])]
|
||||||
private $property1;
|
private $property1;
|
||||||
}];
|
}];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function createConstraintReaderWithValidationGroupsEnabled() : SymfonyConstraintAnnotationReader
|
private function createConstraintReaderWithValidationGroupsEnabled(): SymfonyConstraintAnnotationReader
|
||||||
{
|
{
|
||||||
return new SymfonyConstraintAnnotationReader(
|
return new SymfonyConstraintAnnotationReader(
|
||||||
new AnnotationReader(),
|
new AnnotationReader(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user