Make sure enum values always contain the default value

pull/30/head
Piero Toffanin 2018-01-23 09:58:44 -05:00
rodzic 29f41e4874
commit ac26c16ca6
1 zmienionych plików z 11 dodań i 7 usunięć

Wyświetl plik

@ -95,17 +95,21 @@ module.exports = {
}
}
if (Array.isArray(values.choices)){
type = "enum";
domain = values.choices;
}
help = help.replace(/\%\(default\)s/g, value);
// In the end, all values must be converted back
// to strings (per OpenAPI spec which doesn't allow mixed types)
value = String(value);
if (Array.isArray(values.choices)){
type = "enum";
domain = values.choices;
// Make sure that the default value
// is in the list of choices
if (domain.indexOf(value) === -1) domain.unshift(value);
}
help = help.replace(/\%\(default\)s/g, value);
odmOptions.push({
name, type, value, domain, help
});