Turn your JSON Schemas into types to be used in various languages.
- Generate types for:
- Golang
- Typescript
- Rust
- Python
- handles cycle detection
- automatically determines references
- includes documentation annotations for easy documentation generation with native language tools.
- minimal dependencies (wip)
- Creates 1 type alias per 1 schema
- Autogenerated deterministic titles where missing
- Autoreferencer (removes duplication)
- Code is synchronous - no IO keeps it lean and fast
- Convert schema to types in browser too!
npm install @json-schema-tools/transpiler
const JsonSchemaTranspiler = require("@json-schema-tools/transpiler").default;
const mySchema = {
"title": "PlowAnimals",
"description": "an array of animals that are good at pulling things",
"type": "array",
"items": {
"oneOf": [
{ "title": "Horse" },
{ "title": "Donkey" },
{ "title": "Elephant" },
]
}
};
const transpiler = new JsonSchemaTranspiler(mySchema);
console.log(transpiler.toTypescript());
console.log(transpiler.toRust());
console.log(transpiler.to("go")); // same thing, different form/interface
console.log(transpiler.to("python")); // works with shorthand of the language aswell (py or python)
How to contribute, build and release are outlined in CONTRIBUTING.md, BUILDING.md and RELEASING.md respectively. Commits in this repository follow the CONVENTIONAL_COMMITS.md specification.