From 7b7c15ce6c642de72150be27fcd62d82c7bb05c6 Mon Sep 17 00:00:00 2001 From: Guillaume Turri Date: Fri, 9 May 2025 21:02:30 +0200 Subject: [PATCH] [php-symfony] Never return 406 when user accepts */* When a query has header "Accept" set to "*/*" it means it accepts everything. It is hence weird to return a 406. This patch ensures it does not occur: when the query accepts everything then we take any produced type. This fixes #13334. This also partly makes the open PR #15560 obsolete (or at least, it provides a workaround) --- .../src/main/resources/php-symfony/Controller.mustache | 4 ++++ .../php-symfony/SymfonyBundle-php/Controller/Controller.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache b/modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache index 023b66c90f7..1c3288d813b 100644 --- a/modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache +++ b/modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache @@ -204,6 +204,10 @@ class Controller extends AbstractController return 'application/xml'; } + if (in_array('*/*', $accept)) { + return $produced[0]; + } + // If we reach this point, we don't have a common ground between server and client return null; } diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php index e21a2f13813..7d2600dbb6e 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php @@ -214,6 +214,10 @@ class Controller extends AbstractController return 'application/xml'; } + if (in_array('*/*', $accept)) { + return $produced[0]; + } + // If we reach this point, we don't have a common ground between server and client return null; }