add attributemap to php model, update php petstore sample

This commit is contained in:
William Cheng
2015-03-19 20:58:22 +08:00
parent c109c11bea
commit ab8d62214a
8 changed files with 56 additions and 10 deletions

View File

@@ -182,7 +182,7 @@ class APIClient {
} else if (is_object($data)) {
$values = array();
foreach (array_keys($data::$swaggerTypes) as $property) {
$values[$property] = $this->sanitizeForSerialization($data->$property);
$values[$data::$attributeMap[$property]] = $this->sanitizeForSerialization($data->$property);
}
$sanitized = $values;
} else {
@@ -295,7 +295,8 @@ class APIClient {
$instance = new $class();
foreach ($instance::$swaggerTypes as $property => $type) {
if (isset($data->$property)) {
$instance->$property = self::deserialize($data->$property, $type);
$original_property_name = $instance::$attributeMap[$property];
$instance->$property = self::deserialize($data->$original_property_name, $type);
}
}
$deserialized = $instance;

View File

@@ -28,7 +28,12 @@ class {{classname}} implements ArrayAccess {
static $swaggerTypes = array(
{{#vars}}'{{name}}' => '{{{datatype}}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
);
static $attributeMap = array(
{{#vars}}'{{name}}' => '{{baseName}}'{{#hasMore}},
{{/hasMore}}{{/vars}}
);
{{#vars}}{{#description}}
/**