Closed silverwind closed 3 months ago
A boolean is a valid JSON Schema since draft-06. You can use a boolean anywhere a schema is expected.
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
Found a way:
type JsonSchemaObject = Exclude<JsonSchema, boolean>;
That's a great solution.
Yeah, but it's only a temporary solution of course. I will make my code work with boolean schemas.
Is there a reason why the
JsonSchema
type has aboolean
in its union type? As far as I'm aware, booleans are not valid JSON schemas.https://github.com/hyperjump-io/json-schema/blob/724e2434459ecedb089cd9e8e2b309802cc6b5fe/stable/index.d.ts#L5