Skip to content

Commit 9cff1c1

Browse files
chore: clean code
1 parent 4ea7857 commit 9cff1c1

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

README-en_US.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,10 @@ $ openapi --help
139139
--requestLibPath <string> custom request lib path, for example: "@/request", "node-fetch" (default: "axios")
140140
--enableLogging <boolean> open the log (default: false)
141141
--priorityRule <string> priority rule, include/exclude/both (default: "include")
142-
--includeTags <<string|RegExp>[]> generate code from include tags
143-
--includePaths <<string|RegExp>[]> generate code from include paths
144-
--excludeTags <<string|RegExp>[]> generate code from exclude tags
145-
--excludePaths <<string|RegExp>[]> generate code from exclude paths
142+
--includeTags <(string|RegExp)[]> generate code from include tags
143+
--includePaths <(string|RegExp)[]> generate code from include paths
144+
--excludeTags <(string|RegExp)[]> generate code from exclude tags
145+
--excludePaths <(string|RegExp)[]> generate code from exclude paths
146146
--requestOptionsType <string> custom request method options parameter type (default: "{ [key:
147147
string]: unknown }")
148148
--requestImportStatement <string> custom request import statement, for example: "const request =
@@ -185,7 +185,7 @@ openapi -i ./spec.json -o ./apis
185185
| isDisplayTypeLabel | no | boolean | false | generate label matching type field |
186186
| isGenJsonSchemas | no | boolean | false | generate JSON Schemas |
187187
| mockFolder | no | string | - | mock file path, for example: './mocks' |
188-
| authorization | | string | - | docs authorization |
188+
| authorization | no | string | - | docs authorization |
189189
| nullable | no | boolean | false | null instead of optional |
190190
| isTranslateToEnglishTag | no | boolean | false | translate chinese tag name to english tag name |
191191
| isOnlyGenTypeScriptType | no | boolean | false | only generate typescript type |

src/generator/serviceGenarator.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ export default class ServiceGenerator {
112112

113113
const priorityRule: PriorityRule =
114114
PriorityRule[config.priorityRule as keyof typeof PriorityRule];
115-
const hookCustomFileNames =
116-
this.config.hook?.customFileNames || getDefaultFileTag;
117115

118116
if (this.config.hook?.afterOpenApiDataInited) {
119117
this.openAPIData =
@@ -127,7 +125,7 @@ export default class ServiceGenerator {
127125
// 这里判断paths
128126
switch (priorityRule) {
129127
case PriorityRule.include: {
130-
// includePaths and includeTags is empty,直接跳过
128+
// includePaths and includeTags is empty, 直接跳过
131129
if (isEmpty(includeTags) && isEmpty(includePaths)) {
132130
this.log('priorityRule include need includeTags or includePaths');
133131
break outerLoop;
@@ -181,14 +179,16 @@ export default class ServiceGenerator {
181179
return;
182180
}
183181

182+
const hookCustomFileNames =
183+
this.config.hook?.customFileNames || getDefaultFileTag;
184184
const tags = hookCustomFileNames(operationObject, pathKey, method);
185185

186186
// 这里判断tags
187187
tags.forEach((tag) => {
188188
const tagLowerCase = tag.toLowerCase();
189189

190190
if (priorityRule === PriorityRule.include) {
191-
// includeTags 为空,不会匹配任何path,故跳过;
191+
// includeTags 为空,不会匹配任何path,故跳过
192192
if (isEmpty(includeTags)) {
193193
this.log('priorityRule include need includeTags or includePaths');
194194
return;
@@ -206,7 +206,7 @@ export default class ServiceGenerator {
206206
}
207207

208208
if (priorityRule === PriorityRule.both) {
209-
// includeTags is empty 没有配置,直接跳过
209+
// includeTags is empty 没有配置, 直接跳过
210210
if (isEmpty(includeTags)) {
211211
this.log('priorityRule both need includeTags or includePaths');
212212
return;

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export type GenerateServiceProps = {
4141
enableLogging?: boolean;
4242
/**
4343
/**
44-
* 优先规则, include(只允许include列表) | exclude(只排除exclude列表) | include(允许include列表,排除exclude列表)
44+
* 优先规则, include(只允许include列表) | exclude(只排除exclude列表) | both(允许include列表,排除exclude列表)
4545
*/
4646
priorityRule?: string;
4747
/**

test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ if(include(includeList)){
6767

6868
Exclude 模式只接收 excludeTags,excludePaths 参数,不接收 includeTags,includePaths 参数
6969

70-
如果 excludeTags 和 excludePaths excludeTags 是对 excludePaths 的筛选结果再进行筛选
70+
如果 excludeTags 和 excludePaths 同时存在,excludeTags 是对 excludePaths 的筛选结果再进行筛选
7171

7272
```
7373
// 不在黑名单则生成

0 commit comments

Comments
 (0)