diff --git a/msrest/serialization.py b/msrest/serialization.py index aea5cb5..53682da 100644 --- a/msrest/serialization.py +++ b/msrest/serialization.py @@ -1022,7 +1022,8 @@ class Deserializer(object): if "additional_properties" in attribute_map and attribute_map.get("additional_properties", {}).get("key") != '': # Check empty string. If it's not empty, someone has a real "additionalProperties" return None - known_json_keys = {desc['key'] for desc in attribute_map.values() if desc['key'] != ''} + known_json_keys = {_decode_attribute_map_key(_FLATTEN.split(desc['key'])[0]) + for desc in attribute_map.values() if desc['key'] != ''} present_json_keys = set(data.keys()) missing_keys = present_json_keys - known_json_keys return {key: data[key] for key in missing_keys} diff --git a/tests/test_serialization.py b/tests/test_serialization.py index 8f6bc77..a25f3c8 100644 --- a/tests/test_serialization.py +++ b/tests/test_serialization.py @@ -2076,6 +2076,36 @@ class TestRuntimeDeserialized(unittest.TestCase): self.assertEquals(m.additional_properties['PropArray'], [1,2,3]) self.assertEquals(m.additional_properties['PropDict'], {"a": "b"}) + def test_additional_properties_flattening(self): + + class AdditionalTest(Model): + + _attribute_map = { + "name": {"key":"Name", "type":"str"}, + "content" :{"key":"Properties.Content", "type":"str"} + } + + def __init__(self, name=None, content=None): + super(AdditionalTest, self).__init__() + self.name = name + self.content = content + + message = { + "Name": "test", + "Properties": { + "Content": "Content", + "Unknown": "Unknown" + } + } + + d = Deserializer({'AdditionalTest': AdditionalTest}) + + m = d('AdditionalTest', message) + + self.assertEquals(m.name, "test") + self.assertEquals(m.content, "Content") + self.assertEquals(m.additional_properties, {}) + class TestModelInstanceEquality(unittest.TestCase):