Merge pull request #591 from troglotit/master

Wrap negative numbers in quotes, fix Enums in TypeScript
This commit is contained in:
Ferdi Koomen 2021-03-12 22:46:42 +01:00 committed by GitHub
commit 54c779552f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 8 deletions

View File

@ -11,7 +11,7 @@ export function getEnum(values?: (string | number)[]): Enum[] {
.map(value => {
if (typeof value === 'number') {
return {
name: `_${value}`,
name: `'_${value}'`,
value: String(value),
type: 'number',
description: null,

View File

@ -11,7 +11,7 @@ export function getEnum(values?: (string | number)[]): Enum[] {
.map(value => {
if (typeof value === 'number') {
return {
name: `_${value}`,
name: `'_${value}'`,
value: String(value),
type: 'number',
description: null,

View File

@ -590,9 +590,10 @@ exports[`v2 should generate: ./test/generated/v2/models/EnumWithNumbers.ts 1`] =
* This is a simple enum with numbers
*/
export enum EnumWithNumbers {
_1 = 1,
_2 = 2,
_3 = 3,
'_-1' = -1,
'_1' = 1,
'_2' = 2,
'_3' = 3,
}"
`;
@ -3033,9 +3034,10 @@ exports[`v3 should generate: ./test/generated/v3/models/EnumWithNumbers.ts 1`] =
* This is a simple enum with numbers
*/
export enum EnumWithNumbers {
_1 = 1,
_2 = 2,
_3 = 3,
'_-1' = -1,
'_1' = 1,
'_2' = 2,
'_3' = 3,
}"
`;

View File

@ -800,6 +800,7 @@
"EnumWithNumbers": {
"description": "This is a simple enum with numbers",
"enum": [
-1,
1,
2,
3

View File

@ -1299,6 +1299,7 @@
"EnumWithNumbers": {
"description": "This is a simple enum with numbers",
"enum": [
-1,
1,
2,
3