Kizuna.model
Give a Zod schema a name so the OpenAPI document and every generated client produce named types instead of inline definitions.
Give a Zod schema a name, so the OpenAPI document and every generated client emit a named type for it.
Parameters
| Option | Type | Required | Description |
|---|---|---|---|
title | string | Yes | The name used in generated output (User, Event, etc.) |
description | string | No | Description included in the OpenAPI spec |
schema | ZodType | Yes | The Zod schema defining the shape and validation |
Returns
The Zod schema with metadata attached, usable anywhere a Zod schema is.
Example
Effect on generators
With Kizuna.model:
- OpenAPI: the schema is extracted into
components.schemas.Userand every usage becomes a$refreference - TypeScript: the schema becomes
export type Userin theAPInamespace, and every route that uses it references the name - Swift: an object becomes
public struct User, az.enumbecomespublic enum EventKind, and az.discriminatedUnionbecomes an enum with one case per branch, shared across all routes that reference it - Kotlin: an object becomes
@Serializable data class User, az.enumbecomesenum class EventKind, and az.discriminatedUnionbecomes a sealed class, shared across all routes that reference it
Extracting TypeScript types
Export a type alongside the schema with z.infer:
See the Routes guide for more details.