Skip to content

A CLI to export zod schemas to json schemas, and then pipe the result to other commands.

License

Notifications You must be signed in to change notification settings

wosherco/zod-exporter

Repository files navigation

Zod Exporter

Export zod types from a zod schema, and convert them to json schemas from the CLI. From there, you can use other projects, like quicktype, to convert to other languages.

Usage

You don't need to install this package, just run the following command:

On npm:

(npx | pnpx | bunx) zod-exporter -i <path-to-schema>

Help command:

Options:
  -V, --version            output the version number
  -i, --input <path>       input of the file containing the TRPC router
  -o, --output <path>      output of the TRPC routes json. If empty will print to stdout (useful to pipe to other commands)
  -s, --schema [name]      name of the exported schema variable. Leave empty for default export (default: "default")
  -w, --watch [directory]  watch for changes on a directory and updates the output. Leave empty to watch the input file
  -x, --exec <command>     command to execute after each successful output
  -h, --help               display help for command

Example with quicktype

bunx zod-exporter -i ./test/schema.ts -w -x "bunx quicktype --src-lang schema --out test.py"

About

A CLI to export zod schemas to json schemas, and then pipe the result to other commands.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published