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
Support for boolean JSON Schemas #496
Comments
@bcherny I'll try to submit a PR since this one seems to be a little bit stuck. Having said that, I'm afraid after having a look at the source code, I think I've detected a non trivial issue which blocks us from acomplishing this fix. Long story short: the parser always asumes it's parsing a JSONSchema, but not every part of a JSONSchema should be parsed as a JSONSchema but as a JSON literal instead. Parsing enum values is an excellent example of this. I'll submit a proper issue tomorrow, hopefully it's not too hard to be solved (I might have an idea of how to solve it 😃 ) |
As discussed, this is the issue it's currently blocking us: #508 |
The issue blocking us is solved! Since #503 seems not to be updated, I'll be on my way to submit a PR :) |
As #515 is merged, should this issue be closed? 🤔 |
Context:
Boolean JSON schemas are
true
andfalse
:true
passes the validation of any input.false
fails the validation of any input.Consider the specs as references:
How do we apply this in the library:
I would suggest the following changes:
true
JSON Schema is transpiled to a type, the transpiled type should beany
orunknown
(depending on the config).false
JSON Schema is transpiled to a type, the transpiled type should benever
Examples:
should be transpiled to something like:
I know,
number: never
feels ugly, butnever
is probably the type which works nicely not only in this simple example but also in more complex ones.Current behavior:
Boolean JSON schemas are transpiled into their boolean types:
is transpiled into:
instead of
The text was updated successfully, but these errors were encountered: