@@ -1527,6 +1527,47 @@ def __init__(self, name):
1527
1527
obj = TestObj .from_dict ({'name' : 'ab' })
1528
1528
self .assertEqual ('ab' , obj .name )
1529
1529
1530
+ def test_deserialize_flattening (self ):
1531
+ # https://github.com/Azure/msrest-for-python/issues/197
1532
+
1533
+ json_body = {
1534
+ "properties" : {
1535
+ "properties" : None
1536
+ }
1537
+ }
1538
+
1539
+ # https://github.com/Azure/azure-sdk-for-python/blob/8d02368f03e3185ba102b54c114fa48f8ef36b48/sdk/machinelearning/azure-mgmt-machinelearningservices/azure/mgmt/machinelearningservices/models/_models_py3.py#L648
1540
+ class ComputeResource (Model ):
1541
+
1542
+ _attribute_map = {
1543
+ 'properties' : {'key' : 'properties' , 'type' : 'VirtualMachine' },
1544
+ }
1545
+
1546
+ def __init__ (self , properties = None , ** kwargs ):
1547
+ self .properties = properties
1548
+
1549
+ class VirtualMachine (Model ):
1550
+
1551
+ _attribute_map = {
1552
+ 'virtual_machine_size' : {'key' : 'properties.virtualMachineSize' , 'type' : 'str' },
1553
+ 'ssh_port' : {'key' : 'properties.sshPort' , 'type' : 'int' },
1554
+ 'address' : {'key' : 'properties.address' , 'type' : 'str' },
1555
+ 'administrator_account' : {'key' : 'properties.administratorAccount' , 'type' : 'VirtualMachineSshCredentials' },
1556
+ }
1557
+
1558
+ def __init__ (self , ** kwargs ):
1559
+ super (VirtualMachineProperties , self ).__init__ (** kwargs )
1560
+ self .virtual_machine_size = kwargs .get ('virtual_machine_size' , None )
1561
+ self .ssh_port = kwargs .get ('ssh_port' , None )
1562
+ self .address = kwargs .get ('address' , None )
1563
+ self .administrator_account = kwargs .get ('administrator_account' , None )
1564
+
1565
+ d = Deserializer ({
1566
+ 'ComputeResource' : ComputeResource ,
1567
+ 'VirtualMachine' : VirtualMachine ,
1568
+ })
1569
+ response = d (ComputeResource , json .dumps (json_body ), 'application/json' )
1570
+
1530
1571
def test_deserialize_storage (self ):
1531
1572
StorageAccount = storage_models .StorageAccount
1532
1573
0 commit comments