Introduction
@apical-ts/craft effortlessly turn your OpenAPI specifications into fully-typed Zod v4 schemas ready for runtime (client or server) validation and TypeScript development.
You may ask: why another Typescript OpenAPI generator? The answer lies in full commitment to strict type safety. With @apical-ts/craft, you get:
- π― Operation-based architecture β Each API operation is a standalone, fully-typed function
- π‘οΈ Runtime validation β Zod v4 ensures robust type safety for requests and responses
- π Multiple content types β Supports JSON, XML, form data, and more
- π OpenAPI compatibility β Works with OpenAPI 2.0, 3.0.x, and 3.1.x specs
- π Minimal dependencies β Generated code is lightweight and easy to integrate
- π§ͺ Self-contained schemas β Zod schemas are generated for independent use
- π No runtime exceptions β Client operations are safe and predictable
- π ββοΈ No accidental undefined access β Strict typings prevent undefined property access
- π¦ Discriminated unions β Polymorphic schemas are handled with precise union types
- π Multiple success responses β Handles multiple success codes (e.g.,
200,201) with payloads - π Wildcard response support β Supports wildcard status codes (e.g.,
2XX,4XX) - π Circular reference support β Handles circular schema references gracefully without overflows
- π Rich error reporting β Debug operations easily with detailed errors
Quick Startβ
Get started with @apical-ts/craft in just a few commands:
# Generate schemas and client from an OpenAPI specification
npx @apical-ts/craft generate \
--server \
--client \
-i https://petstore.swagger.io/v2/swagger.json \
-o generated
# Install runtime dependencies for the generated code
cd generated
npm install
This will create:
server/- Typed handler wrappersclient/- Individual operation functions for each API endpointschemas/- Zod schemas and TypeScript types
The generated client and server code requires zod as a runtime dependency for
schema validation. Make sure to install it in your project.
Project Status & Versioningβ
@apical-ts/craft is under active development. In accordance with the
Semantic Versioning specification, the project will begin
strict semantic versioning starting from version 1.0.0. Until then, breaking
changes may occur in minor releases. To avoid unexpected breaking changes, it is
recommended to pin a specific version when using the CLI or as a dependency.
For example, when using npx:
npx @apical-ts/craft@0.3.1 generate ...
Replace 0.3.1 with the desired version. This ensures consistent behavior even
as the project evolves.
Live Demoβ
Explore the live demo to see @apical-ts/craft in action:
Why another generator?β
We all like the developer experience of tRPC, but not always we're in control of the backend. OpenAPI specifications provide a powerful way to define your API contracts, and with @apical-ts/craft, you can easily generate TypeScript code that strictly adheres to those contracts, all while enjoying a seamless developer experience.
Many existing generators lack flexibility and strong type safety. Most do not support multiple success responses or multiple content types, and their typings are often too looseβmaking it easy to accidentally access undefined properties. With stricter guardrails, @apical-ts/craft helps developers (and Gen-AIs) build more robust and reliable implementations.
Curious why you should choose this generator over others? See our comparison with alternative libraries for more details or check our comprehensive feature list for more information.
Next Stepsβ
- Learn how to use the CLI tool
- Dive into client generation to build type-safe API clients
- Check out our comprehensive feature documentation for a complete overview