New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

teason

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

teason

Generates JSON schema and JSON data from typescript definitions

latest
Source
npmnpm
Version
0.0.6
Version published
Weekly downloads
9
-10%
Maintainers
1
Weekly downloads
 
Created
Source

teason - it's teason then

teason is a cli that takes TypeScript definitions and generates both JSON schema and JSON mock data.

Some might call it a TSON generator

Examples

Take a look at the examples to understand what teason does

Examples can be found in the /examples directory

How to use

npm i teason

After installing you will be able to run the command npx teason --help

cli options

Teason requires two things to run

  • Folder path where the TypeScript definitions can be found
  • The interface name to use

Not defining output-paths will result in no output (a dry-run)

Changing validation-keywords will remove the default value (faker)

Options:
  -t, --types-folder <folder>                       folder path with typescript types
  -i, --interface-name <name>                       main interface to begin with
  -j, --json-output-path <file_path>                output file to store the generated JSON
  -s, --schema-output-path <file_path>              output file to store the generated Schema
  -v, --validation-keywords <comma separated list>  keywords of extra annotation to accept ex: "title,test,data"  (default: ["faker"])
  -h, --help                                        output usage information

config options

You can also store your config in a .teasonrc file

{
  "typesFolder": "types",
  "interfaceName": "Database",
  "jsonOutputPath": "out.json",
  "schemaOutputPath": "out.schema.json",
  "validationKeywords": ["faker"]
}

Schema

The schema output can be used to validate or create new JSON data.

validation with ajv and/or creating with json-editor github

Mock data

Mock data that conforms to your schema. Can be extended with @faker annotations to create more realistic data

Uses typescript-json-schema, json-schema-faker and faker.js under the hood.

json-server

The output from teason is not optimized for json-server, but it can be done quite easily.

The quickest way is to use normalizr and define a normalizr.schema (not to be confused with a json schema).

/examples/post-process.ts contains what you need. In most cases you will only have to change the result of getDbSchema() to get the script working for you

Keywords

typescript

FAQs

Package last updated on 24 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts