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
This commit is contained in:
pratyam 2020-07-04 16:27:40 +02:00 committed by GitHub
parent 8e0713be53
commit fe39acd6a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 4 deletions

View File

@ -1,6 +1,11 @@
CHANGELOG CHANGELOG
========= =========
3.8.0
------
* remove pattern added from the Expression Violation message.
3.7.0 (unreleased) 3.7.0 (unreleased)
------------------ ------------------

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->setEnum(array_values($values)); $property->setEnum(array_values($values));
} elseif ($annotation instanceof Assert\Expression) {
$this->appendPattern($property, $annotation->message);
} elseif ($annotation instanceof Assert\Range) { } elseif ($annotation instanceof Assert\Range) {
$property->setMinimum($annotation->min); $property->setMinimum($annotation->min);
$property->setMaximum($annotation->max); $property->setMaximum($annotation->max);

View File

@ -45,7 +45,7 @@ class ApiPlatformDescriberTest extends AbstractDescriberTest
$this->assertEquals($expectedApi->toArray(), $this->getSwaggerDoc()->toArray()); $this->assertEquals($expectedApi->toArray(), $this->getSwaggerDoc()->toArray());
} }
protected function setUp() protected function setUp(): void
{ {
$this->documentation = new Documentation(new ResourceNameCollection(['dummy' => 'dummy'])); $this->documentation = new Documentation(new ResourceNameCollection(['dummy' => 'dummy']));

View File

@ -366,7 +366,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',