diff --git a/src/Generator/OutputGeneratorTrait.php b/src/Generator/OutputGeneratorTrait.php index eb87eb4..f011694 100644 --- a/src/Generator/OutputGeneratorTrait.php +++ b/src/Generator/OutputGeneratorTrait.php @@ -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')) ] diff --git a/tests/fixtures/model-in-response/expected/Resource/TestResource.php b/tests/fixtures/model-in-response/expected/Resource/TestResource.php index f5280b4..1129609 100644 --- a/tests/fixtures/model-in-response/expected/Resource/TestResource.php +++ b/tests/fixtures/model-in-response/expected/Resource/TestResource.php @@ -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'); } } @@ -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'); } }