Skip to content
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

[Q] Recommendations for Converting JSON Schema to TS Types in Ajv? #2339

Open
toteto opened this issue Oct 19, 2023 · 1 comment
Open

[Q] Recommendations for Converting JSON Schema to TS Types in Ajv? #2339

toteto opened this issue Oct 19, 2023 · 1 comment
Labels

Comments

@toteto
Copy link

toteto commented Oct 19, 2023

How can I convert my predefined JSON Schema files into TS Types as a developer? I've looked into:

  1. json-schema-to-typescript
    • Pros: Overall good output.
    • Cons:
      • Produces empty interface for patternProperties.
      • Issues with duplicate type outputs and can't see all the schemas to minimize duplicates.
  2. json-schema-to-ts
    • Pros: Good output for simple schemas and fast.
    • Cons: Problem resolving definitions in referenced schemas (issue #172).

I thought Ajv, being a prominent tool for validation, might have tools for this, but I've only found limited support for type inferring with JTD schemas and no support for type generation for JSON Schema. Does the Ajv community recommend any tools for this purpose, or is there an in-built tool in Ajv that I might have missed?

@croconut
Copy link

@sinclair/typebox. Specifically Static. I would also very seriously consider using other features in that lib

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

4 participants
@toteto @epoberezkin @croconut and others