`JsonSchema` `boolean` type
Closed this issue · 5 comments
silverwind commented
Is there a reason why theJsonSchema
type has a boolean
in its union type? As far as I'm aware, booleans are not valid JSON schemas.
Line 5 in 724e243
jdesrosiers commented
A boolean is a valid JSON Schema since draft-06. You can use a boolean anywhere a schema is expected.
silverwind commented
Hmm, this union is presenting a few typescript related issues to me with "type boolean is not assignable to object" and I'm sure my schemas will never be booleans. Would you be willing to accept a PR that exports a subtype for the object? E.g.
export type JsonSchemaObject = {}
export type JsonSchema = boolean | JsonSchemaObject
silverwind commented
Found a way:
type JsonSchemaObject = Exclude<JsonSchema, boolean>;
jdesrosiers commented
That's a great solution.
silverwind commented
Yeah, but it's only a temporary solution of course. I will make my code work with boolean schemas.