diff --git a/CHANGELOG.md b/CHANGELOG.md index bf64357..52e1278 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ CHANGELOG 3.7.0 ----- +* remove pattern added from the Expression Violation message. * Added `@SerializedName` annotation support and name converters when using Symfony >= 4.2. 3.3.0 diff --git a/Describer/OpenApiPhpDescriber.php b/Describer/OpenApiPhpDescriber.php index 128a529..938e471 100644 --- a/Describer/OpenApiPhpDescriber.php +++ b/Describer/OpenApiPhpDescriber.php @@ -69,7 +69,7 @@ final class OpenApiPhpDescriber return $v instanceof OA\AbstractAnnotation; }); - if (0 === count($annotations)) { + if (0 === count($annotations) && 0 === count($classAnnotations[$declaringClass->getName()])) { continue; } diff --git a/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php b/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php index e8eb58d..3580f48 100644 --- a/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php +++ b/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php @@ -69,8 +69,6 @@ class SymfonyConstraintAnnotationReader } elseif ($annotation instanceof Assert\Choice) { $values = $annotation->callback ? call_user_func(is_array($annotation->callback) ? $annotation->callback : [$reflectionProperty->class, $annotation->callback]) : $annotation->choices; $property->enum = array_values($values); - } elseif ($annotation instanceof Assert\Expression) { - $this->appendPattern($property, $annotation->message); } elseif ($annotation instanceof Assert\Range) { $property->minimum = (int) $annotation->min; $property->maximum = (int) $annotation->max; diff --git a/ModelDescriber/ObjectModelDescriber.php b/ModelDescriber/ObjectModelDescriber.php index 94a37f6..8036bb8 100644 --- a/ModelDescriber/ObjectModelDescriber.php +++ b/ModelDescriber/ObjectModelDescriber.php @@ -61,9 +61,9 @@ class ObjectModelDescriber implements ModelDescriberInterface, ModelRegistryAwar $class = $model->getType()->getClassName(); $schema->_context->class = $class; - $context = []; + $context = ['serializer_groups' => null]; 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); diff --git a/Tests/Functional/Controller/InvokableController.php b/Tests/Functional/Controller/InvokableController.php new file mode 100644 index 0000000..b640b70 --- /dev/null +++ b/Tests/Functional/Controller/InvokableController.php @@ -0,0 +1,31 @@ + [ 'type' => 'integer', - 'pattern' => 'If this is a tech post, the category should be either php or symfony!', ], 'propertyRange' => [ 'type' => 'integer', @@ -449,4 +448,10 @@ class FunctionalTest extends WebTestCase $this->assertSame('array', $property->oneOf[1]->type); $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); + } } diff --git a/Tests/Functional/TestKernel.php b/Tests/Functional/TestKernel.php index 6b9dbf6..57b5674 100644 --- a/Tests/Functional/TestKernel.php +++ b/Tests/Functional/TestKernel.php @@ -81,6 +81,7 @@ class TestKernel extends Kernel $routes->import(__DIR__.'/Controller/ApiController.php', '/', 'annotation'); $routes->import(__DIR__.'/Controller/ClassApiController.php', '/', 'annotation'); $routes->import(__DIR__.'/Controller/UndocumentedController.php', '/', 'annotation'); + $routes->import(__DIR__.'/Controller/InvokableController.php', '/', 'annotation'); $routes->import('', '/api', 'api_platform'); $routes->add('/docs/{area}', 'nelmio_api_doc.controller.swagger_ui')->setDefault('area', 'default'); $routes->add('/docs.json', 'nelmio_api_doc.controller.swagger');