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 9366004e84b..b74fa68699c 100644 --- a/modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache +++ b/modules/openapi-generator/src/main/resources/php-symfony/Controller.mustache @@ -183,6 +183,9 @@ class Controller extends AbstractController // Figure out what the client accepts $accept = preg_split("/[\s,]+/", $accept); + // Remove q-factor weighting. E.g. "application/json;q=0.8" becomes "application/json" + $accept = array_map(function ($type) {return explode(';', $type)[0];}, $accept); + if (in_array('*/*', $accept) || in_array('application/*', $accept)) { // Prefer JSON if the client has no preference if (in_array('application/json', $produced)) { 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 559f3bd5a4b..f1d6d929d53 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Controller/Controller.php @@ -193,6 +193,9 @@ class Controller extends AbstractController // Figure out what the client accepts $accept = preg_split("/[\s,]+/", $accept); + // Remove q-factor weighting. E.g. "application/json;q=0.8" becomes "application/json" + $accept = array_map(function ($type) {return explode(';', $type)[0];}, $accept); + if (in_array('*/*', $accept) || in_array('application/*', $accept)) { // Prefer JSON if the client has no preference if (in_array('application/json', $produced)) {