You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Generate zod models using the provided config. Here's an example zod model:
import type { ExperimentContinuousInput } from "../models/ExperimentContinuousInput.ts";
import { z } from "zod";
export const experimentContinuousInputSchema = z.object({
created_at: z
.string()
.describe("ISO 8601 formatted date and time the data was created"),
deleted_at: z.union([z.string(), z.null()]),
id: z.number().int().describe("Unique ID"),
updated_at: z
.string()
.describe("ISO 8601 formatted date and time the data was last updated"),
value: z
.string()
.describe("Integer or decimal value represented as a string"),
continuous_input_id: z
.number()
.int()
.describe("Associated continuous input ID"),
experiment_id: z.number().int().describe("Associated experiment ID"),
project_id: z.number().int().describe("Associated project ID"),
step_id: z.number().int().describe("Associated step ID"),
}) as z.ZodType<ExperimentContinuousInput>;
Note the as z.ZodType<SomeModel>.
Try to access a method that definitely exists, such as pick. Observe a typescript error.
When using typed, we add as z.ZodType<TYPE>. This will work fine for most Zod schemas but not every schema. I saw this discussion in the Zod repo: colinhacks/zod#372 (comment).
@colinhacks made a library called toZod that could be used in Kubb to bind the types and schemas. I will add this in the next version of Kubb.
What version of
kubb
is running?3.0.12
What kind of platform do you use?
Linux
How does your
kubb.config.ts
config look likeSwagger/OpenAPI file?
What version of external packages are you using(
@tanstack-query
,MSW
,React
,Vue
, ...)What steps can reproduce the bug?
Note the
as z.ZodType<SomeModel>
.pick
. Observe a typescript error.I suppose this could be an upstream issue with zod as well. Or, I'm misusing one of the libraries.
How often does this bug happen?
Every time
What is the expected behavior?
I would expect the type coercion to carry over all expected methods and properties of a zod schema.
Additional information
No response
The text was updated successfully, but these errors were encountered: