Yelp / bravado-core

Other
109 stars 98 forks source link

Fix discriminator validation #302

Closed macisamuele closed 5 years ago

macisamuele commented 5 years ago

Fixes #301

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.

coveralls commented 5 years ago

Coverage Status

Coverage decreased (-0.1%) to 98.324% when pulling eed9cb378f62d36a64fd1fe4cd984d160b14af4e on macisamuele:maci-issue-301-fix-discriminator-validation into 68e98ab85dc4a50cf5a9ffe7fb627d0575387704 on Yelp:master.