Skip to content

Commit 6822ae9

Browse files
perf: perf empty tags behavior, related bug #300
1 parent 6559ae7 commit 6822ae9

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

.changeset/five-sloths-sell.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'openapi-ts-request': patch
3+
---
4+
5+
perf: perf empty tags behavior, related bug #300

src/generator/util.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,19 @@ export function getDefaultFileTag(
293293
operationObject: OperationObject,
294294
apiPath: string
295295
): string[] {
296-
return operationObject['x-swagger-router-controller']
297-
? [operationObject['x-swagger-router-controller'] as string]
298-
: operationObject.tags || [operationObject.operationId] || [
299-
apiPath.replace('/', '').split('/')[1],
300-
];
296+
let lastTags: string[] = [];
297+
298+
if (operationObject['x-swagger-router-controller']) {
299+
lastTags = [operationObject['x-swagger-router-controller'] as string];
300+
} else if (!isEmpty(operationObject.tags)) {
301+
lastTags = operationObject.tags;
302+
} else if (operationObject.operationId) {
303+
lastTags = [operationObject.operationId];
304+
} else {
305+
lastTags = [apiPath.replace('/', '').split('/')[1]];
306+
}
307+
308+
return lastTags;
301309
}
302310

303311
function findDuplicateTypeNames(arr: string[]) {

0 commit comments

Comments
 (0)