diff --git a/modules/swagger-codegen/src/main/resources/php/api.mustache b/modules/swagger-codegen/src/main/resources/php/api.mustache index 9e2cabc92bc..db1d4c8cb4f 100644 --- a/modules/swagger-codegen/src/main/resources/php/api.mustache +++ b/modules/swagger-codegen/src/main/resources/php/api.mustache @@ -170,6 +170,13 @@ use \{{invokerPackage}}\ObjectSerializer; $queryParams, $httpBody, $headerParams{{#returnType}}, '{{returnType}}'{{/returnType}} ); + {{#returnType}} + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader); + {{/returnType}} } catch (ApiException $e) { switch ($e->getCode()) { {{#responses}}{{#dataType}} case {{code}}: @@ -181,11 +188,7 @@ use \{{invokerPackage}}\ObjectSerializer; throw $e; } {{#returnType}} - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}'); + return null; {{/returnType}} } {{/operation}} diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php index b94fd3c5e72..e8dea97be93 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/PetApi.php @@ -146,6 +146,7 @@ class PetApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -210,6 +211,7 @@ class PetApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -273,6 +275,13 @@ class PetApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet[]' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -284,11 +293,7 @@ class PetApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]'); + return null; } @@ -346,6 +351,13 @@ class PetApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet[]' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -357,11 +369,7 @@ class PetApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]'); + return null; } @@ -434,6 +442,13 @@ class PetApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Pet' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -445,11 +460,7 @@ class PetApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet'); + return null; } @@ -523,6 +534,7 @@ class PetApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -598,6 +610,7 @@ class PetApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -677,6 +690,7 @@ class PetApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php index d73032b3329..b64b52d2225 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/StoreApi.php @@ -145,6 +145,13 @@ class StoreApi $queryParams, $httpBody, $headerParams, 'map[string,int]' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -156,11 +163,7 @@ class StoreApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]'); + return null; } @@ -216,6 +219,13 @@ class StoreApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Order' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -227,11 +237,7 @@ class StoreApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order'); + return null; } @@ -294,6 +300,13 @@ class StoreApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\Order' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -305,11 +318,7 @@ class StoreApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order'); + return null; } @@ -372,6 +381,7 @@ class StoreApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } diff --git a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php index b1bbf32c09f..8ce6301a51e 100644 --- a/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php +++ b/samples/client/petstore/php/SwaggerClient-php/lib/Api/UserApi.php @@ -143,6 +143,7 @@ class UserApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -204,6 +205,7 @@ class UserApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -265,6 +267,7 @@ class UserApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -329,6 +332,13 @@ class UserApi $queryParams, $httpBody, $headerParams, 'string' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -340,11 +350,7 @@ class UserApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, 'string'); + return null; } @@ -395,6 +401,7 @@ class UserApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -463,6 +470,13 @@ class UserApi $queryParams, $httpBody, $headerParams, '\Swagger\Client\Model\User' ); + + if (!$response) { + return null; + } + + return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader); + } catch (ApiException $e) { switch ($e->getCode()) { case 200: @@ -474,11 +488,7 @@ class UserApi throw $e; } - if (!$response) { - return null; - } - - return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User'); + return null; } @@ -546,6 +556,7 @@ class UserApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { } @@ -614,6 +625,7 @@ class UserApi $queryParams, $httpBody, $headerParams ); + } catch (ApiException $e) { switch ($e->getCode()) { }