Skip to content

Commit 7f8e581

Browse files
fix: minor changes in zod handler
1 parent 3b53df4 commit 7f8e581

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/vendors/zod.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,19 +11,15 @@ export default async function getToJsonSchemaFn(): Promise<ToJsonSchemaFn> {
1111
// https://zod.dev/library-authors?id=how-to-support-zod-and-zod-mini-simultaneously#how-to-support-zod-3-and-zod-4-simultaneously
1212
if ("_zod" in (schema as $ZodType | ZodTypeAny)) {
1313
try {
14-
handler = await import("zod/v4/core")
15-
.catch(() => {
16-
throw zodv4Error;
17-
})
18-
.then((mod) => mod.toJSONSchema as ToJsonSchemaFn);
14+
const mod = await import("zod/v4/core")
15+
handler = mod.toJSONSchema as ToJsonSchemaFn;
1916
} catch {
2017
throw zodv4Error;
2118
}
2219
} else {
2320
try {
24-
handler = await import("zod-to-json-schema").then(
25-
(mod) => mod.zodToJsonSchema as ToJsonSchemaFn,
26-
);
21+
const mod = await import("zod-to-json-schema")
22+
handler = mod.zodToJsonSchema as ToJsonSchemaFn;
2723
} catch {
2824
throw new MissingDependencyError("zod-to-json-schema");
2925
}

0 commit comments

Comments
 (0)