@@ -6,6 +6,7 @@ import * as yaml from 'js-yaml';
66import {
77 camelCase as _camelCase_ ,
88 forEach ,
9+ isEmpty ,
910 isObject ,
1011 keys ,
1112 map ,
@@ -32,35 +33,6 @@ export const getImportStatement = (requestLibPath: string) => {
3233 return `import { request } from 'axios';` ;
3334} ;
3435
35- const getApifoxIncludeTags = ( tags ?: ( string | RegExp ) [ ] ) : '*' | string [ ] => {
36- let _tags_ : string | string [ ] = '*' ;
37- if ( tags && Array . isArray ( tags ) ) {
38- if ( ! tags . length ) {
39- return '*' ;
40- }
41-
42- _tags_ = [ ] ;
43- for ( const tag of tags ) {
44- if ( typeof tag === 'string' ) {
45- if ( tag === '*' ) {
46- _tags_ = '*' ;
47- break ;
48- }
49- } else if ( tag instanceof RegExp ) {
50- _tags_ = '*' ;
51- break ;
52- // TODO:后期添加支持判断字符串是否为正则
53- } else {
54- _tags_ . push ( tag ) ;
55- }
56- }
57- } else if ( tags ) {
58- _tags_ = [ tags as unknown as string ] ;
59- }
60-
61- return _tags_ as '*' ;
62- } ;
63-
6436/**
6537 * 通过 apifox 获取 openapi 文档
6638 * @param params {object}
@@ -73,8 +45,8 @@ const getSchemaByApifox = async ({
7345 projectId,
7446 locale = 'zh-CN' ,
7547 apifoxVersion = '2024-03-28' ,
76- includeTags ,
77- excludeTags = [ ] ,
48+ selectedTags ,
49+ excludedByTags = [ ] ,
7850 apifoxToken,
7951 oasVersion = '3.0' ,
8052 exportFormat = 'JSON' ,
@@ -84,7 +56,7 @@ const getSchemaByApifox = async ({
8456 try {
8557 const body : APIFoxBody = {
8658 scope : {
87- excludeTags ,
59+ excludedByTags ,
8860 } ,
8961 options : {
9062 includeApifoxExtensionProperties,
@@ -93,13 +65,13 @@ const getSchemaByApifox = async ({
9365 oasVersion,
9466 exportFormat,
9567 } ;
96- const tags = getApifoxIncludeTags ( includeTags ) ;
68+ const tags = ! isEmpty ( selectedTags ) ? selectedTags : '*' ;
9769
9870 if ( tags === '*' ) {
9971 body . scope . type = 'ALL' ;
10072 } else {
10173 body . scope . type = 'SELECTED_TAGS' ;
102- body . scope . includeTags = tags ;
74+ body . scope . selectedTags = tags ;
10375 }
10476
10577 const res = await axios . post (
0 commit comments