JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 122
  • Score
    100M100P100Q81612F

Generate JSON schema from your Typescript sources

Package Exports

  • typescript-to-json-schema
  • typescript-to-json-schema/dist
  • typescript-to-json-schema/dist/factory/formatter
  • typescript-to-json-schema/dist/factory/parser

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (typescript-to-json-schema) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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:
    • JSDoc annotations (planned)
    • command line options (planned)
    • Array<Type> notation (planned)
    • T & U type intersection (planned)
    • class types (not planned)
    • typeof types (not planned)
  • 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 typescript-to-json-schema
./node_modules/.bin/typescript-to-json-schema \
    --path 'my/project/**.*.ts' \
    --type 'My.Type.Full.Name'

Current state

  • interface types
  • enum types
  • union, tuple, type[] types
  • string, boolean, number types
  • "value", 123, true, false, null literals
  • type aliases
  • generics