Wrap negative numbers in quotes, fix enums

This commit is contained in:
Aleksandr Argunov 2021-02-26 16:15:07 +03:00
parent 224e8b0a25
commit 9b9e7cd855
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

@ -587,9 +587,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,
}"
`;
@ -3016,9 +3017,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

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

View File

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