Skip to content

Commit 1292fe4

Browse files
committed
Regenerated PHP petstore sample.
1 parent d71d164 commit 1292fe4

File tree

5 files changed

+57
-2
lines changed

5 files changed

+57
-2
lines changed

samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ public function findPetsByStatusWithHttpInfo($status = null)
301301
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
302302

303303
// query params
304+
305+
if (is_array($status)) {
306+
$status = $this->apiClient->getSerializer()->serializeCollection($status, 'multi', true);
307+
}
308+
304309
if ($status !== null) {
305310
$queryParams['status'] = $this->apiClient->getSerializer()->toQueryValue($status);
306311
}
@@ -391,6 +396,11 @@ public function findPetsByTagsWithHttpInfo($tags = null)
391396
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
392397

393398
// query params
399+
400+
if (is_array($tags)) {
401+
$tags = $this->apiClient->getSerializer()->serializeCollection($tags, 'multi', true);
402+
}
403+
394404
if ($tags !== null) {
395405
$queryParams['tags'] = $this->apiClient->getSerializer()->toQueryValue($tags);
396406
}
@@ -487,6 +497,7 @@ public function getPetByIdWithHttpInfo($pet_id)
487497

488498

489499
// path params
500+
490501
if ($pet_id !== null) {
491502
$resourcePath = str_replace(
492503
"{" . "petId" . "}",
@@ -591,6 +602,7 @@ public function updatePetWithFormWithHttpInfo($pet_id, $name = null, $status = n
591602

592603

593604
// path params
605+
594606
if ($pet_id !== null) {
595607
$resourcePath = str_replace(
596608
"{" . "petId" . "}",
@@ -694,10 +706,12 @@ public function deletePetWithHttpInfo($pet_id, $api_key = null)
694706

695707

696708
// header params
709+
697710
if ($api_key !== null) {
698711
$headerParams['api_key'] = $this->apiClient->getSerializer()->toHeaderValue($api_key);
699712
}
700713
// path params
714+
701715
if ($pet_id !== null) {
702716
$resourcePath = str_replace(
703717
"{" . "petId" . "}",
@@ -792,6 +806,7 @@ public function uploadFileWithHttpInfo($pet_id, $additional_metadata = null, $fi
792806

793807

794808
// path params
809+
795810
if ($pet_id !== null) {
796811
$resourcePath = str_replace(
797812
"{" . "petId" . "}",

samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ public function getOrderByIdWithHttpInfo($order_id)
314314

315315

316316
// path params
317+
317318
if ($order_id !== null) {
318319
$resourcePath = str_replace(
319320
"{" . "orderId" . "}",
@@ -407,6 +408,7 @@ public function deleteOrderWithHttpInfo($order_id)
407408

408409

409410
// path params
411+
410412
if ($order_id !== null) {
411413
$resourcePath = str_replace(
412414
"{" . "orderId" . "}",

samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,9 +371,11 @@ public function loginUserWithHttpInfo($username = null, $password = null)
371371
$headerParams['Content-Type'] = ApiClient::selectHeaderContentType(array());
372372

373373
// query params
374+
374375
if ($username !== null) {
375376
$queryParams['username'] = $this->apiClient->getSerializer()->toQueryValue($username);
376377
}// query params
378+
377379
if ($password !== null) {
378380
$queryParams['password'] = $this->apiClient->getSerializer()->toQueryValue($password);
379381
}
@@ -537,6 +539,7 @@ public function getUserByNameWithHttpInfo($username)
537539

538540

539541
// path params
542+
540543
if ($username !== null) {
541544
$resourcePath = str_replace(
542545
"{" . "username" . "}",
@@ -632,6 +635,7 @@ public function updateUserWithHttpInfo($username, $body = null)
632635

633636

634637
// path params
638+
635639
if ($username !== null) {
636640
$resourcePath = str_replace(
637641
"{" . "username" . "}",
@@ -721,6 +725,7 @@ public function deleteUserWithHttpInfo($username)
721725

722726

723727
// path params
728+
724729
if ($username !== null) {
725730
$resourcePath = str_replace(
726731
"{" . "username" . "}",

samples/client/petstore/php/SwaggerClient-php/lib/Configuration.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ public static function toDebugReport()
516516
$report = "PHP SDK (Swagger\Client) Debug Report:\n";
517517
$report .= " OS: ".php_uname()."\n";
518518
$report .= " PHP Version: ".phpversion()."\n";
519-
$report .= " Swagger Spec Version: 1.0.0\n";
519+
$report .= " OpenAPI Spec Version: 1.0.0\n";
520520
$report .= " SDK Package Version: 1.0.0\n";
521521
$report .= " Temp Folder Path: ".self::getDefaultConfiguration()->getTempFolderPath()."\n";
522522

samples/client/petstore/php/SwaggerClient-php/lib/ObjectSerializer.php

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,39 @@ public function toString($value)
161161
}
162162
}
163163

164+
/**
165+
* Serialize an array to a string.
166+
*
167+
* @param array $collection collection to serialize to a string
168+
* @param string $collectionFormat the format use for serialization (csv,
169+
* ssv, tsv, pipes, multi)
170+
*
171+
* @return string
172+
*/
173+
public function serializeCollection(array $collection, $collectionFormat, $allowCollectionFormatMulti=false)
174+
{
175+
if ($allowCollectionFormatMulti && ('multi' === $collectionFormat)) {
176+
// http_build_query() almost does the job for us. We just
177+
// need to fix the result of multidimensional arrays.
178+
return preg_replace('/%5B[0-9]+%5D=/', '=', http_build_query($collection, '', '&'));
179+
}
180+
switch ($collectionFormat) {
181+
case 'pipes':
182+
return implode('|', $collection);
183+
184+
case 'tsv':
185+
return implode("\t", $collection);
186+
187+
case 'ssv':
188+
return implode(' ', $collection);
189+
190+
case 'csv':
191+
// Deliberate fall through. CSV is default format.
192+
default:
193+
return implode(',', $collection);
194+
}
195+
}
196+
164197
/**
165198
* Deserialize a JSON string into an object
166199
*
@@ -193,7 +226,7 @@ public function deserialize($data, $class, $httpHeader=null)
193226
$deserialized = $values;
194227
} elseif ($class === '\DateTime') {
195228
$deserialized = new \DateTime($data);
196-
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {
229+
} elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
197230
settype($data, $class);
198231
$deserialized = $data;
199232
} elseif ($class === '\SplFileObject') {

0 commit comments

Comments
 (0)