Skip to content

Commit 88740b6

Browse files
committed
Fix number enum names
1 parent 4a92b34 commit 88740b6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/swaggerToTS.js

+8-3
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,14 @@ const buildTypes = (spec, options) => {
4949
const buildNextEnum = ([ID, options]) => {
5050
output.push(`enum ${ID} {`);
5151
options.forEach(option => {
52-
const name =
53-
typeof option === 'string' ? capitalize(camelCase(option)) : option;
54-
output.push(`${name} = ${JSON.stringify(option)},`);
52+
if (typeof option === 'number') {
53+
const lastWord = ID.search(/[A-Z](?=[^A-Z]*$)/);
54+
const name = ID.substr(lastWord, ID.length);
55+
output.push(`${name}${option} = ${option},`);
56+
} else {
57+
const name = capitalize(camelCase(option));
58+
output.push(`${name} = ${JSON.stringify(option)},`);
59+
}
5560
});
5661
output.push('}');
5762
};

0 commit comments

Comments
 (0)