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 a3482129b0e4..91b9f80bdf17 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 @@ -18,7 +18,10 @@ {{#isContainer}} {{#items}} $asserts[] = new Assert\All([ - new Assert\Type("{{dataType}}") + new Assert\Type("{{dataType}}"), + {{^isPrimitiveType}} + new Assert\Valid(), + {{/isPrimitiveType}} ]); {{/items}} {{/isContainer}} @@ -36,6 +39,9 @@ {{/isFile}} {{^isFile}} $asserts[] = new Assert\Type("{{dataType}}"); + {{^isPrimitiveType}} + $asserts[] = new Assert\Valid(); + {{/isPrimitiveType}} {{/isFile}} {{/isDateTime}} {{/isDate}} 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 b3141f14b99c..fba04f0ff3a9 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/PetController.php @@ -98,6 +98,7 @@ public function addPetAction(Request $request) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\Type("OpenAPI\Server\Model\Pet"); + $asserts[] = new Assert\Valid(); $response = $this->validate($body, $asserts); if ($response instanceof Response) { return $response; @@ -274,7 +275,7 @@ public function findPetsByStatusAction(Request $request) new Assert\Choice([ "available", "pending", "sold" ]) ]); $asserts[] = new Assert\All([ - new Assert\Type("string") + new Assert\Type("string"), ]); $response = $this->validate($status, $asserts); if ($response instanceof Response) { @@ -362,7 +363,7 @@ public function findPetsByTagsAction(Request $request) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\All([ - new Assert\Type("string") + new Assert\Type("string"), ]); $response = $this->validate($tags, $asserts); if ($response instanceof Response) { @@ -546,6 +547,7 @@ public function updatePetAction(Request $request) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\Type("OpenAPI\Server\Model\Pet"); + $asserts[] = new Assert\Valid(); $response = $this->validate($body, $asserts); if ($response instanceof Response) { return $response; diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php index dce68da494d5..41a9f697f62e 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/StoreController.php @@ -327,6 +327,7 @@ public function placeOrderAction(Request $request) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\Type("OpenAPI\Server\Model\Order"); + $asserts[] = new Assert\Valid(); $response = $this->validate($body, $asserts); if ($response instanceof Response) { return $response; 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 d2b32eb4af18..c72f28e2b6c2 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/UserController.php @@ -94,6 +94,7 @@ public function createUserAction(Request $request) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\Type("OpenAPI\Server\Model\User"); + $asserts[] = new Assert\Valid(); $response = $this->validate($body, $asserts); if ($response instanceof Response) { return $response; @@ -180,7 +181,8 @@ public function createUsersWithArrayInputAction(Request $request) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\All([ - new Assert\Type("OpenAPI\Server\Model\User") + new Assert\Type("OpenAPI\Server\Model\User"), + new Assert\Valid(), ]); $response = $this->validate($body, $asserts); if ($response instanceof Response) { @@ -268,7 +270,8 @@ public function createUsersWithListInputAction(Request $request) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\All([ - new Assert\Type("OpenAPI\Server\Model\User") + new Assert\Type("OpenAPI\Server\Model\User"), + new Assert\Valid(), ]); $response = $this->validate($body, $asserts); if ($response instanceof Response) { @@ -680,6 +683,7 @@ public function updateUserAction(Request $request, $username) $asserts = []; $asserts[] = new Assert\NotNull(); $asserts[] = new Assert\Type("OpenAPI\Server\Model\User"); + $asserts[] = new Assert\Valid(); $response = $this->validate($body, $asserts); if ($response instanceof Response) { return $response;