Skip to content

fix: force required=true for path params (handles z.coerce in Zod 4)#383

Open
atl3tico wants to merge 1 commit intoasteasolutions:masterfrom
atl3tico:fix/coerce-path-param-required
Open

fix: force required=true for path params (handles z.coerce in Zod 4)#383
atl3tico wants to merge 1 commit intoasteasolutions:masterfrom
atl3tico:fix/coerce-path-param-required

Conversation

@atl3tico
Copy link
Copy Markdown

@atl3tico atl3tico commented May 7, 2026

Closes #360 — path params incorrectly getting required: false when using z.coerce.*() in Zod 4.

Root cause: Zod 4's z.coerce.number().safeParse(null).success = true, making isNullableSchema() return true, which combined with the nullable check in openapi-generator produces required = false.

Fix: After generateSimpleParameter() for path params, force parameter.required = true.

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.

z.coerce.number().min(0) generates nullable: true while min(1) does not

1 participant