diff --git a/modules/openapi-generator/src/main/resources/php/api.mustache b/modules/openapi-generator/src/main/resources/php/api.mustache index 537cf815951b..2014b8ec83bd 100644 --- a/modules/openapi-generator/src/main/resources/php/api.mustache +++ b/modules/openapi-generator/src/main/resources/php/api.mustache @@ -472,11 +472,22 @@ use {{invokerPackage}}\ObjectSerializer; $multipart = false; {{#queryParams}} - // query params {{#isExplode}} if (${{paramName}} !== null) { + {{#style}} + if('form' === '{{style}}' && is_array(${{paramName}})) { + foreach(${{paramName}} as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['{{baseName}}'] = ${{paramName}}; + } + {{/style}} + {{^style}} $queryParams['{{baseName}}'] = ${{paramName}}; + {{/style}} } {{/isExplode}} {{^isExplode}} @@ -487,7 +498,6 @@ use {{invokerPackage}}\ObjectSerializer; $queryParams['{{baseName}}'] = ${{paramName}}; } {{/isExplode}} - {{/queryParams}} {{#headerParams}} diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index 5dacb7f31086..c2508552e1a0 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -1740,7 +1740,6 @@ protected function testBodyWithQueryParamsRequest($query, $body) $httpBody = ''; $multipart = false; - // query params if (is_array($query)) { $query = ObjectSerializer::serializeCollection($query, '', true); @@ -1751,7 +1750,6 @@ protected function testBodyWithQueryParamsRequest($query, $body) - // body params $_tempBody = null; if (isset($body)) { @@ -2674,7 +2672,6 @@ protected function testEnumParametersRequest($enum_header_string_array = null, $ $httpBody = ''; $multipart = false; - // query params if (is_array($enum_query_string_array)) { $enum_query_string_array = ObjectSerializer::serializeCollection($enum_query_string_array, 'form', true); @@ -2682,8 +2679,6 @@ protected function testEnumParametersRequest($enum_header_string_array = null, $ if ($enum_query_string_array !== null) { $queryParams['enum_query_string_array'] = $enum_query_string_array; } - - // query params if (is_array($enum_query_string)) { $enum_query_string = ObjectSerializer::serializeCollection($enum_query_string, '', true); @@ -2691,8 +2686,6 @@ protected function testEnumParametersRequest($enum_header_string_array = null, $ if ($enum_query_string !== null) { $queryParams['enum_query_string'] = $enum_query_string; } - - // query params if (is_array($enum_query_integer)) { $enum_query_integer = ObjectSerializer::serializeCollection($enum_query_integer, '', true); @@ -2700,8 +2693,6 @@ protected function testEnumParametersRequest($enum_header_string_array = null, $ if ($enum_query_integer !== null) { $queryParams['enum_query_integer'] = $enum_query_integer; } - - // query params if (is_array($enum_query_double)) { $enum_query_double = ObjectSerializer::serializeCollection($enum_query_double, '', true); @@ -2710,7 +2701,6 @@ protected function testEnumParametersRequest($enum_header_string_array = null, $ $queryParams['enum_query_double'] = $enum_query_double; } - // header params if (is_array($enum_header_string_array)) { $enum_header_string_array = ObjectSerializer::serializeCollection($enum_header_string_array, 'csv'); @@ -3001,7 +2991,6 @@ protected function testGroupParametersRequest($associative_array) $httpBody = ''; $multipart = false; - // query params if (is_array($required_string_group)) { $required_string_group = ObjectSerializer::serializeCollection($required_string_group, '', true); @@ -3009,8 +2998,6 @@ protected function testGroupParametersRequest($associative_array) if ($required_string_group !== null) { $queryParams['required_string_group'] = $required_string_group; } - - // query params if (is_array($required_int64_group)) { $required_int64_group = ObjectSerializer::serializeCollection($required_int64_group, '', true); @@ -3018,8 +3005,6 @@ protected function testGroupParametersRequest($associative_array) if ($required_int64_group !== null) { $queryParams['required_int64_group'] = $required_int64_group; } - - // query params if (is_array($string_group)) { $string_group = ObjectSerializer::serializeCollection($string_group, '', true); @@ -3027,8 +3012,6 @@ protected function testGroupParametersRequest($associative_array) if ($string_group !== null) { $queryParams['string_group'] = $string_group; } - - // query params if (is_array($int64_group)) { $int64_group = ObjectSerializer::serializeCollection($int64_group, '', true); @@ -3037,7 +3020,6 @@ protected function testGroupParametersRequest($associative_array) $queryParams['int64_group'] = $int64_group; } - // header params if ($required_boolean_group !== null) { $headerParams['required_boolean_group'] = ObjectSerializer::toHeaderValue($required_boolean_group); @@ -3758,7 +3740,6 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht $httpBody = ''; $multipart = false; - // query params if (is_array($pipe)) { $pipe = ObjectSerializer::serializeCollection($pipe, 'form', true); @@ -3766,8 +3747,6 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht if ($pipe !== null) { $queryParams['pipe'] = $pipe; } - - // query params if (is_array($ioutil)) { $ioutil = ObjectSerializer::serializeCollection($ioutil, 'csv', true); @@ -3775,8 +3754,6 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht if ($ioutil !== null) { $queryParams['ioutil'] = $ioutil; } - - // query params if (is_array($http)) { $http = ObjectSerializer::serializeCollection($http, 'spaceDelimited', true); @@ -3784,8 +3761,6 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht if ($http !== null) { $queryParams['http'] = $http; } - - // query params if (is_array($url)) { $url = ObjectSerializer::serializeCollection($url, 'form', true); @@ -3793,16 +3768,20 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht if ($url !== null) { $queryParams['url'] = $url; } - - // query params if ($context !== null) { - $queryParams['context'] = $context; + if('form' === 'form' && is_array($context)) { + foreach($context as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['context'] = $context; + } } - // body params $_tempBody = null; diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index f949d0acb66c..90c6ef022319 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -775,7 +775,6 @@ protected function findPetsByStatusRequest($status) $httpBody = ''; $multipart = false; - // query params if (is_array($status)) { $status = ObjectSerializer::serializeCollection($status, 'form', true); @@ -786,7 +785,6 @@ protected function findPetsByStatusRequest($status) - // body params $_tempBody = null; @@ -1053,7 +1051,6 @@ protected function findPetsByTagsRequest($tags) $httpBody = ''; $multipart = false; - // query params if (is_array($tags)) { $tags = ObjectSerializer::serializeCollection($tags, 'form', true); @@ -1064,7 +1061,6 @@ protected function findPetsByTagsRequest($tags) - // body params $_tempBody = null; diff --git a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php index 9345f4b155b5..22b217fc4eaa 100644 --- a/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -1482,7 +1482,6 @@ protected function loginUserRequest($username, $password) $httpBody = ''; $multipart = false; - // query params if (is_array($username)) { $username = ObjectSerializer::serializeCollection($username, '', true); @@ -1490,8 +1489,6 @@ protected function loginUserRequest($username, $password) if ($username !== null) { $queryParams['username'] = $username; } - - // query params if (is_array($password)) { $password = ObjectSerializer::serializeCollection($password, '', true); @@ -1502,7 +1499,6 @@ protected function loginUserRequest($username, $password) - // body params $_tempBody = null; diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php index e2a83116f44f..6d1a24aa7de8 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php @@ -1774,15 +1774,20 @@ protected function testBodyWithQueryParamsRequest($query, $user) $httpBody = ''; $multipart = false; - // query params if ($query !== null) { - $queryParams['query'] = $query; + if('form' === 'form' && is_array($query)) { + foreach($query as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['query'] = $query; + } } - // body params $_tempBody = null; if (isset($user)) { @@ -2705,31 +2710,51 @@ protected function testEnumParametersRequest($enum_header_string_array = null, $ $httpBody = ''; $multipart = false; - // query params if ($enum_query_string_array !== null) { - $queryParams['enum_query_string_array'] = $enum_query_string_array; + if('form' === 'form' && is_array($enum_query_string_array)) { + foreach($enum_query_string_array as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['enum_query_string_array'] = $enum_query_string_array; + } } - - // query params if ($enum_query_string !== null) { - $queryParams['enum_query_string'] = $enum_query_string; + if('form' === 'form' && is_array($enum_query_string)) { + foreach($enum_query_string as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['enum_query_string'] = $enum_query_string; + } } - - // query params if ($enum_query_integer !== null) { - $queryParams['enum_query_integer'] = $enum_query_integer; + if('form' === 'form' && is_array($enum_query_integer)) { + foreach($enum_query_integer as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['enum_query_integer'] = $enum_query_integer; + } } - - // query params if ($enum_query_double !== null) { - $queryParams['enum_query_double'] = $enum_query_double; + if('form' === 'form' && is_array($enum_query_double)) { + foreach($enum_query_double as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['enum_query_double'] = $enum_query_double; + } } - // header params if (is_array($enum_header_string_array)) { $enum_header_string_array = ObjectSerializer::serializeCollection($enum_header_string_array, 'csv'); @@ -3020,31 +3045,51 @@ protected function testGroupParametersRequest($associative_array) $httpBody = ''; $multipart = false; - // query params if ($required_string_group !== null) { - $queryParams['required_string_group'] = $required_string_group; + if('form' === 'form' && is_array($required_string_group)) { + foreach($required_string_group as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['required_string_group'] = $required_string_group; + } } - - // query params if ($required_int64_group !== null) { - $queryParams['required_int64_group'] = $required_int64_group; + if('form' === 'form' && is_array($required_int64_group)) { + foreach($required_int64_group as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['required_int64_group'] = $required_int64_group; + } } - - // query params if ($string_group !== null) { - $queryParams['string_group'] = $string_group; + if('form' === 'form' && is_array($string_group)) { + foreach($string_group as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['string_group'] = $string_group; + } } - - // query params if ($int64_group !== null) { - $queryParams['int64_group'] = $int64_group; + if('form' === 'form' && is_array($int64_group)) { + foreach($int64_group as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['int64_group'] = $int64_group; + } } - // header params if ($required_boolean_group !== null) { $headerParams['required_boolean_group'] = ObjectSerializer::toHeaderValue($required_boolean_group); @@ -3769,13 +3814,17 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht $httpBody = ''; $multipart = false; - // query params if ($pipe !== null) { - $queryParams['pipe'] = $pipe; + if('form' === 'form' && is_array($pipe)) { + foreach($pipe as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['pipe'] = $pipe; + } } - - // query params if (is_array($ioutil)) { $ioutil = ObjectSerializer::serializeCollection($ioutil, 'form', true); @@ -3783,8 +3832,6 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht if ($ioutil !== null) { $queryParams['ioutil'] = $ioutil; } - - // query params if (is_array($http)) { $http = ObjectSerializer::serializeCollection($http, 'spaceDelimited', true); @@ -3792,8 +3839,6 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht if ($http !== null) { $queryParams['http'] = $http; } - - // query params if (is_array($url)) { $url = ObjectSerializer::serializeCollection($url, 'form', true); @@ -3801,16 +3846,20 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht if ($url !== null) { $queryParams['url'] = $url; } - - // query params if ($context !== null) { - $queryParams['context'] = $context; + if('form' === 'form' && is_array($context)) { + foreach($context as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['context'] = $context; + } } - // body params $_tempBody = null; diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php index 993e951e1bbd..4e1803989cac 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/PetApi.php @@ -801,7 +801,6 @@ protected function findPetsByStatusRequest($status) $httpBody = ''; $multipart = false; - // query params if (is_array($status)) { $status = ObjectSerializer::serializeCollection($status, 'form', true); @@ -812,7 +811,6 @@ protected function findPetsByStatusRequest($status) - // body params $_tempBody = null; @@ -1079,7 +1077,6 @@ protected function findPetsByTagsRequest($tags) $httpBody = ''; $multipart = false; - // query params if (is_array($tags)) { $tags = ObjectSerializer::serializeCollection($tags, 'form', true); @@ -1090,7 +1087,6 @@ protected function findPetsByTagsRequest($tags) - // body params $_tempBody = null; diff --git a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php index 4da3fa6fe20b..a274723a1fb7 100644 --- a/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php +++ b/samples/openapi3/client/petstore/php/OpenAPIClient-php/lib/Api/UserApi.php @@ -1482,21 +1482,31 @@ protected function loginUserRequest($username, $password) $httpBody = ''; $multipart = false; - // query params if ($username !== null) { - $queryParams['username'] = $username; + if('form' === 'form' && is_array($username)) { + foreach($username as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['username'] = $username; + } } - - // query params if ($password !== null) { - $queryParams['password'] = $password; + if('form' === 'form' && is_array($password)) { + foreach($password as $key => $value) { + $queryParams[$key] = $value; + } + } + else { + $queryParams['password'] = $password; + } } - // body params $_tempBody = null;