See blog:*, train:*, museum:*, and petstore:* scripts in package.json for command line examples. Set up your config file and scripts for your preferred approach (ref, deref). In most cases, you only need two scripts.
to4ft is a commander application, so -h or --help and -V or --version work as you'd expect, including to4ft <command> -h.
Generate TypeBox schemas and types from an OpenAPI spec.
Example: to4ft oas2tb -i examples/openapi/openapi.yaml -o examples/dtb -c configFile
-i (required) -- path to one of the following:
- a file to convert
examples/openapi/schemas/User.yamlgenerates types for items defined incomponentsinUser.yamland in any file$refed inUser.yamlor its$refs (recursive).examples/openapi/openapi.yamlgenerates types for items defined incomponentsin theopenapi.yamland in any file$refed in theopenapi.yamlor its$refs (recursive).
- a directory containing files to convert
examples/openapi/schemasgenerates types defined incomponentsin any file in the directory
-o (required) -- path to receive generated files
-c -- JSON configuration file to use. See config_deref.json and config_ref.json for examples.
Generate partial Fastify RouteOptions objects based on OpenAPI paths.
Example: to4ft oas2ro -i input -o outDir -r refDir -c configFile
-i (required) -- the root file of an OpenAPI spec; to4ft expects to find an OpenAPI Document Object
-o (required) -- directory to receive TypeScript files with RouteOptions
-c -- JSON configuration file to use. See config_deref.json and config_ref.json for examples.
--refDir (required if derefFl: false) -- directory to reference for TypeBox types; to4ft assumes the directory and files it wants exist and exports the TypeBox schemas it wants to import.