Skip to content

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

Open
darkbasic wants to merge 2 commits into
astahmer:mainfrom
darkbasic:feat/enum-deps-circular
Open

Emit type for enum dependencies of circular schemas, not just object dependencies#349
darkbasic wants to merge 2 commits into
astahmer:mainfrom
darkbasic:feat/enum-deps-circular

Conversation

@darkbasic

Copy link
Copy Markdown

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.

@vercel

vercel Bot commented Sep 24, 2025

Copy link
Copy Markdown

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant