Skip to content

Commit 3da8faf

Browse files
authored
Merge pull request #371 from eamd-wq/main
fix: 修复配置includePaths时,没有按照includePaths进行type过滤,而是生成了全量的type
1 parent a4339e9 commit 3da8faf

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

.changeset/ready-pans-tickle.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+
fix: 修复配置includePaths时,没有按照includePaths进行type过滤,而是生成了全量的type

src/generator/serviceGenarator.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,7 @@ export default class ServiceGenerator {
445445
const schemas = this.openAPIData.components?.schemas;
446446
const lastTypes: Array<ITypeItem> = this.interfaceTPConfigs;
447447
const includeTags = this.config?.includeTags || [];
448+
const includePaths = this.config?.includePaths || [];
448449

449450
// 强行替换掉请求参数params的类型,生成方法对应的 xxxxParams 类型
450451
keys(this.openAPIData.paths).forEach((pathKey) => {
@@ -461,7 +462,11 @@ export default class ServiceGenerator {
461462

462463
const tags = hookCustomFileNames(operationObject, pathKey, method);
463464

464-
if (isEmpty(includeTags) || (!isEmpty(includeTags) && isEmpty(tags))) {
465+
if (
466+
isEmpty(includeTags) ||
467+
(!isEmpty(includeTags) && isEmpty(tags)) ||
468+
isEmpty(includePaths)
469+
) {
465470
return;
466471
}
467472

@@ -475,7 +480,9 @@ export default class ServiceGenerator {
475480
includeTags
476481
);
477482

478-
if (!flag) {
483+
const pathFlag = this.validateRegexp(pathKey, includePaths);
484+
485+
if (!flag || !pathFlag) {
479486
return;
480487
}
481488

0 commit comments

Comments
 (0)