From e87c4ea6c040ecfdafafa1af16c83cda4c4304fa Mon Sep 17 00:00:00 2001 From: Julian Vennen Date: Mon, 16 Dec 2024 12:19:24 +0100 Subject: [PATCH] [PHP][php-nextgen] Fix usage of enums in parameters (#20294) --- .../src/main/resources/php-nextgen/api.mustache | 6 +++--- .../echo_api/php-nextgen-streaming/src/Api/HeaderApi.php | 2 +- .../echo_api/php-nextgen-streaming/src/Api/PathApi.php | 2 +- .../echo_api/php-nextgen-streaming/src/Api/QueryApi.php | 2 +- samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php | 2 +- samples/client/echo_api/php-nextgen/src/Api/PathApi.php | 2 +- samples/client/echo_api/php-nextgen/src/Api/QueryApi.php | 2 +- .../php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache b/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache index 006cbbc7523e..6110545eda62 100644 --- a/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache +++ b/modules/openapi-generator/src/main/resources/php-nextgen/api.mustache @@ -711,7 +711,7 @@ use {{invokerPackage}}\ObjectSerializer; {{#queryParams}} // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - ${{paramName}}, + ${{paramName}}{{#isEnumRef}}->value{{/isEnumRef}}, '{{baseName}}', // param base name '{{#schema}}{{openApiType}}{{/schema}}', // openApiType '{{style}}', // style @@ -728,7 +728,7 @@ use {{invokerPackage}}\ObjectSerializer; } {{/collectionFormat}} if (${{paramName}} !== null) { - $headerParams['{{baseName}}'] = ObjectSerializer::toHeaderValue(${{paramName}}); + $headerParams['{{baseName}}'] = ObjectSerializer::toHeaderValue(${{paramName}}{{#isEnumRef}}->value{{/isEnumRef}}); } {{/headerParams}} @@ -742,7 +742,7 @@ use {{invokerPackage}}\ObjectSerializer; if (${{paramName}} !== null) { $resourcePath = str_replace( '{' . '{{baseName}}' . '}', - ObjectSerializer::toPathValue(${{paramName}}), + ObjectSerializer::toPathValue(${{paramName}}{{#isEnumRef}}->value{{/isEnumRef}}), $resourcePath ); } diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Api/HeaderApi.php b/samples/client/echo_api/php-nextgen-streaming/src/Api/HeaderApi.php index 3f2a16f51318..871fd002020b 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Api/HeaderApi.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Api/HeaderApi.php @@ -438,7 +438,7 @@ public function testHeaderIntegerBooleanStringEnumsRequest( } // header params if ($enum_ref_string_header !== null) { - $headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header); + $headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header->value); } diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Api/PathApi.php b/samples/client/echo_api/php-nextgen-streaming/src/Api/PathApi.php index 69e0fcdc645b..e806d61c9453 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Api/PathApi.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Api/PathApi.php @@ -462,7 +462,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE if ($enum_ref_string_path !== null) { $resourcePath = str_replace( '{' . 'enum_ref_string_path' . '}', - ObjectSerializer::toPathValue($enum_ref_string_path), + ObjectSerializer::toPathValue($enum_ref_string_path->value), $resourcePath ); } diff --git a/samples/client/echo_api/php-nextgen-streaming/src/Api/QueryApi.php b/samples/client/echo_api/php-nextgen-streaming/src/Api/QueryApi.php index 220bba31302c..8e64ba5648ce 100644 --- a/samples/client/echo_api/php-nextgen-streaming/src/Api/QueryApi.php +++ b/samples/client/echo_api/php-nextgen-streaming/src/Api/QueryApi.php @@ -424,7 +424,7 @@ public function testEnumRefStringRequest( ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_ref_string_query, + $enum_ref_string_query->value, 'enum_ref_string_query', // param base name 'StringEnumRef', // openApiType 'form', // style diff --git a/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php b/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php index 3f2a16f51318..871fd002020b 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php @@ -438,7 +438,7 @@ public function testHeaderIntegerBooleanStringEnumsRequest( } // header params if ($enum_ref_string_header !== null) { - $headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header); + $headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header->value); } diff --git a/samples/client/echo_api/php-nextgen/src/Api/PathApi.php b/samples/client/echo_api/php-nextgen/src/Api/PathApi.php index 69e0fcdc645b..e806d61c9453 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/PathApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/PathApi.php @@ -462,7 +462,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE if ($enum_ref_string_path !== null) { $resourcePath = str_replace( '{' . 'enum_ref_string_path' . '}', - ObjectSerializer::toPathValue($enum_ref_string_path), + ObjectSerializer::toPathValue($enum_ref_string_path->value), $resourcePath ); } diff --git a/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php b/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php index 220bba31302c..8e64ba5648ce 100644 --- a/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php +++ b/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php @@ -424,7 +424,7 @@ public function testEnumRefStringRequest( ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_ref_string_query, + $enum_ref_string_query->value, 'enum_ref_string_query', // param base name 'StringEnumRef', // openApiType 'form', // style diff --git a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php index 3e9a2126b258..2ae29d84e293 100644 --- a/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php +++ b/samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php @@ -773,7 +773,7 @@ public function fakeEnumEndpointRequest( // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_class, + $enum_class->value, 'enum-class', // param base name 'EnumClass', // openApiType 'form', // style