diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java index 2a3c2ffef01d..fede4f2a34a6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java @@ -417,7 +417,17 @@ public OperationsMap postProcessOperationsWithModels(OperationsMap objs, Listbuild()->serialize($data, $this->convertFormat($format)); + $convertFormat = $this->convertFormat($format); + if ($convertFormat !== null) { + return SerializerBuilder::create()->build()->serialize($data, $convertFormat); + } else { + return is_string($data) ? $data : var_export($data, true); + } } /** diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php index 097275dc0a48..4ed7e7079860 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/StoreApiInterface.php @@ -77,12 +77,12 @@ public function deleteOrder( * @param int &$responseCode The HTTP Response Code * @param array $responseHeaders Additional HTTP headers to return with the response () * - * @return array|object|null + * @return int */ public function getInventory( int &$responseCode, array &$responseHeaders - ): array|object|null; + ): int; /** * Operation getOrderById diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php index f98deb9fd07d..0689aa1f710f 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Api/UserApiInterface.php @@ -147,14 +147,14 @@ public function getUserByName( * @param int &$responseCode The HTTP Response Code * @param array $responseHeaders Additional HTTP headers to return with the response () * - * @return array|object|null + * @return string */ public function loginUser( string $username, string $password, int &$responseCode, array &$responseHeaders - ): array|object|null; + ): string; /** * Operation logoutUser 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 e21a2f138131..7d2600dbb6e7 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 @@ protected function getOutputFormat(string $accept, array $produced): ?string 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/Service/JmsSerializer.php b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/JmsSerializer.php index 5abbc6de3fb9..26d852700fa5 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/JmsSerializer.php +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/Service/JmsSerializer.php @@ -29,7 +29,12 @@ public function __construct() */ public function serialize($data, string $format): string { - return SerializerBuilder::create()->build()->serialize($data, $this->convertFormat($format)); + $convertFormat = $this->convertFormat($format); + if ($convertFormat !== null) { + return SerializerBuilder::create()->build()->serialize($data, $convertFormat); + } else { + return is_string($data) ? $data : var_export($data, true); + } } /** diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/StoreApiInterface.md b/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/StoreApiInterface.md index b6ed0824d5c8..111a791612e1 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/StoreApiInterface.md +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/StoreApiInterface.md @@ -107,7 +107,7 @@ class StoreApi implements StoreApiInterface /** * Implementation of StoreApiInterface#getInventory */ - public function getInventory(int &$responseCode, array &$responseHeaders): array|object|null + public function getInventory(int &$responseCode, array &$responseHeaders): int { // Implement the operation ... } diff --git a/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/UserApiInterface.md b/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/UserApiInterface.md index 2c7e3ba26260..827393e38c5d 100644 --- a/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/UserApiInterface.md +++ b/samples/server/petstore/php-symfony/SymfonyBundle-php/docs/Api/UserApiInterface.md @@ -351,7 +351,7 @@ class UserApi implements UserApiInterface /** * Implementation of UserApiInterface#loginUser */ - public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): array|object|null + public function loginUser(string $username, string $password, int &$responseCode, array &$responseHeaders): string { // Implement the operation ... }