0.1.2 ⢠Published 7 years ago
schema-script v0.1.2
Features
āļø JSON Schema for defining external interfaces (APIs, database, user input)
š Generate static and runtime TypeScript types
š Generated files look great thanks to prettier, formatted according to your project settings.
Prerequisites
- put your JSON schemas files in the folders where you want the generated types to be placed
- use the following pattern for naming files
<typeName>.schema.json - add a
$commentattribute to your schemas and define whatschema-scriptshould generate:"$comment": "+ts +iots +graphql"
Note: for +iots install io-ts(a TypeScript compatible runtime type system for IO decoding/encoding).
Note: +graphql support is coming.
Getting Started
npm i schema-script -g
schema-script <dir-with-schemas>
ss <dir-with-schemas>schema-script will go over all files matching the pattern <typeName>.schema.json. It will generate TypeScript files next to the schema file as following <TypeName>.ts.
Examples
See ./examples for some examples of generated types.
Get Help
Probably schema-script is not working as expected for all possible JSON schemas. It needs more testing and your feedback: