JSON Schema and JSON Type Definition transformation utilities (contains the schema2td and td2schema commands).
npx --package @koumoul/schema-jtd schema2td --help
- need help migrating from one format to another ?
- need to make a tool written for one format work with the other at low cost ?
- need create an Open API documentation from your JTDs ?
- need to create code bindings from your schemas ?
Don't be too fast in chosing one and rejecting the other. JSON schema is good for a self documented API that makes many of its validation rules explicit, JTD is great for non-ambiguous types and generating code bindings.
A possible sequence that includes both:
- write an API specification including self documented JSON schemas
- use
schema2td
to produce JTD equivalents - use
jtd-codegen
to produce code bindings - use JTD for fast parsing and serializing at both ends of your API endpoints
- use a JSON Schema validator to validate the payload with extra rules ignored by JTD
schema2td
will reject schemas with ambiguous typing (for example a oneOf with different types)- this might be resolved in the future using a vocabulary to resolve ambiguous typing (for example by flagging a oneOf to be ignored)
td2schema
will be missing some semantics- this is partially compoensated by mapping some JTD metadata to JSON Schema attributes