0.1.2 ā€¢ Published 5 years ago

schema-script v0.1.2

Weekly downloads
4
License
MIT
Repository
github
Last release
5 years ago

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 $comment attribute to your schemas and define what schema-script should 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:

Open an issue