Skip to content

Commit

Permalink
fix: discard invalid default values when field is enum
Browse files Browse the repository at this point in the history
  • Loading branch information
invakid404 committed Nov 27, 2024
1 parent deada10 commit dead43c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/generator/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ export const schemaToZod = (
delete schema.default;
}

// NOTE: Windmill sometimes has invalid default values on enum schemas,
// which causes the generated code to error during compilation
if (
schema.enum != null &&
"default" in schema &&
!schema.enum.includes(schema.default)
) {
delete schema.default;
}

// NOTE: Windmill sometimes has `enum: null` on string fields, and the
// library doesn't like that, so we need to delete it
if (schema.type === "string" && schema.enum == null) {
Expand Down

0 comments on commit dead43c

Please sign in to comment.