@@ -107,20 +107,20 @@ export default class ServiceGenerator {
107107 } ;
108108 this . generateInfoLog ( ) ;
109109
110- const allowedPaths = this . config ?. allowedPaths || [ ] ;
111- const allowedTags = this . config ?. allowedTags || [ ] ;
110+ const includePaths = this . config ?. includePaths || [ ] ;
111+ const includeTags = this . config ?. includeTags || [ ] ;
112112 const excludePaths = this . config ?. excludePaths || [ ] ;
113113 const excludeTags = this . config ?. excludeTags || [ ] ;
114114
115115 const priorityRule : PriorityRule =
116116 PriorityRule [ config . priorityRule as keyof typeof PriorityRule ] ;
117117
118118 if (
119- priorityRule === PriorityRule . allowed &&
120- isEmpty ( this . config ?. allowedTags ) &&
121- isEmpty ( this . config ?. allowedPaths )
119+ priorityRule === PriorityRule . include &&
120+ isEmpty ( this . config ?. includeTags ) &&
121+ isEmpty ( this . config ?. includePaths )
122122 ) {
123- this . log ( 'priorityRule allowed need allowedTags or allowedPaths ' ) ;
123+ this . log ( 'priorityRule include need includeTags or includePaths ' ) ;
124124 }
125125 const hookCustomFileNames =
126126 this . config . hook ?. customFileNames || getDefaultFileTag ;
@@ -136,16 +136,16 @@ export default class ServiceGenerator {
136136 for ( const pathKey in this . openAPIData . paths ) {
137137 // 这里判断paths
138138 switch ( priorityRule ) {
139- case PriorityRule . allowed : {
140- // allowedPaths and allowedTags is empty 没有任何allowed配置 ,直接跳过这个数组的所有元素
141- if ( isEmpty ( allowedTags ) && isEmpty ( allowedPaths ) ) {
142- this . log ( 'priorityRule allowed need allowedTags or allowedPaths ' ) ;
139+ case PriorityRule . include : {
140+ // includePaths and includeTags is empty 没有任何include配置 ,直接跳过这个数组的所有元素
141+ if ( isEmpty ( includeTags ) && isEmpty ( includePaths ) ) {
142+ this . log ( 'priorityRule include need includeTags or includePaths ' ) ;
143143 continue ;
144144 }
145145
146146 if (
147- ! isEmpty ( allowedPaths ) &&
148- ! allowedPaths . some ( ( pathRule ) =>
147+ ! isEmpty ( includePaths ) &&
148+ ! includePaths . some ( ( pathRule ) =>
149149 typeof pathRule === 'string'
150150 ? minimatch ( pathKey , pathRule )
151151 : pathRule . test ( pathKey )
@@ -167,16 +167,16 @@ export default class ServiceGenerator {
167167 }
168168 break ;
169169 }
170- case PriorityRule . include : {
171- // allowedPaths is empty 没有配置,直接跳过
172- if ( isEmpty ( allowedTags ) && isEmpty ( allowedPaths ) ) {
173- this . log ( 'priorityRule include need allowedTags or allowedPaths ' ) ;
170+ case PriorityRule . both : {
171+ // includePaths is empty 没有配置,直接跳过
172+ if ( isEmpty ( includeTags ) && isEmpty ( includePaths ) ) {
173+ this . log ( 'priorityRule include need includeTags or includePaths ' ) ;
174174 continue ;
175175 }
176176
177- const inAllowedPaths =
178- ! isEmpty ( allowedPaths ) &&
179- ! allowedPaths . some ( ( path ) =>
177+ const inIncludePaths =
178+ ! isEmpty ( includePaths ) &&
179+ ! includePaths . some ( ( path ) =>
180180 typeof path === 'string'
181181 ? minimatch ( pathKey , path )
182182 : path . test ( pathKey )
@@ -189,14 +189,14 @@ export default class ServiceGenerator {
189189 : path . test ( pathKey )
190190 ) ;
191191
192- if ( inAllowedPaths || inExcludePaths ) {
192+ if ( inIncludePaths || inExcludePaths ) {
193193 continue ;
194194 }
195195 break ;
196196 }
197197 default :
198198 throw new Error (
199- 'priorityRule must be "allowed " or "exclude" or "include"'
199+ 'priorityRule must be "include " or "exclude" or "include"'
200200 ) ;
201201 }
202202
@@ -219,19 +219,19 @@ export default class ServiceGenerator {
219219 tags . forEach ( ( tag ) => {
220220 const tagLowerCase = tag . toLowerCase ( ) ;
221221
222- if ( priorityRule === PriorityRule . allowed ) {
223- // allowedTags 为空, 不会匹配任何path,故跳过; allowedTags 和 allowedPaths 同时为空则没意义,故跳过;
222+ if ( priorityRule === PriorityRule . include ) {
223+ // includeTags 为空, 不会匹配任何path,故跳过; includeTags 和 includePaths 同时为空则没意义,故跳过;
224224 if (
225- isEmpty ( allowedTags ) ||
226- ( isEmpty ( allowedTags ) && isEmpty ( allowedPaths ) )
225+ isEmpty ( includeTags ) ||
226+ ( isEmpty ( includeTags ) && isEmpty ( includePaths ) )
227227 ) {
228- this . log ( 'priorityRule include need allowedTags or allowedPaths ' ) ;
228+ this . log ( 'priorityRule include need includeTags or includePaths ' ) ;
229229 return ;
230230 }
231231
232232 if (
233- ! isEmpty ( allowedTags ) &&
234- ! allowedTags . some ( ( tagRule ) =>
233+ ! isEmpty ( includeTags ) &&
234+ ! includeTags . some ( ( tagRule ) =>
235235 typeof tagRule === 'string'
236236 ? minimatch ( tagLowerCase , tagRule )
237237 : tagRule . test ( tagLowerCase )
@@ -253,16 +253,16 @@ export default class ServiceGenerator {
253253 }
254254 }
255255
256- if ( priorityRule === PriorityRule . include ) {
257- // allowedTags is empty 没有配置,直接跳过
258- if ( isEmpty ( allowedTags ) ) {
259- this . log ( 'priorityRule include need allowedTags or allowedPaths ' ) ;
256+ if ( priorityRule === PriorityRule . both ) {
257+ // includeTags is empty 没有配置,直接跳过
258+ if ( isEmpty ( includeTags ) ) {
259+ this . log ( 'priorityRule include need includeTags or includePaths ' ) ;
260260 return ;
261261 }
262262
263- const inAllowedTags =
264- ! isEmpty ( allowedTags ) &&
265- ! allowedTags . some ( ( tagRule ) =>
263+ const inincludeTags =
264+ ! isEmpty ( includeTags ) &&
265+ ! includeTags . some ( ( tagRule ) =>
266266 typeof tagRule === 'string'
267267 ? minimatch ( tagLowerCase , tagRule )
268268 : tagRule . test ( tagLowerCase )
@@ -274,7 +274,7 @@ export default class ServiceGenerator {
274274 ? minimatch ( tagLowerCase , tagRule )
275275 : tagRule . test ( tagLowerCase )
276276 ) ;
277- if ( inAllowedTags || inExcludeTags ) {
277+ if ( inincludeTags || inExcludeTags ) {
278278 return ;
279279 }
280280 }
@@ -451,13 +451,13 @@ export default class ServiceGenerator {
451451
452452 // 筛选出 pathItem 包含的 $ref 对应的schema
453453 if (
454- ! isEmpty ( this . config ?. allowedTags ) &&
454+ ! isEmpty ( this . config ?. includeTags ) &&
455455 ! isEmpty ( operationObject . tags )
456456 ) {
457457 if (
458458 ! isEmpty (
459459 intersection (
460- this . config . allowedTags ,
460+ this . config . includeTags ,
461461 map ( operationObject . tags , ( tag ) => tag . toLowerCase ( ) )
462462 )
463463 )
@@ -548,7 +548,7 @@ export default class ServiceGenerator {
548548
549549 // 判断哪些 schema 需要添加进 type, schemas 渲染数组
550550 if (
551- isEmpty ( this . config . allowedTags ) ||
551+ isEmpty ( this . config . includeTags ) ||
552552 ( schema as ICustomSchemaObject ) ?. isAllowed
553553 ) {
554554 const isEnum = result . isEnum as boolean ;
@@ -1240,16 +1240,16 @@ export default class ServiceGenerator {
12401240 private generateInfoLog ( ) : void {
12411241 this . log ( `priorityRule: ${ this . config ?. priorityRule } ` ) ;
12421242
1243- if ( this . config ?. allowedTags ) {
1244- this . log ( `allowedTags : ${ this . config ?. allowedTags . join ( ', ' ) } ` ) ;
1243+ if ( this . config ?. includeTags ) {
1244+ this . log ( `includeTags : ${ this . config ?. includeTags . join ( ', ' ) } ` ) ;
12451245 }
12461246
12471247 if ( this . config ?. excludeTags ) {
12481248 this . log ( `excludeTags: ${ this . config ?. excludeTags . join ( ', ' ) } ` ) ;
12491249 }
12501250
1251- if ( this . config ?. allowedPaths ) {
1252- this . log ( `allowedPaths : ${ this . config ?. allowedPaths . join ( ', ' ) } ` ) ;
1251+ if ( this . config ?. includePaths ) {
1252+ this . log ( `includePaths : ${ this . config ?. includePaths . join ( ', ' ) } ` ) ;
12531253 }
12541254
12551255 if ( this . config ?. excludePaths ) {
0 commit comments