TypeScript OpenAPI client generator with runtime Zod validation, neverthrow results, and configurable Axios/Fetch adapters.
- Command-line generator:
api-geno generatecreates a typed client from an OpenAPI JSON file. - Axios + Fetch adapters: Choose
axiosorfetchwith the--http-adapteroption. - Optional Zod validation: Runtime schemas are generated by default, and can be disabled with
--no-zod. - Functional error handling: Generated requests return
neverthrowResultvalues instead of raw exceptions. - Config-driven generation: Supports
api-geno.config.jsonalongside CLI flags. - Flexible output structure:
--flat,--split-services, and--emit-only-shapesallow tailored output. - Formatting support:
--formatrunsbiomeor falls back toprettierwhen available. - Smart regeneration: Keeps a hash file to skip generation when inputs/options are unchanged, with
--forceto override. - Auxiliary features:
--reportgenerates coverage reporting,--skip-generated-outputsprints generated files to console, and--watchrebuilds on change.
bun run build
bun run ./dist/cli.js generate \
--input api.json \
--output generated \
--http-adapter fetch \
--format \
--report-i, --input <file>: OpenAPI JSON file-o, --output <dir>: Output directory--http-adapter <adapter>:axiosorfetch(default:axios)--error-style <style>:class,shape, orboth(default:both)--emit-only-shapes: Emit only type shapes--skip-generated-outputs: Print files instead of writing them--force: Force regeneration--output-format <fmt>: Output format (tsonly)--flat: Generate files in a single directory--no-zod: Disable Zod schema generation--split-services/--no-split-services: Control service file splitting--format: Format generated code after generation--report: Emit a schema coverage report-w, --watch: Watch input/config changes and regenerate
Create an api-geno.config.json to reuse common generation options:
{
"input": "api.json",
"output": "generated",
"httpAdapter": "fetch",
"format": true,
"report": true
}| Script | What it does |
|---|---|
bun run build |
Compile the generator |
bun run gen |
Build and generate using api.json |
bun run check |
Type-check only |
bun run lint |
Run Biome lint |
bun run lint:fix |
Autofix lint issues |
bun run format |
Format all files |
bun run format:check |
Check formatting (CI) |
bun run test |
Run tests |
bun run verify |
Lint + typecheck + test + build (full local CI) |
bun run release |
Create a single bundled CLI binary in release/api-geno |
bun install
bun testbun run build
bun run ./dist/cli.js generate -i api.json -o ./generated --forcebun install # also sets up git hooks via lefthook
bun run verify # run full check before pushingPre-commit hooks run lint and check automatically. Pre-push runs the full verify pipeline.
Use changesets for versioning:
bun run changeset # describe your changeNote:
api-genois published as a CLI binary viadist/cli.jsand also supportsapi-genoonce installed globally or linked.