From 783ab303f1d6afe2df6507b17ea4f724668afa84 Mon Sep 17 00:00:00 2001 From: vnq <28255343+vnq@users.noreply.github.com> Date: Wed, 17 Mar 2021 15:26:47 +0100 Subject: [PATCH 1/3] Fix constraint Valid cannot be nested --- .../resources/php-symfony/api_input_validation.mustache | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php-symfony/api_input_validation.mustache b/modules/openapi-generator/src/main/resources/php-symfony/api_input_validation.mustache index 8c3a1d5e361a..fca8dcd101b8 100644 --- a/modules/openapi-generator/src/main/resources/php-symfony/api_input_validation.mustache +++ b/modules/openapi-generator/src/main/resources/php-symfony/api_input_validation.mustache @@ -19,11 +19,11 @@ {{#items}} $asserts[] = new Assert\All([ new Assert\Type("{{dataType}}"), - {{^isPrimitiveType}} - new Assert\Valid(), - {{/isPrimitiveType}} ]); {{/items}} + {{^isPrimitiveType}} + $asserts[] = new Assert\Valid(); + {{/isPrimitiveType}} {{/isContainer}} {{^isContainer}} {{#isDate}} From f520fe8370198df9534ffe71a813eb9d25e44246 Mon Sep 17 00:00:00 2001 From: vnq <28255343+vnq@users.noreply.github.com> Date: Wed, 17 Mar 2021 17:41:15 +0100 Subject: [PATCH 2/3] Update PetController.php --- .../php-symfony/SymfonyBundle-php/Controller/PetController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php index ba7ecc50c5c8..ca07f62678d6 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php @@ -257,6 +257,7 @@ public function findPetsByStatusAction(Request $request) $asserts[] = new Assert\All([ new Assert\Type("string"), ]); + $asserts[] = new Assert\Valid(); $response = $this->validate($status, $asserts); if ($response instanceof Response) { return $response; @@ -345,6 +346,7 @@ public function findPetsByTagsAction(Request $request) $asserts[] = new Assert\All([ new Assert\Type("string"), ]); + $asserts[] = new Assert\Valid(); $response = $this->validate($tags, $asserts); if ($response instanceof Response) { return $response; From 6e0c738565085f4b7de5b2570e43c72ba6189a66 Mon Sep 17 00:00:00 2001 From: vnq <28255343+vnq@users.noreply.github.com> Date: Wed, 17 Mar 2021 17:42:11 +0100 Subject: [PATCH 3/3] Update UserController.php --- .../SymfonyBundle-php/Controller/UserController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php index 3328426b0490..52af362ae347 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php @@ -163,8 +163,8 @@ public function createUsersWithArrayInputAction(Request $request) $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\All([ new Assert\Type("OpenAPI\Server\Model\User"), - new Assert\Valid(), ]); + $asserts[] = new Assert\Valid(); $response = $this->validate($body, $asserts); if ($response instanceof Response) { return $response; @@ -242,8 +242,8 @@ public function createUsersWithListInputAction(Request $request) $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\All([ new Assert\Type("OpenAPI\Server\Model\User"), - new Assert\Valid(), ]); + $asserts[] = new Assert\Valid(); $response = $this->validate($body, $asserts); if ($response instanceof Response) { return $response;