Skip to content

Commit

Permalink
[PHP] complete support for form style (OpenAPITools#5519)
Browse files Browse the repository at this point in the history
* [BUG][PHP] Parameter property style not fully implemented (related to comment on PR OpenAPITools#3984)

* [AUTOGENERATED][PHP] Sample Files
  • Loading branch information
wing328 authored and MikailBag committed Mar 23, 2020
1 parent 4d06f08 commit 17f4ef1
Show file tree
Hide file tree
Showing 7 changed files with 124 additions and 88 deletions.
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}})) {
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
37 changes: 8 additions & 29 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, '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, '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, 'spaceDelimited', true);
}
if ($http !== null) {
$queryParams['http'] = $http;
}


// query params
if (is_array($url)) {
$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,7 +775,6 @@ protected function findPetsByStatusRequest($status)
$httpBody = '';
$multipart = false;


// query params
if (is_array($status)) {
$status = ObjectSerializer::serializeCollection($status, 'form', true);
Expand All @@ -786,7 +785,6 @@ protected function findPetsByStatusRequest($status)




// body params
$_tempBody = null;

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


// query params
if (is_array($tags)) {
$tags = ObjectSerializer::serializeCollection($tags, 'form', true);
Expand All @@ -1064,7 +1061,6 @@ protected function findPetsByTagsRequest($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

0 comments on commit 17f4ef1

Please sign in to comment.