Skip to content

Validate oneOf, anyOf and allOf with discriminator #30

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

Merged
merged 3 commits into from
Jan 27, 2022

Conversation

gberaudo
Copy link
Contributor

@gberaudo gberaudo commented Jan 14, 2022

Related to: #29.

Implement discriminator support.

Todo:

  • implement basic functionnality and some tests;
  • validate approach with @p1c2u;
  • handle both oneOf and anyOf;
  • handle implicit refs / no mapping property.
  • what about allOf?

@gberaudo gberaudo marked this pull request as draft January 14, 2022 17:39
@gberaudo gberaudo force-pushed the support_oneof_discriminator branch from d4bd56e to 8c47c3c Compare January 14, 2022 18:19
@gberaudo
Copy link
Contributor Author

Hi @p1c2u, I implemented a minimal handling of the discriminator when using oneOf schemas.
It works on the added tests and in a real life schema.

Were you already working on that feature?
What do you think of the approach?
Are you interested in a contribution?

@codecov
Copy link

codecov bot commented Jan 24, 2022

Codecov Report

Merging #30 (1543afe) into master (ad54522) will increase coverage by 3.12%.
The diff coverage is 83.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #30      +/-   ##
==========================================
+ Coverage   67.19%   70.31%   +3.12%     
==========================================
  Files           6        6              
  Lines         189      219      +30     
  Branches       40       45       +5     
==========================================
+ Hits          127      154      +27     
- Misses         50       53       +3     
  Partials       12       12              
Impacted Files Coverage Δ
openapi_schema_validator/validators.py 95.45% <ø> (ø)
openapi_schema_validator/_validators.py 62.22% <83.33%> (+13.88%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad54522...1543afe. Read the comment docs.

@p1c2u
Copy link
Collaborator

p1c2u commented Jan 24, 2022

@gberaudo I didn't work on the feature and your approach looks very nice and promising.

- handle implicit refs and missing "mapping";
- test all 3 cases.
@gberaudo gberaudo marked this pull request as ready for review January 25, 2022 11:28
@gberaudo gberaudo changed the title Validate oneOf with discriminator Validate oneOf,anyOf and allOf with discriminator Jan 25, 2022
@gberaudo gberaudo changed the title Validate oneOf,anyOf and allOf with discriminator Validate oneOf, anyOf and allOf with discriminator Jan 25, 2022
@gberaudo
Copy link
Contributor Author

@gberaudo I didn't work on the feature and your approach looks very nice and promising.

Hi @p1c2u, thanks for your encouraging words.

I have continued work on this PR; it now handles implicit references and was extented to support also anyOf and allOf (which are actually identical). I think it handles all cases described in https://swagger.io/specification/#discriminator-object.
I am looking forward for your review.

@p1c2u p1c2u changed the base branch from master to stable/0.2.x January 27, 2022 02:58
@p1c2u p1c2u changed the base branch from stable/0.2.x to master January 27, 2022 02:59
@p1c2u p1c2u merged commit 6e9621c into python-openapi:master Jan 27, 2022
p1c2u added a commit that referenced this pull request Jan 27, 2022
Validate oneOf, anyOf and allOf with discriminator
@gberaudo gberaudo deleted the support_oneof_discriminator branch January 27, 2022 08:24
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.

2 participants