sramam / ts-json-schema-generator

Generate JSON schema from your Typescript sources

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ts-json-schema-generator

Build Status npm dependencies npm version

Extended version of https://github.com/xiag-ag/typescript-to-json-schema.

Inspired by YousefED/typescript-json-schema. Here's the differences list:

  • this implementation does not use typeChecker.getTypeAtLocation() (so probably it keeps correct type aliases)
  • the following features are not supported yet:
    • class types
  • processing AST and formatting JSON schema have been split into two independent steps
  • not exported types, interfaces, enums are not exposed in the definitions section in the JSON schema

Usage

npm install --save ts-json-schema-generator
./node_modules/.bin/ts-json-schema-generator \
    --path 'my/project/**.*.ts' \
    --type 'My.Type.Full.Name' \
    --expose 'export' \
    --topRef 'yes' \
    --jsDoc 'extended'

Current state

  • interface types
  • enum types
  • union, tuple, type[] types
  • string, boolean, number types
  • "value", 123, true, false, null literals
  • type aliases
  • generics
  • typeof
  • @nullable annotations
  • @hide annotations for enum values and object properties

Debug

npm run debug -- test/programs/type-alias-single/main.ts --aliasRefs true MyString

And connect via the debugger protocol.

About

Generate JSON schema from your Typescript sources


Languages

Language:TypeScript 100.0%Language:JavaScript 0.0%