CLI tool for various TypeBox and JSON Schema operations
npm install typebox-cliCLI tool for various TypeBox and JSON Schema operations.
``bash`
npm install -g typebox-cli
#### Convert TypeScript types to TypeBox Schema
Input file (i.e. types.ts):`ts`
export type T = "test";
Run TypeBox Codegen:
`bash`
typebox codegen TypeBox --source types.ts
Outputs:
`ts
import { Type, Static } from '@sinclair/typebox'
export type T = Static
export const T = Type.String()
`
#### Convert TypeBox Schema into JSON schema
Input file (i.e. typebox.ts):`ts `
import { Type } from "@sinclair/typebox";
export const T = Type.String();
Run JSON Schema extraction:
`bash `
typebox extract json --module typebox.ts -e T
Outputs:
`json `
{
"$id": "T",
"type": "string"
}
`bash Extract - Extract JSON schema from exported TypeBox variables:
typebox extract json --module
$3
typebox-cli` is based on these packages:- TypeBox - Json Schema Type Builder with Static Type Resolution for TypeScript
- TypeBox Codegen - Code Generation Tools for TypeBox
- jiti - Module Loading
- Commander - CLI Interface