mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-08 11:23:58 +00:00
fix empty object serialization issue
This commit is contained in:
parent
9fd4f39c8c
commit
dcd2c00fe6
@ -71,7 +71,7 @@ class ObjectSerializer
|
|||||||
$values[$data::$attributeMap[$property]] = self::sanitizeForSerialization($data->$getter());
|
$values[$data::$attributeMap[$property]] = self::sanitizeForSerialization($data->$getter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sanitized = $values;
|
$sanitized = (object)$values;
|
||||||
} else {
|
} else {
|
||||||
$sanitized = (string)$data;
|
$sanitized = (string)$data;
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ class ObjectSerializer
|
|||||||
$values[$data::$attributeMap[$property]] = self::sanitizeForSerialization($data->$getter());
|
$values[$data::$attributeMap[$property]] = self::sanitizeForSerialization($data->$getter());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$sanitized = $values;
|
$sanitized = (object)$values;
|
||||||
} else {
|
} else {
|
||||||
$sanitized = (string)$data;
|
$sanitized = (string)$data;
|
||||||
}
|
}
|
||||||
|
@ -316,6 +316,16 @@ class PetApiTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertSame($json['tags'][0]['id'], $pet_id);
|
$this->assertSame($json['tags'][0]['id'], $pet_id);
|
||||||
$this->assertSame($json['tags'][0]['name'], 'test php tag');
|
$this->assertSame($json['tags'][0]['name'], 'test php tag');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// test empty object serialization
|
||||||
|
public function testEmptyPetSerialization()
|
||||||
|
{
|
||||||
|
$new_pet = new Swagger\Client\Model\Pet;
|
||||||
|
// the empty object should be serialised to {}
|
||||||
|
$this->assertSame("{}", "$new_pet");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user