forked from loafle/openapi-generator-original
fix php map, add test case for get inventory
This commit is contained in:
parent
59ca8bd986
commit
d0f9345c5a
@ -376,17 +376,16 @@ class ApiClient {
|
||||
{
|
||||
if (null === $data) {
|
||||
$deserialized = null;
|
||||
} elseif (substr($class, 0, 4) == 'map[') {
|
||||
} elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int]
|
||||
$inner = substr($class, 4, -1);
|
||||
$values = array();
|
||||
$deserialized = array();
|
||||
if(strrpos($inner, ",") !== false) {
|
||||
$subClass_array = explode(',', $inner, 2);
|
||||
$subClass = $subClass_array[1];
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = array($key => self::deserialize($value, $subClass));
|
||||
$deserialized[$key] = self::deserialize($value, $subClass);
|
||||
}
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
||||
$subClass = substr($class, 6, -1);
|
||||
$values = array();
|
||||
|
@ -381,17 +381,16 @@ class ApiClient {
|
||||
{
|
||||
if (null === $data) {
|
||||
$deserialized = null;
|
||||
} elseif (substr($class, 0, 4) == 'map[') {
|
||||
} elseif (substr($class, 0, 4) == 'map[') { # for associative array e.g. map[string,int]
|
||||
$inner = substr($class, 4, -1);
|
||||
$values = array();
|
||||
$deserialized = array();
|
||||
if(strrpos($inner, ",") !== false) {
|
||||
$subClass_array = explode(',', $inner, 2);
|
||||
$subClass = $subClass_array[1];
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = array($key => self::deserialize($value, $subClass));
|
||||
$deserialized[$key] = self::deserialize($value, $subClass);
|
||||
}
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif (strcasecmp(substr($class, 0, 6),'array[') == 0) {
|
||||
$subClass = substr($class, 6, -1);
|
||||
$values = array();
|
||||
|
@ -181,7 +181,7 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($response->name, 'PHP Unit Test');
|
||||
}
|
||||
|
||||
// test
|
||||
// test upload file
|
||||
public function testUploadFile()
|
||||
{
|
||||
// initialize the API client
|
||||
@ -194,6 +194,20 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertSame($add_response, NULL);
|
||||
}
|
||||
|
||||
// test get inventory
|
||||
public function testGetInventory()
|
||||
{
|
||||
// initialize the API client
|
||||
$api_client = new SwaggerClient\APIClient('http://petstore.swagger.io/v2');
|
||||
$store_api = new SwaggerClient\StoreAPI($api_client);
|
||||
// get inventory
|
||||
$get_response = $store_api->getInventory();
|
||||
|
||||
$this->assertInternalType("int", $get_response['sold']);
|
||||
$this->assertInternalType("int", $get_response['pending']);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user