forked from loafle/openapi-generator-original
update tostring to use sanitizeforserialization
This commit is contained in:
@@ -46,13 +46,13 @@ class ObjectSerializer
|
||||
{
|
||||
|
||||
/**
|
||||
* Build a JSON POST object
|
||||
* Serialize data
|
||||
*
|
||||
* @param mixed $data the data to serialize
|
||||
*
|
||||
* @return string serialized form of $data
|
||||
*/
|
||||
public function sanitizeForSerialization($data)
|
||||
public static function sanitizeForSerialization($data)
|
||||
{
|
||||
if (is_scalar($data) || null === $data) {
|
||||
$sanitized = $data;
|
||||
@@ -60,7 +60,7 @@ class ObjectSerializer
|
||||
$sanitized = $data->format(\DateTime::ISO8601);
|
||||
} elseif (is_array($data)) {
|
||||
foreach ($data as $property => $value) {
|
||||
$data[$property] = $this->sanitizeForSerialization($value);
|
||||
$data[$property] = self::sanitizeForSerialization($value);
|
||||
}
|
||||
$sanitized = $data;
|
||||
} elseif (is_object($data)) {
|
||||
@@ -68,7 +68,7 @@ class ObjectSerializer
|
||||
foreach (array_keys($data::$swaggerTypes) as $property) {
|
||||
$getter = $data::$getters[$property];
|
||||
if ($data->$getter() !== null) {
|
||||
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$getter());
|
||||
$values[$data::$attributeMap[$property]] = self::sanitizeForSerialization($data->$getter());
|
||||
}
|
||||
}
|
||||
$sanitized = $values;
|
||||
@@ -220,7 +220,7 @@ class ObjectSerializer
|
||||
*
|
||||
* @return object an instance of $class
|
||||
*/
|
||||
public function deserialize($data, $class, $httpHeaders=null)
|
||||
public static function deserialize($data, $class, $httpHeaders=null)
|
||||
{
|
||||
if (null === $data) {
|
||||
$deserialized = null;
|
||||
@@ -231,14 +231,14 @@ class ObjectSerializer
|
||||
$subClass_array = explode(',', $inner, 2);
|
||||
$subClass = $subClass_array[1];
|
||||
foreach ($data as $key => $value) {
|
||||
$deserialized[$key] = $this->deserialize($value, $subClass);
|
||||
$deserialized[$key] = self::deserialize($value, $subClass);
|
||||
}
|
||||
}
|
||||
} elseif (strcasecmp(substr($class, -2), '[]') == 0) {
|
||||
$subClass = substr($class, 0, -2);
|
||||
$values = array();
|
||||
foreach ($data as $key => $value) {
|
||||
$values[] = $this->deserialize($value, $subClass);
|
||||
$values[] = self::deserialize($value, $subClass);
|
||||
}
|
||||
$deserialized = $values;
|
||||
} elseif ($class === 'ByteArray') { // byte array
|
||||
@@ -270,7 +270,7 @@ class ObjectSerializer
|
||||
|
||||
$propertyValue = $data->{$instance::$attributeMap[$property]};
|
||||
if (isset($propertyValue)) {
|
||||
$instance->$propertySetter($this->deserialize($propertyValue, $type));
|
||||
$instance->$propertySetter(self::deserialize($propertyValue, $type));
|
||||
}
|
||||
}
|
||||
$deserialized = $instance;
|
||||
|
||||
Reference in New Issue
Block a user