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

Stop traversing oneOf and anyOf combiners when filling/removing defaults #811

Merged
merged 2 commits into from
Jun 16, 2020

Conversation

eslavich
Copy link
Contributor

This PR completely disables filling/remove defaults from subschemas within oneOf or anyOf combiners. #809 demonstrates a serious bug in the defaults code that prevents use of oneOf in most realistic cases. Given that there isn't a clear correct answer when choosing a default from among multiple oneOf subschemas, I'm inclined to ignore them when processing defaults.

I also propose that we do away with defaults for anyOf. The way anyOf currently behaves is to always add a default from the first subschema. If the object actually matches one of the subsequent subschemas, then we'll be adding a default from the wrong type!

With these changes, the remaining default rules are as follows, for a given missing property:

  • If an object's own property definition has a default, use that
  • Otherwise, if there is an allOf combiner, use the first default value available for that property among the combiner's subschemas. The first listed subschema in the allOf array has highest precedence.
  • Defaults from any other combiners are ignored

Milestoning this as 2.7.0, since it doesn't seem possible that anyone could be successfully using defaults with these combiners given the bugs.

Resolves #809

@eslavich eslavich added the bug label Jun 15, 2020
@eslavich eslavich added this to the 2.7.0 milestone Jun 15, 2020
Copy link
Contributor

@perrygreenfield perrygreenfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@eslavich eslavich merged commit 859cad8 into asdf-format:master Jun 16, 2020
@eslavich eslavich deleted the eslavich-fix-one-of-combiner branch June 16, 2020 11:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

usage of oneOf for schema validation
4 participants