openapi-zod-client icon indicating copy to clipboard operation
openapi-zod-client copied to clipboard

Emit type for enum dependencies of circular schemas, not just object dependencies

Open darkbasic opened this issue 6 months ago • 1 comments

Enum dependencies of circular schemas weren't getting proper TypeScript type annotations (z.ZodType<T>), only object dependencies were. This resulted in enums being generated as const Status = z.enum([...]) instead of const Status: z.ZodType<Status> = z.enum([...]).

Root Cause: The template-context.ts logic only set emittedType: true for object dependencies (nodeSchema.type === "object") of circular schemas, but ignored enum dependencies.

Main fix: Extended the circular dependency processing in template-context.ts to also set emittedType: true for enum dependencies (nodeSchema.type === "string" && nodeSchema.enum).

Secondary fix: Fixed dependency detection in getOpenApiDependencyGraph.ts to handle union types like ["array", "null"] that were preventing some enum dependencies from being detected.

darkbasic avatar Sep 24 '25 17:09 darkbasic

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
openapi-zod-client-rim4 Ready Ready Preview Comment Sep 24, 2025 5:11pm

vercel[bot] avatar Sep 24 '25 17:09 vercel[bot]