Azure / msrest-for-python

The runtime library "msrest" for AutoRest generated Python clients.
MIT License
41 stars 64 forks source link

[Do not merge] Fix Deserilization error if payload does not contains Required fields #5

Closed lmazuel closed 7 years ago

lmazuel commented 7 years ago

There is an issue if the payload does not contains a required field. For instance, this payload {"status":"Succeeded"} should not be deserialized successfully in the following model:

class Resource(Model):
    def __init__(location):
        self.location=location

The current code is parsing using dict.get and then give None values to fields not in the payload. This should raise a DeserializationError.

This PR fixes this issue and adds a unit test. However, I still have two unit tests broken, but I don't know exactly why, and if these unit tests are correct. Still opening this PR for review of @annatisch and @brettcannon if you are curious.

lmazuel commented 7 years ago

Fixed an issue in Paging created by the patch. Filled a bug to have Paging tests in msrest as well #6

lmazuel commented 7 years ago

So closing this issue for now, too many Swagger files have RestAPI response that does not fill required parameters. Following closely with Autorest team to have this at least in the linter, and might re-open this issue later.