From fe39acd6a808fffd3e8ac249afd9837e9b2a00ca Mon Sep 17 00:00:00 2001 From: pratyam <48760495+pratyam@users.noreply.github.com> Date: Sat, 4 Jul 2020 16:27:40 +0200 Subject: [PATCH] Bugfix/remove pattern from property expression message error (#1670) * remove pattern added from the Expression Violation message. This string confuses the API client showing a violation message instead of having a Regex. Any informatory message for the client should be placed in "description" * fix tests * fix typo --- CHANGELOG.md | 5 +++++ .../Annotations/SymfonyConstraintAnnotationReader.php | 2 -- Tests/Describer/ApiPlatformDescriberTest.php | 2 +- Tests/Functional/FunctionalTest.php | 1 - 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 08efefd..5c41e99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ CHANGELOG ========= +3.8.0 +------ + +* remove pattern added from the Expression Violation message. + 3.7.0 (unreleased) ------------------ diff --git a/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php b/ModelDescriber/Annotations/SymfonyConstraintAnnotationReader.php index 73f8449..f944ee0 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->setEnum(array_values($values)); - } elseif ($annotation instanceof Assert\Expression) { - $this->appendPattern($property, $annotation->message); } elseif ($annotation instanceof Assert\Range) { $property->setMinimum($annotation->min); $property->setMaximum($annotation->max); diff --git a/Tests/Describer/ApiPlatformDescriberTest.php b/Tests/Describer/ApiPlatformDescriberTest.php index 5e83a03..dacfb53 100644 --- a/Tests/Describer/ApiPlatformDescriberTest.php +++ b/Tests/Describer/ApiPlatformDescriberTest.php @@ -45,7 +45,7 @@ class ApiPlatformDescriberTest extends AbstractDescriberTest $this->assertEquals($expectedApi->toArray(), $this->getSwaggerDoc()->toArray()); } - protected function setUp() + protected function setUp(): void { $this->documentation = new Documentation(new ResourceNameCollection(['dummy' => 'dummy'])); diff --git a/Tests/Functional/FunctionalTest.php b/Tests/Functional/FunctionalTest.php index 0e18c3f..7d2db9a 100644 --- a/Tests/Functional/FunctionalTest.php +++ b/Tests/Functional/FunctionalTest.php @@ -366,7 +366,6 @@ class FunctionalTest extends WebTestCase ], 'propertyExpression' => [ 'type' => 'integer', - 'pattern' => 'If this is a tech post, the category should be either php or symfony!', ], 'propertyRange' => [ 'type' => 'integer',