Skip to content

Commit

Permalink
fix: error when generating types for select field with no options
Browse files Browse the repository at this point in the history
  • Loading branch information
AlessioGr committed Oct 4, 2024
1 parent 96477cf commit 4eb1bfc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions packages/payload/src/utilities/configToJSONSchema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,13 +270,17 @@ export function fieldsToJSONSchema(
type: withNullableJSONSchemaType('array', isRequired),
items: {
type: 'string',
enum: optionEnums,
},
}
if (optionEnums?.length) {
;(fieldSchema.items as JSONSchema4).enum = optionEnums
}
} else {
fieldSchema = {
type: withNullableJSONSchemaType('string', isRequired),
enum: optionEnums,
}
if (optionEnums?.length) {
fieldSchema.enum = optionEnums
}
}

Expand Down

0 comments on commit 4eb1bfc

Please sign in to comment.