ts-json-schema-generator
ts-json-schema-generator copied to clipboard
feat: cli overhaul with oclif
This PR adds a new cli under the name of tjsg. I kept the previous ts-json-schema-generator intact to keep compatibility with older versions and avoid another breaking release.
Also updated readme and set up oclif to automatically update some readme sections to keep up with cli changes.
New --flags were added and some unused ones were removed.
Some outputs:
$ tjsg --help
Generate JSON schema from your Typescript sources
VERSION
ts-json-schema-generator/2.0.0 wsl-x64 node-v20.13.1
USAGE
$ tjsg [COMMAND]
COMMANDS
autocomplete Display autocomplete installation instructions.
generate Generate JSON schema from your Typescript sources
help Display help for tjsg.
$ tjsg generate --help
Generate JSON schema from your Typescript sources
USAGE
$ tjsg generate [PATH] [-t <value>] [--top-ref] [-i <value>] [-p <value>] [-e all|none|export] [-j
none|basic|extended] [--markdown-description] [--sort-props] [--strict-tuples] [--type-check] [--ref-encode]
[--additional-properties] [--functions fail|comment|hide] [--minify] [-o <value>] [--extra-tags <value>]
[--discriminator-type json-schema|open-api]
ARGUMENTS
PATH Source file path
FLAGS
-e, --expose=<option> [default: export] Type exposing
<options: all|none|export>
-i, --id=<value> $id for generated schema
-j, --jsdoc=<option> [default: extended] Read JsDoc annotations
<options: none|basic|extended>
-o, --out=<value> Set the output file (default: stdout)
-p, --tsconfig=<value> Your tsconfig.json to load entry files and compilation settings
-t, --type=<value> Type name
--additional-properties Allow additional properties for objects with no index signature
--discriminator-type=<option> [default: json-schema] Type of discriminator to use
<options: json-schema|open-api>
--extra-tags=<value>... [default: ] Provide additional validation keywords to include
--functions=<option> [default: comment] How to handle functions. `fail` will throw an error. `comment` will
add a comment. `hide` will treat the function like a NeverType or HiddenType.
<options: fail|comment|hide>
--markdown-description Generate `markdownDescription` in addition to `description`. Implies --jsdoc=extended
--minify Minify generated schema
--[no-]ref-encode Encode references
--[no-]sort-props Makes the schema stable by sorting properties
--strict-tuples Do not allow additional items on tuples
--[no-]top-ref Create a top-level $ref definition
--[no-]type-check Type checks to improve performance
DESCRIPTION
Generate JSON schema from your Typescript sources
EXAMPLES
Analyzes src/types.ts using tsconfig.json and writes the schema to schema.json.
$ tjsg generate -f tsconfig.json -o schema.json src/types.ts
📦 Published PR as canary version: 2.2.1--canary.1966.fab4d27.0
:sparkles: Test out this PR locally via:
npm install [email protected]
# or
yarn add [email protected]