Skip to content

Repository files navigation

TypeBox CLI

TestPackage Publication

Description

CLI tool for various TypeBox and JSON Schema operations.

Install

npm install -g typebox-cli

Usage

Convert TypeScript types to TypeBox Schema

Input file (i.e. types.ts):

exporttypeT="test";

Run TypeBox Codegen:

typebox codegen TypeBox --source types.ts

Outputs:

import{Type,Static}from'@sinclair/typebox'exporttypeT=Static<typeofT>exportconstT=Type.String()

Convert TypeBox Schema into JSON schema

Input file (i.e. typebox.ts):

import{Type}from"@sinclair/typebox";exportconstT=Type.String();

Run JSON Schema extraction:

typebox extract json --module typebox.ts -e T

Outputs:

{
"$id": "T",
"type": "string"
}

Reference

Commands

# Extract - Extract JSON schema from exported TypeBox variables:
typebox extract json --module <module path># Codegen -- Generate Schema from either TypeScript types (using --source) or TypeBox schema (using --module):
typebox codegen <model-name> --source <source file># Generate from TypeScript Types.
typebox codegen <model-name> --module <module path># Generate from exported TypeBox Schema values.# List available Codegen models:
typebox list
# Misc
typebox --version # Display current typebox version.
typebox --help # Help

Dependencies

typebox-cli is based on these packages:

License

MIT

About

CLI tool for various TypeBox and JSON Schema operations

Resources

Stars

9 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages