-
-
Notifications
You must be signed in to change notification settings - Fork 872
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
Nullable doesn't work on oneOf fields #2450
Comments
|
I personally think the docs aren't clear at all, and it looks like even within the broader OpenAPI community there was a lot of disagreement about the use of nullable as it relates to json schema. They did however firmly land in the "nullable doesn't override oneOf" camp. It wouldn't be the worst thing to update the ajv docs for oneOf/anyof/allof to mention this very unintuitive interaction pattern |
Thanks for the extra info @theahura and for sharing your thoughts. I'm happy to accept an update to the docs. I can do it myself but if someone else submits the PR I can actually approve and merge it whereas if I submit it myself I can't :D |
Closing as this has been shown to be the expected behaviour, but will explore a change to the docs, by myself or someone else. |
What version of Ajv are you using? Does the issue happen if you use the latest version?
8.11.0, Also reproduces on 8.12.0
Ajv options object
JSON Schema
Schema 1 (doesn't work)
Schema 2 (works)
Sample data
Your code
Runkit: https://runkit.com/embed/f2r6epfwc8h7
Validation result, data AFTER validation, error messages
What results did you expect?
I would expect that since in both schemas the
foo
field is marked as nullable,{foo: null}
should pass validation. However, it only passes validation where an explicitnull
option is included in theoneOf
Are you going to resolve the issue?
I can use the second version of the schema as a workaround for now.
The text was updated successfully, but these errors were encountered: