Skip to content

Commit

Permalink
[PHP][php-nextgen] Fix usage of enums in parameters (#20294)
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianVennen authored Dec 16, 2024
1 parent 4789124 commit e87c4ea
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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}}

Expand All @@ -742,7 +742,7 @@ use {{invokerPackage}}\ObjectSerializer;
if (${{paramName}} !== null) {
$resourcePath = str_replace(
'{' . '{{baseName}}' . '}',
ObjectSerializer::toPathValue(${{paramName}}),
ObjectSerializer::toPathValue(${{paramName}}{{#isEnumRef}}->value{{/isEnumRef}}),
$resourcePath
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/php-nextgen/src/Api/HeaderApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/php-nextgen/src/Api/PathApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
}
Expand Down
2 changes: 1 addition & 1 deletion samples/client/echo_api/php-nextgen/src/Api/QueryApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e87c4ea

Please sign in to comment.