[PR #4394] Replace z.union with z.enum for cleaner OpenAPI generation #10954

Closed
opened 2026-02-16 18:15:43 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/4394

State: closed
Merged: Yes


Replaces the use of z.union() in Zod schemas where z.enum() will suffice, and also changes z.any().nullable() to z.any() which is implicitly nullable (null is a member of any)

This change is expected to produce no functional changes in the application but to render simpler openapi spec.

The benefit is that by using z.enum(), code generators can produce named enumerations and simpler deserialization code for these types.

Attached is a snippet of the resulting changes to the generated openapi spec.

**Original Pull Request:** https://github.com/anomalyco/opencode/pull/4394 **State:** closed **Merged:** Yes --- Replaces the use of `z.union()` in Zod schemas where `z.enum()` will suffice, and also changes `z.any().nullable()` to `z.any()` which is implicitly nullable (null is a member of any) This change is expected to produce no functional changes in the application but to render simpler openapi spec. The benefit is that by using `z.enum()`, code generators can produce named enumerations and simpler deserialization code for these types. Attached is a snippet of the resulting changes to the generated openapi spec.
yindo added the pull-request label 2026-02-16 18:15:43 -05:00
yindo closed this issue 2026-02-16 18:15:43 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#10954