Skip to content

Commit

Permalink
Add support for numeric choice
Browse files Browse the repository at this point in the history
  • Loading branch information
ChappIO committed Oct 25, 2023
1 parent 9aa90db commit 40c9d3b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,10 @@ async function generateModel(collection: Collection, schema: SchemaOverview, ser
if (fieldItem?.options?.choices?.length) {
// this is an enum with fixed choices!
type = fieldItem?.options?.choices
?.map(choice => `'${choice.value.replaceAll('\'', '\\\'')}'`)
?.map(choice => typeof choice.value === 'string' ?
`'${choice.value.replaceAll('\'', '\\\'')}'`
: choice.value
)
?.join(' | ');

// add array type in case of multi-selection
Expand Down

0 comments on commit 40c9d3b

Please sign in to comment.