The current implementation of bravado_core.swagger20_validator.discriminator_validator assumes that discriminator_attribute is present in instance.
This assumption is valid if we are able to guarantee that required validator operates before discriminator validator.
As we shoudln't making assumptions on keywords validation order we should make sure that the validator is more resilient to this type of issue, we should be removing the assumption.
According to the swagger specs, the discriminator field has to be a required field of the object, so to keep users less "distracted" I'm returning an error message like the one returned by the jsonschema library that highlights the fact that the attribute is missing.
Coverage decreased (-0.1%) to 98.324% when pulling eed9cb378f62d36a64fd1fe4cd984d160b14af4e on macisamuele:maci-issue-301-fix-discriminator-validation into 68e98ab85dc4a50cf5a9ffe7fb627d0575387704 on Yelp:master.
Fixes #301
The current implementation of
bravado_core.swagger20_validator.discriminator_validator
assumes thatdiscriminator_attribute
is present ininstance
. This assumption is valid if we are able to guarantee thatrequired
validator operates beforediscriminator
validator.As we shoudln't making assumptions on keywords validation order we should make sure that the validator is more resilient to this type of issue, we should be removing the assumption.
According to the swagger specs, the discriminator field has to be a required field of the object, so to keep users less "distracted" I'm returning an error message like the one returned by the jsonschema library that highlights the fact that the attribute is missing.