Deserialize httpHeader.

See #1354.

Regenerated php-petstore sample.
This commit is contained in:
Arne Jørgensen
2015-10-08 11:25:43 +02:00
parent 733e19c113
commit 3bd4502bbf
5 changed files with 88 additions and 49 deletions

View File

@@ -170,6 +170,13 @@ use \{{invokerPackage}}\ObjectSerializer;
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams{{#returnType}}, '{{returnType}}'{{/returnType}} $headerParams{{#returnType}}, '{{returnType}}'{{/returnType}}
); );
{{#returnType}}
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}', $httpHeader);
{{/returnType}}
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { {{#responses}}{{#dataType}} switch ($e->getCode()) { {{#responses}}{{#dataType}}
case {{code}}: case {{code}}:
@@ -181,11 +188,7 @@ use \{{invokerPackage}}\ObjectSerializer;
throw $e; throw $e;
} }
{{#returnType}} {{#returnType}}
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '{{returnType}}');
{{/returnType}} {{/returnType}}
} }
{{/operation}} {{/operation}}

View File

@@ -146,6 +146,7 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -210,6 +211,7 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -273,6 +275,13 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]' $headerParams, '\Swagger\Client\Model\Pet[]'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -284,11 +293,7 @@ class PetApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]');
} }
@@ -346,6 +351,13 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet[]' $headerParams, '\Swagger\Client\Model\Pet[]'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -357,11 +369,7 @@ class PetApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet[]');
} }
@@ -416,6 +424,9 @@ class PetApi
$httpBody = $formParams; // for HTTP post (form) $httpBody = $formParams; // for HTTP post (form)
} }
//TODO support oauth
$apiKey = $this->apiClient->getApiKeyWithPrefix('api_key'); $apiKey = $this->apiClient->getApiKeyWithPrefix('api_key');
if (isset($apiKey)) { if (isset($apiKey)) {
$headerParams['api_key'] = $apiKey; $headerParams['api_key'] = $apiKey;
@@ -423,9 +434,6 @@ class PetApi
//TODO support oauth
// make the API Call // make the API Call
try try
{ {
@@ -434,6 +442,13 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Pet' $headerParams, '\Swagger\Client\Model\Pet'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -445,11 +460,7 @@ class PetApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Pet');
} }
@@ -523,6 +534,7 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -598,6 +610,7 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -677,6 +690,7 @@ class PetApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }

View File

@@ -145,6 +145,13 @@ class StoreApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, 'map[string,int]' $headerParams, 'map[string,int]'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -156,11 +163,7 @@ class StoreApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, 'map[string,int]');
} }
@@ -216,6 +219,13 @@ class StoreApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order' $headerParams, '\Swagger\Client\Model\Order'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -227,11 +237,7 @@ class StoreApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order');
} }
@@ -294,6 +300,13 @@ class StoreApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\Order' $headerParams, '\Swagger\Client\Model\Order'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -305,11 +318,7 @@ class StoreApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\Order');
} }
@@ -372,6 +381,7 @@ class StoreApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }

View File

@@ -143,6 +143,7 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -204,6 +205,7 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -265,6 +267,7 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -329,6 +332,13 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, 'string' $headerParams, 'string'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, 'string', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -340,11 +350,7 @@ class UserApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, 'string');
} }
@@ -395,6 +401,7 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -463,6 +470,13 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams, '\Swagger\Client\Model\User' $headerParams, '\Swagger\Client\Model\User'
); );
if (!$response) {
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User', $httpHeader);
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
case 200: case 200:
@@ -474,11 +488,7 @@ class UserApi
throw $e; throw $e;
} }
if (!$response) { return null;
return null;
}
return $this->apiClient->getSerializer()->deserialize($response, '\Swagger\Client\Model\User');
} }
@@ -546,6 +556,7 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }
@@ -614,6 +625,7 @@ class UserApi
$queryParams, $httpBody, $queryParams, $httpBody,
$headerParams $headerParams
); );
} catch (ApiException $e) { } catch (ApiException $e) {
switch ($e->getCode()) { switch ($e->getCode()) {
} }

View File

@@ -193,7 +193,7 @@ class ObjectSerializer
$deserialized = $values; $deserialized = $values;
} elseif ($class === '\DateTime') { } elseif ($class === '\DateTime') {
$deserialized = new \DateTime($data); $deserialized = new \DateTime($data);
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) { } elseif (in_array($class, array('void', 'bool', 'string', 'double', 'byte', 'mixed', 'integer', 'float', 'int', 'DateTime', 'number', 'boolean', 'object'))) {
settype($data, $class); settype($data, $class);
$deserialized = $data; $deserialized = $data;
} elseif ($class === '\SplFileObject') { } elseif ($class === '\SplFileObject') {