{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/autorest/issues/1729","repository_url":"https://api.github.com/repos/Azure/autorest","labels_url":"https://api.github.com/repos/Azure/autorest/issues/1729/labels{/name}","comments_url":"https://api.github.com/repos/Azure/autorest/issues/1729/comments","events_url":"https://api.github.com/repos/Azure/autorest/issues/1729/events","html_url":"https://github.com/Azure/autorest/issues/1729","id":201446980,"number":1729,"title":"[Python] Unable to deserialize when RestAPI answer is a subtype","user":{"login":"lmazuel","id":1050156,"avatar_url":"https://avatars.githubusercontent.com/u/1050156?v=3","gravatar_id":"","url":"https://api.github.com/users/lmazuel","html_url":"https://github.com/lmazuel","followers_url":"https://api.github.com/users/lmazuel/followers","following_url":"https://api.github.com/users/lmazuel/following{/other_user}","gists_url":"https://api.github.com/users/lmazuel/gists{/gist_id}","starred_url":"https://api.github.com/users/lmazuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmazuel/subscriptions","organizations_url":"https://api.github.com/users/lmazuel/orgs","repos_url":"https://api.github.com/users/lmazuel/repos","events_url":"https://api.github.com/users/lmazuel/events{/privacy}","received_events_url":"https://api.github.com/users/lmazuel/received_events","type":"User","site_admin":false},"labels":[{"id":179169898,"url":"https://api.github.com/repos/Azure/autorest/labels/bug","name":"bug","color":"fc2929","default":true},{"id":330249846,"url":"https://api.github.com/repos/Azure/autorest/labels/python","name":"python","color":"3572A5","default":false}],"state":"open","locked":false,"assignee":{"login":"annatisch","id":8689453,"avatar_url":"https://avatars.githubusercontent.com/u/8689453?v=3","gravatar_id":"","url":"https://api.github.com/users/annatisch","html_url":"https://github.com/annatisch","followers_url":"https://api.github.com/users/annatisch/followers","following_url":"https://api.github.com/users/annatisch/following{/other_user}","gists_url":"https://api.github.com/users/annatisch/gists{/gist_id}","starred_url":"https://api.github.com/users/annatisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annatisch/subscriptions","organizations_url":"https://api.github.com/users/annatisch/orgs","repos_url":"https://api.github.com/users/annatisch/repos","events_url":"https://api.github.com/users/annatisch/events{/privacy}","received_events_url":"https://api.github.com/users/annatisch/received_events","type":"User","site_admin":false},"assignees":[{"login":"annatisch","id":8689453,"avatar_url":"https://avatars.githubusercontent.com/u/8689453?v=3","gravatar_id":"","url":"https://api.github.com/users/annatisch","html_url":"https://github.com/annatisch","followers_url":"https://api.github.com/users/annatisch/followers","following_url":"https://api.github.com/users/annatisch/following{/other_user}","gists_url":"https://api.github.com/users/annatisch/gists{/gist_id}","starred_url":"https://api.github.com/users/annatisch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/annatisch/subscriptions","organizations_url":"https://api.github.com/users/annatisch/orgs","repos_url":"https://api.github.com/users/annatisch/repos","events_url":"https://api.github.com/users/annatisch/events{/privacy}","received_events_url":"https://api.github.com/users/annatisch/received_events","type":"User","site_admin":false}],"milestone":null,"comments":0,"created_at":"2017-01-18T00:36:24Z","updated_at":"2017-01-18T00:40:30Z","closed_at":null,"body":"In [Machine Learning Swagger](https://github.com/Azure/azure-rest-api-specs/blob/master/arm-machinelearning/2016-05-01-preview/swagger/webservices.json): \r\n\r\n```json\r\n    \"WebServiceProperties\": {\r\n      \"type\": \"object\",\r\n      \"description\": \"The set of properties specific to the Azure ML web service resource.\",\r\n      \"required\": [\r\n        \"packageType\"\r\n      ],\r\n      \"discriminator\": \"packageType\",\r\n.......\r\n        \"packageType\": {\r\n          \"type\": \"string\",\r\n          \"description\": \"Specifies the package type. Valid values are Graph (Specifies a web service published through the Machine Learning Studio) and Code (Specifies a web service published using code such as Python). Note: Code is not supported at this time.\",\r\n          \"enum\": [\r\n            \"Graph\"\r\n          ]        \r\n        }\r\n      }\r\n    },\r\n    \"WebServicePropertiesForGraph\": {\r\n      \"description\": \"Properties specific to a Graph based web service.\",\r\n      \"x-ms-discriminator-value\": \"Graph\",\r\n      \"allOf\": [\r\n        {\r\n          \"$ref\": \"#/definitions/WebServiceProperties\"\r\n        }\r\n      ],\r\n```\r\n\r\nwhen deserializing an answer from the RestAPI, it fails:\r\n```python\r\nTraceback (most recent call last):\r\n  File \"D:\\VSProjects\\msrest-for-python\\msrest\\serialization.py\", line 837, in _instantiate_model\r\n    response_obj = response(**kwargs)\r\nTypeError: __init__() got an unexpected keyword argument 'package_type'\r\nDuring handling of the above exception, another exception occurred:\r\nTraceback (most recent call last):\r\n  File \"d:\\vsprojects\\azure-sdk-for-python\\azure-mgmt\\tests\\test_mgmt_machinelearning.py\", line 288, in test_ml\r\n    webservice = async_webservice.result()\r\n  File \"D:\\VSProjects\\msrestazure-for-python\\msrestazure\\azure_operation.py\", line 473, in result\r\n    self.wait(timeout)\r\n  File \"D:\\VSProjects\\msrestazure-for-python\\msrestazure\\azure_operation.py\", line 486, in wait\r\n    raise self._exception\r\n  File \"D:\\VSProjects\\msrestazure-for-python\\msrestazure\\azure_operation.py\", line 367, in _start\r\n    self._poll(update_cmd)\r\n  File \"D:\\VSProjects\\msrestazure-for-python\\msrestazure\\azure_operation.py\", line 463, in _poll\r\n    self._response)\r\n  File \"D:\\VSProjects\\msrestazure-for-python\\msrestazure\\azure_operation.py\", line 292, in get_status_from_resource\r\n    self.resource = self._deserialize(response)\r\n  File \"D:\\VSProjects\\msrestazure-for-python\\msrestazure\\azure_operation.py\", line 177, in _deserialize\r\n    resource = self.get_outputs(response)\r\n  File \"d:\\vsprojects\\azure-sdk-for-python\\azure-mgmt-machinelearning\\azure\\mgmt\\machinelearning\\webservices\\operations\\web_services_operations.py\", line 117, in get_long_running_output\r\n    deserialized = self._deserialize('WebService', response)\r\n  File \"D:\\VSProjects\\msrest-for-python\\msrest\\serialization.py\", line 762, in __call__\r\n    value = self.deserialize_data(raw_value, attr_type)\r\n  File \"D:\\VSProjects\\msrest-for-python\\msrest\\serialization.py\", line 888, in deserialize_data\r\n    return self(obj_type, data)\r\n  File \"D:\\VSProjects\\msrest-for-python\\msrest\\serialization.py\", line 768, in __call__\r\n    return self._instantiate_model(response, d_attrs)\r\n  File \"D:\\VSProjects\\msrest-for-python\\msrest\\serialization.py\", line 844, in _instantiate_model\r\n    raise DeserializationError(msg + str(err))\r\nmsrest.exceptions.DeserializationError: Unable to deserialize {'realtime_configuration': <azure.mgmt.machinelearning.webservices.models.realtime_configuration.RealtimeConfiguration object at 0x04B14590>, 'description': None, 'output': <azure.mgmt.machinelearning.webservices.models.service_input_output_specification.ServiceInputOutputSpecification object at 0x04B14530>, 'storage_account': <azure.mgmt.machinelearning.webservices.models.storage_account.StorageAccount object at 0x04B14550>, 'read_only': False, 'diagnostics': <azure.mgmt.machinelearning.webservices.models.diagnostics_configuration.DiagnosticsConfiguration object at 0x04B145B0>, 'parameters': {'trigonometric Function': 'Sin', 'output mode': 'ResultOnly', 'category': 'Trigonometric', 'column Set': '{\"isFilter\":true,\"rules\":[{\"ruleType\":\"ColumnTypes\",\"exclude\":false,\"columnTypes\":[\"Numeric\"],\"columnKinds\":[\"All\"]}]}'}, 'commitment_plan': None, 'machine_learning_workspace': None, 'assets': {'asset1': <azure.mgmt.machinelearning.webservices.models.asset_item.AssetItem object at 0x04B14630>}, 'keys': None, 'expose_sample_data': True, 'input': <azure.mgmt.machinelearning.webservices.models.service_input_output_specification.ServiceInputOutputSpecification object at 0x04B14610>, 'title': None, 'example_request': <azure.mgmt.machinelearning.webservices.models.example_request.ExampleRequest object at 0x04B145F0>, 'package_type': 'Graph'} into model <class 'azure.mgmt.machinelearning.webservices.models.web_service_properties.WebServiceProperties'>. __init__() got an unexpected keyword argument 'package_type'\r\n```\r\n\r\n[And looking at the code](https://github.com/lmazuel/azure-sdk-for-python/blob/machine_learning_mgmt/azure-mgmt-machinelearning/azure/mgmt/machinelearning/webservices/models/web_service_properties.py), `package_type` is not a parameter of `WebServiceProperties` indeed:\r\n```python\r\nclass WebServiceProperties(Model):\r\n\r\n    _validation = {\r\n        'created_on': {'readonly': True},\r\n        'modified_on': {'readonly': True},\r\n        'provisioning_state': {'readonly': True},\r\n        'swagger_location': {'readonly': True},\r\n        'package_type': {'required': True},\r\n    }\r\n\r\n    _attribute_map = {\r\n...\r\n        'parameters': {'key': 'parameters', 'type': '{str}'},\r\n        'package_type': {'key': 'packageType', 'type': 'str'},\r\n    }\r\n\r\n    _subtype_map = {\r\n        'package_type': {'Graph': 'WebServicePropertiesForGraph'}\r\n    }\r\n\r\n    def __init__(self, title=None, description=None, keys=None, read_only=None, expose_sample_data=None, realtime_configuration=None, diagnostics=None, storage_account=None, machine_learning_workspace=None, commitment_plan=None, input=None, output=None, example_request=None, assets=None, parameters=None):\r\n...\r\n        self.parameters = parameters\r\n        self.package_type = None\r\n```"},"comment":{"url":"https://api.github.com/repos/Azure/autorest/issues/comments/273347419","html_url":"https://github.com/Azure/autorest/issues/1729#issuecomment-273347419","issue_url":"https://api.github.com/repos/Azure/autorest/issues/1729","id":273347419,"user":{"login":"lmazuel","id":1050156,"avatar_url":"https://avatars.githubusercontent.com/u/1050156?v=3","gravatar_id":"","url":"https://api.github.com/users/lmazuel","html_url":"https://github.com/lmazuel","followers_url":"https://api.github.com/users/lmazuel/followers","following_url":"https://api.github.com/users/lmazuel/following{/other_user}","gists_url":"https://api.github.com/users/lmazuel/gists{/gist_id}","starred_url":"https://api.github.com/users/lmazuel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lmazuel/subscriptions","organizations_url":"https://api.github.com/users/lmazuel/orgs","repos_url":"https://api.github.com/users/lmazuel/repos","events_url":"https://api.github.com/users/lmazuel/events{/privacy}","received_events_url":"https://api.github.com/users/lmazuel/received_events","type":"User","site_admin":false},"created_at":"2017-01-18T00:40:30Z","updated_at":"2017-01-18T00:40:30Z","body":"(needs https://github.com/Azure/autorest/pull/1727 to be reproduced)"}}
{"actor":{"display_login":"lmazuel"}}