mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 03:18:53 +00:00
Keep PHP binary responses as strings for easier manipulation.
This commit is contained in:
parent
d2bb505147
commit
6698c532e6
@ -242,7 +242,7 @@ class ObjectSerializer
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif ($class === 'ByteArray') { // byte array
|
||||
$deserialized = unpack('C*', (string)$data);
|
||||
$deserialized = (string)$data;
|
||||
} elseif ($class === '\DateTime') {
|
||||
$deserialized = new \DateTime($data);
|
||||
} elseif (in_array($class, array({{&primitives}}))) {
|
||||
|
@ -188,7 +188,7 @@ use \{{invokerPackage}}\ObjectSerializer;
|
||||
{{#bodyParams}}// body params
|
||||
$_tempBody = null;
|
||||
if (isset(${{paramName}})) {
|
||||
{{^isBinary}}$_tempBody = ${{paramName}};{{/isBinary}}{{#isBinary}}$_tempBody = call_user_func_array('pack', array_merge(array('C*'), ${{paramName}}));{{/isBinary}}
|
||||
$_tempBody = ${{paramName}};
|
||||
}{{/bodyParams}}
|
||||
|
||||
// for model (json/xml)
|
||||
|
@ -1036,7 +1036,7 @@ class PetApi
|
||||
// body params
|
||||
$_tempBody = null;
|
||||
if (isset($body)) {
|
||||
$_tempBody = call_user_func_array('pack', array_merge(array('C*'), $body));
|
||||
$_tempBody = $body;
|
||||
}
|
||||
|
||||
// for model (json/xml)
|
||||
|
@ -242,7 +242,7 @@ class ObjectSerializer
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif ($class === 'ByteArray') { // byte array
|
||||
$deserialized = unpack('C*', (string)$data);
|
||||
$deserialized = (string)$data;
|
||||
} elseif ($class === '\DateTime') {
|
||||
$deserialized = new \DateTime($data);
|
||||
} elseif (in_array($class, array('integer', 'int', 'void', 'number', 'object', 'double', 'float', 'byte', 'DateTime', 'string', 'mixed', 'boolean', 'bool'))) {
|
||||
|
@ -279,7 +279,7 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
// add a new pet (model)
|
||||
$object_serializer = new Swagger\Client\ObjectSerializer();
|
||||
$pet_json_string = json_encode($object_serializer->sanitizeForSerialization($new_pet));
|
||||
$add_response = $pet_api->addPetUsingByteArray(unpack('C*', $pet_json_string));
|
||||
$add_response = $pet_api->addPetUsingByteArray($pet_json_string);
|
||||
// return nothing (void)
|
||||
$this->assertSame($add_response, NULL);
|
||||
// verify added Pet
|
||||
@ -330,9 +330,9 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
// test getPetByIdWithByteArray
|
||||
$pet_id = 10005;
|
||||
$bytes = $pet_api->petPetIdtestingByteArraytrueGet($pet_id);
|
||||
$json = json_decode(call_user_func_array('pack', array_merge(array('C*'), $bytes )), true);
|
||||
$json = json_decode($bytes, true);
|
||||
|
||||
$this->assertInternalType("array", $bytes);
|
||||
$this->assertInternalType("string", $bytes);
|
||||
|
||||
$this->assertSame($json['id'], $pet_id);
|
||||
// not testing name as it's tested by addPetUsingByteArray
|
||||
|
Loading…
Reference in New Issue
Block a user