Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions modules/openapi-generator/src/main/resources/php/api.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -472,11 +472,22 @@ use {{invokerPackage}}\ObjectSerializer;
$multipart = false;

{{#queryParams}}

// query params
{{#isExplode}}
if (${{paramName}} !== null) {
{{#style}}
if('form' === '{{style}}' && is_array(${{paramName}})) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I may submit a PR later to add a space after if and put line 484 in the same line as line 483, i.e. } else {

foreach(${{paramName}} as $key => $value) {
$queryParams[$key] = $value;
}
}
else {
$queryParams['{{baseName}}'] = ${{paramName}};
}
{{/style}}
{{^style}}
$queryParams['{{baseName}}'] = ${{paramName}};
{{/style}}
}
{{/isExplode}}
{{^isExplode}}
Expand All @@ -487,7 +498,6 @@ use {{invokerPackage}}\ObjectSerializer;
$queryParams['{{baseName}}'] = ${{paramName}};
}
{{/isExplode}}

{{/queryParams}}

{{#headerParams}}
Expand Down
45 changes: 12 additions & 33 deletions samples/client/petstore/php/OpenAPIClient-php/lib/Api/FakeApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,6 @@ protected function testBodyWithQueryParamsRequest($query, $body)
$httpBody = '';
$multipart = false;


// query params
if (is_array($query)) {
$query = ObjectSerializer::serializeCollection($query, '', true);
Expand All @@ -1751,7 +1750,6 @@ protected function testBodyWithQueryParamsRequest($query, $body)




// body params
$_tempBody = null;
if (isset($body)) {
Expand Down Expand Up @@ -2674,34 +2672,27 @@ 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, 'csv', true);
$enum_query_string_array = ObjectSerializer::serializeCollection($enum_query_string_array, 'form', true);
}
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);
}
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);
}
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);
Expand All @@ -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');
Expand Down Expand Up @@ -3001,34 +2991,27 @@ 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);
}
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);
}
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);
}
if ($string_group !== null) {
$queryParams['string_group'] = $string_group;
}


// query params
if (is_array($int64_group)) {
$int64_group = ObjectSerializer::serializeCollection($int64_group, '', true);
Expand All @@ -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);
Expand Down Expand Up @@ -3758,51 +3740,48 @@ protected function testQueryParameterCollectionFormatRequest($pipe, $ioutil, $ht
$httpBody = '';
$multipart = false;


// query params
if (is_array($pipe)) {
$pipe = ObjectSerializer::serializeCollection($pipe, 'csv', true);
$pipe = ObjectSerializer::serializeCollection($pipe, 'form', true);
}
if ($pipe !== null) {
$queryParams['pipe'] = $pipe;
}


// query params
if (is_array($ioutil)) {
$ioutil = ObjectSerializer::serializeCollection($ioutil, 'csv', true);
}
if ($ioutil !== null) {
$queryParams['ioutil'] = $ioutil;
}


// query params
if (is_array($http)) {
$http = ObjectSerializer::serializeCollection($http, 'space', true);
$http = ObjectSerializer::serializeCollection($http, 'spaceDelimited', true);
}
if ($http !== null) {
$queryParams['http'] = $http;
}


// query params
if (is_array($url)) {
$url = ObjectSerializer::serializeCollection($url, 'csv', true);
$url = ObjectSerializer::serializeCollection($url, 'form', true);
}
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;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -775,18 +775,16 @@ protected function findPetsByStatusRequest($status)
$httpBody = '';
$multipart = false;


// query params
if (is_array($status)) {
$status = ObjectSerializer::serializeCollection($status, 'csv', true);
$status = ObjectSerializer::serializeCollection($status, 'form', true);
}
if ($status !== null) {
$queryParams['status'] = $status;
}




// body params
$_tempBody = null;

Expand Down Expand Up @@ -1053,18 +1051,16 @@ protected function findPetsByTagsRequest($tags)
$httpBody = '';
$multipart = false;


// query params
if (is_array($tags)) {
$tags = ObjectSerializer::serializeCollection($tags, 'csv', true);
$tags = ObjectSerializer::serializeCollection($tags, 'form', true);
}
if ($tags !== null) {
$queryParams['tags'] = $tags;
}




// body params
$_tempBody = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,16 +1482,13 @@ protected function loginUserRequest($username, $password)
$httpBody = '';
$multipart = false;


// query params
if (is_array($username)) {
$username = ObjectSerializer::serializeCollection($username, '', true);
}
if ($username !== null) {
$queryParams['username'] = $username;
}


// query params
if (is_array($password)) {
$password = ObjectSerializer::serializeCollection($password, '', true);
Expand All @@ -1502,7 +1499,6 @@ protected function loginUserRequest($username, $password)




// body params
$_tempBody = null;

Expand Down
Loading