We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Given this schema:
{ "type": "object", "additionalProperties": false, "properties": { "id": { "type": "string" }, "validFrom": { "type": "string" }, "validTo": { "type": "string" } }, "anyOf": [ { "required": ["id", "validFrom"] }, { "required": ["id", "validTo"] } ], "title": "Assortment" }
This is the type generated:
export type Assortment = Assortment1 & Assortment2; export type Assortment1 = { [k: string]: unknown; }; export interface Assortment2 { id?: string; validFrom?: string; validTo?: string; }
And I was hoping it would generate something like this:
export type Assortment = | { id: string; validFrom: string; validTo?: string; } | { id: string; validFrom?: string; validTo: string; };
I might be doing something wrong, so my apologies in advance.
Thank you so much!
The text was updated successfully, but these errors were encountered:
This technique is called Factoring Schemas in the documentation and should work.
A simpler sample would be
{ "type": "string", "oneOf": [ { "description": "Name of resource.", "pattern": "^d[0-9]+$" }, { "description": "Id (uuid) of resource.", "format": "uuid" } ] }
produces this type:
{ [k: string]: unknown; } & string;
when I’d expect
string | string
or just
string
Sorry, something went wrong.
Any update on this? Or a workaround?
oh good this is an actual issue, I thought I just didn't understand json schema lol +1
No branches or pull requests
Given this schema:
This is the type generated:
And I was hoping it would generate something like this:
I might be doing something wrong, so my apologies in advance.
Thank you so much!
The text was updated successfully, but these errors were encountered: