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

Properly handle oneOfs in schemas #57

Closed
tamasfe opened this issue Nov 7, 2020 · 4 comments · Fixed by #211
Closed

Properly handle oneOfs in schemas #57

tamasfe opened this issue Nov 7, 2020 · 4 comments · Fixed by #211
Labels
enhancement schema JSON-schema related issues

Comments

@tamasfe
Copy link
Owner

tamasfe commented Nov 7, 2020

Currently all oneOfs are merged for autocompletion, instead only the relevant ones should be shown to the user.

@Bludator
Copy link

I think that this not only gives merged autocomplete result but also results in fails in validation:

With this setup

VSCode extension:

Expected the value to be exactly one of "test1" or "test2", but it is valid for "test1" and "test2"

or CLI:

> npx @taplo/cli lint -s test-schema.json test.toml

npx: installed 20 in 5.21s
error: failed schema validation
 --> test.toml:1:1
  | 
1 | testProp = 10
  | ^ expected exactly one schema to match, but 2 schemas matched

failure: processed 1 document with 1 error

@tamasfe
Copy link
Owner Author

tamasfe commented Sep 15, 2021

Yes, schemas probably need an overhaul along with #136 as well.

@Profpatsch
Copy link
Contributor

I would like to use oneOf in our schema as well, but as it stands it looks like the usability of hover-documentation suffers a lot when overlapping oneOf is involved.

@Profpatsch
Copy link
Contributor

For example this trick: https://gist.github.com/Profpatsch/af40fc52f51cc94796e05bf7fed395ed doesn’t lead to helpful error messages when used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement schema JSON-schema related issues
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants