Open bmc-msft opened 4 years ago
We don't do hard checking of enum nowadays, since RestAPI tends to had values and not checking is making SDK more resistent. For isntance, autorest (our main code generator) generates serialization type as string nowadays (not enum). We don't validate anymore nor on serialization or deserialization.
Please readdress this. 'validate()' should actually validate the data.
The validation should be enough to know that it's invalid, not generating an error on serialization.
from enum import Enum
from msrest.serialization import Model
class A(Enum):
b = "b"
class C(Model):
_attribute_map = {"a": {"key": "a", "type": "A"}}
x = C(a='d')
x.validate()
x.serialize()
That code generates the error:
msrest.exceptions.SerializationError: 'd' is not valid value for enum <enum 'A'>
Example:
I would expect validation of the above to fail.
Note, the value is checked when serialized.
Note, if you deserialize an invalid value, something is logged, but there is no way to check it without reserialization.
I would expect this error to be checkable from validation, not just as a warning during deserialization.