https://github.com/koumoul-dev/schema-jtd
JSON Schema and JSON Type Definition transformation utilities (contains the schema2td and td2schema commands)
https://github.com/koumoul-dev/schema-jtd
Last synced: 6 months ago
JSON representation
JSON Schema and JSON Type Definition transformation utilities (contains the schema2td and td2schema commands)
- Host: GitHub
- URL: https://github.com/koumoul-dev/schema-jtd
- Owner: koumoul-dev
- License: mit
- Created: 2023-02-01T07:13:55.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-24T07:51:06.000Z (over 2 years ago)
- Last Synced: 2025-03-16T21:37:47.210Z (7 months ago)
- Language: JavaScript
- Size: 2.56 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# schema-jtd
JSON Schema and JSON Type Definition transformation utilities (contains the schema2td and td2schema commands).## CLI usage
```
npx --package @koumoul/schema-jtd schema2td --help
```## Why
- 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 ?## JTD or JSON Schema ?

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:
1. write an API specification including self documented JSON schemas
2. use `schema2td` to produce JTD equivalents
3. use `jtd-codegen` to produce code bindings
4. use JTD for fast parsing and serializing at both ends of your API endpoints
5. use a JSON Schema validator to validate the payload with extra rules ignored by JTD## Limitations
- `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