From 3d2ff493e6ae5d0c37718b52989e7eb1f650ebcd Mon Sep 17 00:00:00 2001 From: Julian Vennen Date: Thu, 9 Jan 2025 00:22:43 -0500 Subject: [PATCH] Use conditional access for enumref query params (#20418) --- .../src/main/resources/php-nextgen/api.mustache | 2 +- .../client/echo_api/php-nextgen-streaming/src/Api/QueryApi.php | 2 +- samples/client/echo_api/php-nextgen/src/Api/QueryApi.php | 2 +- .../petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php | 2 +- 4 files changed, 4 insertions(+), 4 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 757c79827c2..bdbe28f85c5 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}}{{#isEnumRef}}->value{{/isEnumRef}}, + ${{paramName}}{{#isEnumRef}}?->value{{/isEnumRef}}, '{{baseName}}', // param base name '{{#schema}}{{openApiType}}{{/schema}}', // openApiType '{{style}}', // style 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 f0e76da188b..674bdd46d7e 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 @@ class QueryApi ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_ref_string_query->value, + $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/QueryApi.php b/samples/client/echo_api/php-nextgen/src/Api/QueryApi.php index f0e76da188b..674bdd46d7e 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 @@ class QueryApi ) ?? []); // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_ref_string_query->value, + $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 e489439ba14..56833392f95 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 @@ class FakeApi // query params $queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue( - $enum_class->value, + $enum_class?->value, 'enum-class', // param base name 'EnumClass', // openApiType 'form', // style