Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #359: properly validate nullable polymorphic models #367

Merged
merged 3 commits into from
Feb 20, 2020

Conversation

macisamuele
Copy link
Collaborator

The goal of this review is to address the validation issue that affects polymorphic models that are nullable (via x-nullable field).

In order to better highlight the reported issue I've modified the polymorphic_specs to ensure that the operation (endpoint) used for testing does return an object that is not directly the polymorphic model.

The issue was mostly caused by the fact that discriminator validation was not using the usual safe check around nullability and so in case of instance=None entering bravado_core.swagger20_validator.discriminator_validator was not short circuiting and instead trying to extract the discriminator key from instance (which was none) and so leading to TypeError being thrown.

Adding the null-gate address the issue an so resolves #359

@macisamuele macisamuele self-assigned this Feb 8, 2020
@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 98.621% when pulling 0841fe3 on macisamuele:maci-issue-359 into 7c0a3bd on Yelp:master.

@macisamuele macisamuele merged commit f018c79 into Yelp:master Feb 20, 2020
@macisamuele macisamuele deleted the maci-issue-359 branch February 20, 2020 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validation fails for x-nullable objects that happen to have discriminator
3 participants