Emit type for enum dependencies of circular schemas, not just object dependencies #349
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 asconst Status = z.enum([...])
instead ofconst 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 setemittedType: 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.