Merge remote-tracking branch 'origin/3.x' into HEAD

This commit is contained in:
Guilhem Niot 2020-07-11 18:06:00 +02:00
commit d167685f42
7 changed files with 42 additions and 6 deletions

View File

@ -8,6 +8,7 @@ CHANGELOG
3.7.0 3.7.0
----- -----
* remove pattern added from the Expression Violation message.
* Added `@SerializedName` annotation support and name converters when using Symfony >= 4.2. * Added `@SerializedName` annotation support and name converters when using Symfony >= 4.2.
3.3.0 3.3.0

View File

@ -69,7 +69,7 @@ final class OpenApiPhpDescriber
return $v instanceof OA\AbstractAnnotation; return $v instanceof OA\AbstractAnnotation;
}); });
if (0 === count($annotations)) { if (0 === count($annotations) && 0 === count($classAnnotations[$declaringClass->getName()])) {
continue; continue;
} }

View File

@ -69,8 +69,6 @@ class SymfonyConstraintAnnotationReader
} elseif ($annotation instanceof Assert\Choice) { } elseif ($annotation instanceof Assert\Choice) {
$values = $annotation->callback ? call_user_func(is_array($annotation->callback) ? $annotation->callback : [$reflectionProperty->class, $annotation->callback]) : $annotation->choices; $values = $annotation->callback ? call_user_func(is_array($annotation->callback) ? $annotation->callback : [$reflectionProperty->class, $annotation->callback]) : $annotation->choices;
$property->enum = array_values($values); $property->enum = array_values($values);
} elseif ($annotation instanceof Assert\Expression) {
$this->appendPattern($property, $annotation->message);
} elseif ($annotation instanceof Assert\Range) { } elseif ($annotation instanceof Assert\Range) {
$property->minimum = (int) $annotation->min; $property->minimum = (int) $annotation->min;
$property->maximum = (int) $annotation->max; $property->maximum = (int) $annotation->max;

View File

@ -61,9 +61,9 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar
$class = $model->getType()->getClassName(); $class = $model->getType()->getClassName();
$schema->_context->class = $class; $schema->_context->class = $class;
$context = []; $context = ['serializer_groups' => null];
if (null !== $model->getGroups()) { if (null !== $model->getGroups()) {
$context = ['serializer_groups' => array_filter($model->getGroups(), 'is_string')]; $context['serializer_groups'] = array_filter($model->getGroups(), 'is_string');
} }
$annotationsReader = new AnnotationsReader($this->doctrineReader, $this->modelRegistry, $this->mediaTypes); $annotationsReader = new AnnotationsReader($this->doctrineReader, $this->modelRegistry, $this->mediaTypes);

View File

@ -0,0 +1,31 @@
<?php
/*
* This file is part of the NelmioApiDocBundle package.
*
* (c) Nelmio
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Nelmio\ApiDocBundle\Tests\Functional\Controller;
use OpenApi\Annotations as OA;
use Symfony\Component\Routing\Annotation\Route;
/**
* Prevents a regression (see https://github.com/nelmio/NelmioApiDocBundle/issues/1559).
*
* @Route("/api/invoke", host="api.example.com", name="invokable", methods={"GET"})
* @OA\Response(
* response=200,
* description="Invokable!"
* )
*/
class InvokableController
{
public function __invoke()
{
}
}

View File

@ -374,7 +374,6 @@ class FunctionalTest extends WebTestCase
], ],
'propertyExpression' => [ 'propertyExpression' => [
'type' => 'integer', 'type' => 'integer',
'pattern' => 'If this is a tech post, the category should be either php or symfony!',
], ],
'propertyRange' => [ 'propertyRange' => [
'type' => 'integer', 'type' => 'integer',
@ -449,4 +448,10 @@ class FunctionalTest extends WebTestCase
$this->assertSame('array', $property->oneOf[1]->type); $this->assertSame('array', $property->oneOf[1]->type);
$this->assertSame('#/components/schemas/CompoundEntity', $property->oneOf[1]->items->ref); $this->assertSame('#/components/schemas/CompoundEntity', $property->oneOf[1]->items->ref);
} }
public function testInvokableController()
{
$operation = $this->getOperation('/api/invoke', 'get');
$this->assertSame('Invokable!', $this->getOperationResponse($operation, 200)->description);
}
} }

View File

@ -81,6 +81,7 @@ class TestKernel extends Kernel
$routes->import(__DIR__.'/Controller/ApiController.php', '/', 'annotation'); $routes->import(__DIR__.'/Controller/ApiController.php', '/', 'annotation');
$routes->import(__DIR__.'/Controller/ClassApiController.php', '/', 'annotation'); $routes->import(__DIR__.'/Controller/ClassApiController.php', '/', 'annotation');
$routes->import(__DIR__.'/Controller/UndocumentedController.php', '/', 'annotation'); $routes->import(__DIR__.'/Controller/UndocumentedController.php', '/', 'annotation');
$routes->import(__DIR__.'/Controller/InvokableController.php', '/', 'annotation');
$routes->import('', '/api', 'api_platform'); $routes->import('', '/api', 'api_platform');
$routes->add('/docs/{area}', 'nelmio_api_doc.controller.swagger_ui')->setDefault('area', 'default'); $routes->add('/docs/{area}', 'nelmio_api_doc.controller.swagger_ui')->setDefault('area', 'default');
$routes->add('/docs.json', 'nelmio_api_doc.controller.swagger'); $routes->add('/docs.json', 'nelmio_api_doc.controller.swagger');