diff --git a/autorest/codegen/models/object_schema.py b/autorest/codegen/models/object_schema.py index a8889551e87..b9d140d4b73 100644 --- a/autorest/codegen/models/object_schema.py +++ b/autorest/codegen/models/object_schema.py @@ -94,6 +94,8 @@ def fill_instance_from_yaml(self, namespace: str, yaml_data: Dict[str, Any], **k properties = [] base_model = None + name = yaml_data["language"]["python"]["name"] + # checking to see if there is a parent class and / or additional properties if yaml_data.get("parents"): immediate_parents = yaml_data["parents"]["immediate"] @@ -113,7 +115,10 @@ def fill_instance_from_yaml(self, namespace: str, yaml_data: Dict[str, Any], **k description="Unmatched properties from the message are deserialized to this collection." ) ) - elif immediate_parent["language"]["default"]["name"] != yaml_data["language"]["default"]["name"]: + elif ( + immediate_parent["language"]["default"]["name"] != name and + immediate_parent['type'] == "object" + ): base_model = id(immediate_parent) # checking to see if this is a polymorphic class @@ -131,7 +136,7 @@ def fill_instance_from_yaml(self, namespace: str, yaml_data: Dict[str, Any], **k ] # this is to ensure that the attribute map type and property type are generated correctly - name = yaml_data["language"]["python"]["name"] + description = yaml_data["language"]["python"]["description"] is_exception = False