-
Notifications
You must be signed in to change notification settings - Fork 108
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
Rethink JSON Schema generation #2722
Comments
See-also: web-platform-dx#2722
Currently, the alternatives field is described to be an array. But the type of item is missing. This change adds the type as string for each alternative. See-also: #2722 Co-authored-by: Daniel D. Beck <daniel@ddbeck.com>
If you're open to it, I would vote for this approach. I will also suggest another tool named quicktype. It supports multiple languages (including typescript). If you want to try it out, you could paste the JSON schema into their online tool and change the source type to JSON Schema and change the language to typescript. (They also have Typescript Zod too) webstatus.dev uses it on the data.schema.json here to generate the Go types. A few things to note:
As a result, webstatus.dev keeps a slightly modified version of the schema in the tree [1]. After making that modification, it works great! |
Thank you for the quicktype recommendation, @jcscottiii! I much prefer the idea of using a tool that someone has first hand experience with. |
And #1981 (comment) covers making the types consistent for arrays of strings. It is planned for the next major release. |
ts-json-schema-generator
only incompletely generates a schema based on our TypeScript types. It seems to have some longstanding bugs aroundkeyof
. I doubt they'll be fixed any time soon.We should explore alternatives for keeping our TypeScript types and JSON Schema in sync.
Some routes we might consider:
zod
and use zod-to-json-schema)json-schema-to-typescript
)The text was updated successfully, but these errors were encountered: