Skip to content
This repository has been archived by the owner on Jan 30, 2020. It is now read-only.

Commit

Permalink
Merge pull request #14 from sagikazarmark/cast_response
Browse files Browse the repository at this point in the history
Cast response body to stream instead of calling getContent
  • Loading branch information
joelwurtz committed Feb 1, 2016
2 parents 3410a87 + 5910a97 commit bcad455
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Generator/OutputGeneratorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ protected function createResponseDenormalizationStatement($status, $schema, Cont
new Expr\PropertyFetch(new Expr\Variable('this'), 'serializer'),
'deserialize',
[
new Arg(new Expr\MethodCall(new Expr\MethodCall(new Expr\Variable('response'), 'getBody'), 'getContents')),
new Arg(new Expr\Cast\String_(new Expr\MethodCall(new Expr\Variable('response'), 'getBody'))),
new Arg(new Scalar\String_($class)),
new Arg(new Scalar\String_('json'))
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public function getTest($parameters = [], $fetch = self::FETCH_OBJECT)
$response = $this->httpClient->sendRequest($request);
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize($response->getBody()->getContents(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Schema', 'json');
return $this->serializer->deserialize((string) $response->getBody(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Schema', 'json');
}
if ('400' == $response->getStatusCode()) {
return $this->serializer->deserialize($response->getBody()->getContents(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Error', 'json');
return $this->serializer->deserialize((string) $response->getBody(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Error', 'json');
}
if ('404' == $response->getStatusCode()) {
return $this->serializer->deserialize($response->getBody()->getContents(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Error', 'json');
return $this->serializer->deserialize((string) $response->getBody(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Error', 'json');
}
}

Expand All @@ -54,7 +54,7 @@ public function getTestList($parameters = [], $fetch = self::FETCH_OBJECT)
$response = $this->httpClient->sendRequest($request);
if (self::FETCH_OBJECT == $fetch) {
if ('200' == $response->getStatusCode()) {
return $this->serializer->deserialize($response->getBody()->getContents(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Schema[]', 'json');
return $this->serializer->deserialize((string) $response->getBody(), 'Joli\\Jane\\OpenApi\\Tests\\Expected\\Model\\Schema[]', 'json');
}
}

Expand Down

0 comments on commit bcad455

Please sign in to comment.