-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
Milestone
Description
If you have nested models in your swagger spec, the nested object does not deserialize correctly.
Given this Swagger 2.0 spec snippet:
...
"definitions": {
"BookAuthor": {
"properties": {
"name": {
"type": "string"
}
}
},
"Book": {
"properties": {
"name": {
"type": "string"
},
"bookAuthor": {
"$ref": "#/definitions/BookAuthor"
}
}
}
}
...
The PHP client will yield this JSON when returning Book responses.
{"name":"My Book Name","book_author":null}
The fix for this appears to be in the deserialize() method of APIClient.Mustache
Here's the apparent fix:
Change this:
...
foreach ($instance::$swaggerTypes as $property => $type) {
if (isset($data->$property)) {
$original_property_name = $instance::$attributeMap[$property];
$instance->$property = self::deserialize($data->$original_property_name, $type);
}
}
...
To this:
...
foreach ($instance::$swaggerTypes as $property => $type) {
$original_property_name = $instance::$attributeMap[$property];
if (isset($original_property_name)) {
$instance->$property = self::deserialize($data->$original_property_name, $type);
}
}
...