mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
Merge pull request #591 from troglotit/master
Wrap negative numbers in quotes, fix Enums in TypeScript
This commit is contained in:
commit
54c779552f
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
}"
|
||||
`;
|
||||
|
||||
|
||||
@ -800,6 +800,7 @@
|
||||
"EnumWithNumbers": {
|
||||
"description": "This is a simple enum with numbers",
|
||||
"enum": [
|
||||
-1,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
|
||||
@ -1299,6 +1299,7 @@
|
||||
"EnumWithNumbers": {
|
||||
"description": "This is a simple enum with numbers",
|
||||
"enum": [
|
||||
-1,
|
||||
1,
|
||||
2,
|
||||
3
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user