fix(scripts): avoid 'undefined Options: ...' for enums without description (#2963)

schema.description is only assigned when setting.description is truthy.
For enum settings missing a description, the subsequent += produced the
literal string 'undefined Options: foo, bar' in the generated JSON
schema. Initialize the field when absent instead of concatenating onto
undefined.
This commit is contained in:
chinesepowered 2026-04-17 18:19:23 -07:00 committed by GitHub
parent fc75913e50
commit db4b76576a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -121,8 +121,11 @@ function convertSettingToJsonSchema(
case 'enum':
if (setting.options && setting.options.length > 0) {
schema.enum = setting.options.map((o) => o.value);
schema.description +=
' Options: ' + setting.options.map((o) => `${o.value}`).join(', ');
const optionsText =
'Options: ' + setting.options.map((o) => `${o.value}`).join(', ');
schema.description = schema.description
? `${schema.description} ${optionsText}`
: optionsText;
} else {
// Enum without predefined options - accept any string
schema.type = 'string';