This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

schema-script

0.1.2 • Public • Published

schema-script npm

newsletter cli demo

Zero-configuration pre-processor for generating runtime and static TypeScript/GraphQL types based on JSON schemas.

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

/schema-script/

    Package Sidebar

    Install

    npm i schema-script

    Weekly Downloads

    2

    Version

    0.1.2

    License

    MIT

    Unpacked Size

    15.5 kB

    Total Files

    10

    Last publish

    Collaborators

    • orkon