Skip to content

Commit e87c4ea

Browse files
authored
[PHP][php-nextgen] Fix usage of enums in parameters (#20294)
1 parent 4789124 commit e87c4ea

File tree

8 files changed

+10
-10
lines changed

8 files changed

+10
-10
lines changed

modules/openapi-generator/src/main/resources/php-nextgen/api.mustache

+3-3
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ use {{invokerPackage}}\ObjectSerializer;
711711
{{#queryParams}}
712712
// query params
713713
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
714-
${{paramName}},
714+
${{paramName}}{{#isEnumRef}}->value{{/isEnumRef}},
715715
'{{baseName}}', // param base name
716716
'{{#schema}}{{openApiType}}{{/schema}}', // openApiType
717717
'{{style}}', // style
@@ -728,7 +728,7 @@ use {{invokerPackage}}\ObjectSerializer;
728728
}
729729
{{/collectionFormat}}
730730
if (${{paramName}} !== null) {
731-
$headerParams['{{baseName}}'] = ObjectSerializer::toHeaderValue(${{paramName}});
731+
$headerParams['{{baseName}}'] = ObjectSerializer::toHeaderValue(${{paramName}}{{#isEnumRef}}->value{{/isEnumRef}});
732732
}
733733
{{/headerParams}}
734734

@@ -742,7 +742,7 @@ use {{invokerPackage}}\ObjectSerializer;
742742
if (${{paramName}} !== null) {
743743
$resourcePath = str_replace(
744744
'{' . '{{baseName}}' . '}',
745-
ObjectSerializer::toPathValue(${{paramName}}),
745+
ObjectSerializer::toPathValue(${{paramName}}{{#isEnumRef}}->value{{/isEnumRef}}),
746746
$resourcePath
747747
);
748748
}

samples/client/echo_api/php-nextgen-streaming/src/Api/HeaderApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public function testHeaderIntegerBooleanStringEnumsRequest(
438438
}
439439
// header params
440440
if ($enum_ref_string_header !== null) {
441-
$headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header);
441+
$headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header->value);
442442
}
443443

444444

samples/client/echo_api/php-nextgen-streaming/src/Api/PathApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE
462462
if ($enum_ref_string_path !== null) {
463463
$resourcePath = str_replace(
464464
'{' . 'enum_ref_string_path' . '}',
465-
ObjectSerializer::toPathValue($enum_ref_string_path),
465+
ObjectSerializer::toPathValue($enum_ref_string_path->value),
466466
$resourcePath
467467
);
468468
}

samples/client/echo_api/php-nextgen-streaming/src/Api/QueryApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public function testEnumRefStringRequest(
424424
) ?? []);
425425
// query params
426426
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
427-
$enum_ref_string_query,
427+
$enum_ref_string_query->value,
428428
'enum_ref_string_query', // param base name
429429
'StringEnumRef', // openApiType
430430
'form', // style

samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ public function testHeaderIntegerBooleanStringEnumsRequest(
438438
}
439439
// header params
440440
if ($enum_ref_string_header !== null) {
441-
$headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header);
441+
$headerParams['enum_ref_string_header'] = ObjectSerializer::toHeaderValue($enum_ref_string_header->value);
442442
}
443443

444444

samples/client/echo_api/php-nextgen/src/Api/PathApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ public function testsPathStringPathStringIntegerPathIntegerEnumNonrefStringPathE
462462
if ($enum_ref_string_path !== null) {
463463
$resourcePath = str_replace(
464464
'{' . 'enum_ref_string_path' . '}',
465-
ObjectSerializer::toPathValue($enum_ref_string_path),
465+
ObjectSerializer::toPathValue($enum_ref_string_path->value),
466466
$resourcePath
467467
);
468468
}

samples/client/echo_api/php-nextgen/src/Api/QueryApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,7 @@ public function testEnumRefStringRequest(
424424
) ?? []);
425425
// query params
426426
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
427-
$enum_ref_string_query,
427+
$enum_ref_string_query->value,
428428
'enum_ref_string_query', // param base name
429429
'StringEnumRef', // openApiType
430430
'form', // style

samples/client/petstore/php-nextgen/OpenAPIClient-php/src/Api/FakeApi.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ public function fakeEnumEndpointRequest(
773773

774774
// query params
775775
$queryParams = array_merge($queryParams, ObjectSerializer::toQueryValue(
776-
$enum_class,
776+
$enum_class->value,
777777
'enum-class', // param base name
778778
'EnumClass', // openApiType
779779
'form', // style

0 commit comments

Comments
 (0)