Skip to content

Commit 64c3be0

Browse files
committed
fix: generation enum numbers as strings one
1 parent 39ca291 commit 64c3be0

File tree

5 files changed

+56
-3
lines changed

5 files changed

+56
-3
lines changed

CHANGELOG.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ feat: `--custom-config <string>` option (#503)
66
feat: `--sort-routes` option, ability to sort routes;
77
fix: critical bugs based with extract types and enums
88
fix: sort types option (sort was not correctly work with nested or extracted types)
9-
fix: problems based with extracting enums;
9+
fix: problems based with extracting enums;
1010
fix: nullable enum with integer values (#543)
11-
chore: refactoring the axios imports
11+
fix: generation enum numbers as strings one (#534)
12+
chore: refactoring the axios imports
1213
fix: non-object custom spec extensions (#500)
1314
fix(docs): input instead of output in readme
1415
internal: remove redundant internal scripts
@@ -28,7 +29,7 @@ fix: problem with filtering primitive in complex types (#459)
2829
feat: add discriminator property support (#456)
2930
internal: prepare code + templates for async code execution (next plans)
3031
fix: problems with dot in query params (hard fix) (#460)
31-
feature: ability to send custom Ts output code translator to js. Example:
32+
feature: ability to send custom Ts output code translator to js. Example:
3233
```ts
3334
const { Translator } = require("swagger-typescript-api/src/translators/translator");
3435
const { JavascriptTranslator } = require("swagger-typescript-api/src/translators/javascript");

tests/spec/enums-2.0/expected.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,11 @@ export enum SomeInterestEnum {
9090
ASDds = "ASDds",
9191
HSDFDS = "HSDFDS",
9292
}
93+
94+
export interface PostFooPayload {
95+
someTypeId?: 1 | 2 | 3 | 4 | 5;
96+
}
97+
98+
export interface PostFooParams {
99+
testKek: 1 | 2 | 3 | 4 | 5;
100+
}

tests/spec/enums-2.0/schema.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,5 +80,37 @@
8080
"HSDFDS"
8181
]
8282
}
83+
},
84+
"paths": {
85+
"/foo": {
86+
"post": {
87+
"operationId": "postFoo",
88+
"parameters": [
89+
{
90+
"in": "query",
91+
"name": "testKek",
92+
"required": true,
93+
"type": "integer",
94+
"enum": [1,2,3,4,5]
95+
}
96+
],
97+
"requestBody": {
98+
"content": {
99+
"application/json": {
100+
"schema": {
101+
"type": "object",
102+
"properties": {
103+
"someTypeId": {
104+
"type":"integer",
105+
"enum":[1,2,3,4,5]
106+
}
107+
}
108+
}
109+
}
110+
}
111+
},
112+
"responses": {}
113+
}
114+
}
83115
}
84116
}

tests/spec/enums-2.0/schema.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,11 @@ export enum SomeInterestEnum {
9090
ASDds = "ASDds",
9191
HSDFDS = "HSDFDS",
9292
}
93+
94+
export interface PostFooPayload {
95+
someTypeId?: 1 | 2 | 3 | 4 | 5;
96+
}
97+
98+
export interface PostFooParams {
99+
testKek: 1 | 2 | 3 | 4 | 5;
100+
}

tests/spec/enums-2.0/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ schemas.forEach(({ absolutePath, apiFileName }) => {
1313
name: apiFileName,
1414
input: absolutePath,
1515
output: resolve(__dirname, "./"),
16+
extractRequestParams: true,
17+
extractRequestBody: true,
18+
extractResponseBody: true,
19+
extractResponseError: true,
1620
generateClient: false,
1721
}).then(() => {
1822
validateGeneratedModule(resolve(__dirname, `./${apiFileName}`));

0 commit comments

Comments
 (0)