jsonschema-to-interface

1.0.5 • Public • Published

jsonschema-logo-v1

NPM version NPM downloads built with typescript-lib-starter

JSONSchema to TypeScript Interface

This is a proof of concept. This is just a convenient cli to add to your package.json and watch for changes on JSONSchemas.

Usage as project dependency

Install

npm i -D jsonschema-to-interface

Add scripts to your package.json

"generate-interfaces": "generate-interfaces \"./src/**/schema.json\"",
"generate-interfaces:watch": "generate-interfaces -w \"./src/**/schema.json\""

Call generate-interfaces:watch in parallel with your dev server.

Usage as global CLI

Install

npm i -g jsonschema-to-interface

Call it from the terminal

generate-interfaces './src/**/schema.json'

or run it in watch mode:

generate-interfaces -w './src/**/schema.json'

Note on code style

If there is a .prettierrc.json in che current working dir, it will be used to style the output interface.

Options

  • -w './glob/path/**/schema.json': wathces a glob for changes
  • -o filename: set output file name. Defaults to schema "title" property or, if the "title" is missing, the input filename.

Dependencies

License

MIT

/jsonschema-to-interface/

    Package Sidebar

    Install

    npm i jsonschema-to-interface

    Weekly Downloads

    3

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    6.02 kB

    Total Files

    4

    Last publish

    Collaborators

    • fox1t