openapi-ts-request 1.7.0 → 1.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/generator/serviceGenarator.js +1 -1
- package/dist/type.d.ts +4 -4
- package/dist/util.js +4 -33
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -274,8 +274,8 @@ openapi --i ./spec.json --o ./apis
|
|
|
274
274
|
| apifoxToken | string | [获取](https://docs.apifox.com/doc-5723694) | true |
|
|
275
275
|
| local | string | 语言(默认: zh-CN) | false |
|
|
276
276
|
| apifoxVersion | string | 默认: 2024-03-28, [获取当前版本](https://api.apifox.com/v1/versions) | false |
|
|
277
|
-
|
|
|
278
|
-
|
|
|
277
|
+
| selectedTags | \* 或 string[] | 默认: \* | false |
|
|
278
|
+
| excludedByTags | string[] | 默认: [] | false |
|
|
279
279
|
| oasVersion | string | 指定用于导出的 OpenAPI 规范的版本,可以有值如 "2.0"、"3.0"、"3.1" | '3.0' |
|
|
280
280
|
| exportFormat | string | 指定导出的 OpenAPI 文件的格式,可以有值如 'JSON' 或 'YAML' | 'JSON' |
|
|
281
281
|
| includeApifoxExtensionProperties | boolean | 指定是否包含 Apifox 的 OpenAPI 规范扩展字段 `x-apifox` | false |
|
|
@@ -663,7 +663,7 @@ class ServiceGenerator {
|
|
|
663
663
|
var _a;
|
|
664
664
|
const { components } = this.openAPIData;
|
|
665
665
|
const response = responses &&
|
|
666
|
-
this.resolveRefObject(responses
|
|
666
|
+
this.resolveRefObject(responses['200'] || responses['201'] || responses.default);
|
|
667
667
|
const defaultResponse = {
|
|
668
668
|
mediaType: '*/*',
|
|
669
669
|
type: 'unknown',
|
package/dist/type.d.ts
CHANGED
|
@@ -86,8 +86,8 @@ export type ReadConfigOptions = MutuallyExclusiveWithFallback<{
|
|
|
86
86
|
export interface APIFoxBody {
|
|
87
87
|
scope?: {
|
|
88
88
|
type?: 'ALL' | 'SELECTED_TAGS';
|
|
89
|
-
|
|
90
|
-
|
|
89
|
+
selectedTags?: string[];
|
|
90
|
+
excludedByTags?: string[];
|
|
91
91
|
};
|
|
92
92
|
options?: {
|
|
93
93
|
includeApifoxExtensionProperties?: boolean;
|
|
@@ -102,7 +102,7 @@ export interface GetSchemaByApifoxProps extends Pick<APIFoxBody, 'oasVersion' |
|
|
|
102
102
|
apifoxToken: string;
|
|
103
103
|
locale?: string;
|
|
104
104
|
apifoxVersion?: string;
|
|
105
|
-
|
|
106
|
-
|
|
105
|
+
selectedTags?: string[];
|
|
106
|
+
excludedByTags?: string[];
|
|
107
107
|
}
|
|
108
108
|
export {};
|
package/dist/util.js
CHANGED
|
@@ -24,35 +24,6 @@ const getImportStatement = (requestLibPath) => {
|
|
|
24
24
|
return `import { request } from 'axios';`;
|
|
25
25
|
};
|
|
26
26
|
exports.getImportStatement = getImportStatement;
|
|
27
|
-
const getApifoxIncludeTags = (tags) => {
|
|
28
|
-
let _tags_ = '*';
|
|
29
|
-
if (tags && Array.isArray(tags)) {
|
|
30
|
-
if (!tags.length) {
|
|
31
|
-
return '*';
|
|
32
|
-
}
|
|
33
|
-
_tags_ = [];
|
|
34
|
-
for (const tag of tags) {
|
|
35
|
-
if (typeof tag === 'string') {
|
|
36
|
-
if (tag === '*') {
|
|
37
|
-
_tags_ = '*';
|
|
38
|
-
break;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
else if (tag instanceof RegExp) {
|
|
42
|
-
_tags_ = '*';
|
|
43
|
-
break;
|
|
44
|
-
// TODO:后期添加支持判断字符串是否为正则
|
|
45
|
-
}
|
|
46
|
-
else {
|
|
47
|
-
_tags_.push(tag);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
else if (tags) {
|
|
52
|
-
_tags_ = [tags];
|
|
53
|
-
}
|
|
54
|
-
return _tags_;
|
|
55
|
-
};
|
|
56
27
|
/**
|
|
57
28
|
* 通过 apifox 获取 openapi 文档
|
|
58
29
|
* @param params {object}
|
|
@@ -61,11 +32,11 @@ const getApifoxIncludeTags = (tags) => {
|
|
|
61
32
|
* @param params.apifoxVersion {string} apifox 版本 目前固定为 2024-03-28 可通过 https://api.apifox.com/v1/versions 获取最新版本
|
|
62
33
|
* @returns
|
|
63
34
|
*/
|
|
64
|
-
const getSchemaByApifox = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ projectId, locale = 'zh-CN', apifoxVersion = '2024-03-28',
|
|
35
|
+
const getSchemaByApifox = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, function* ({ projectId, locale = 'zh-CN', apifoxVersion = '2024-03-28', selectedTags, excludedByTags = [], apifoxToken, oasVersion = '3.0', exportFormat = 'JSON', includeApifoxExtensionProperties = false, addFoldersToTags = false, }) {
|
|
65
36
|
try {
|
|
66
37
|
const body = {
|
|
67
38
|
scope: {
|
|
68
|
-
|
|
39
|
+
excludedByTags,
|
|
69
40
|
},
|
|
70
41
|
options: {
|
|
71
42
|
includeApifoxExtensionProperties,
|
|
@@ -74,13 +45,13 @@ const getSchemaByApifox = (_a) => tslib_1.__awaiter(void 0, [_a], void 0, functi
|
|
|
74
45
|
oasVersion,
|
|
75
46
|
exportFormat,
|
|
76
47
|
};
|
|
77
|
-
const tags =
|
|
48
|
+
const tags = !(0, lodash_1.isEmpty)(selectedTags) ? selectedTags : '*';
|
|
78
49
|
if (tags === '*') {
|
|
79
50
|
body.scope.type = 'ALL';
|
|
80
51
|
}
|
|
81
52
|
else {
|
|
82
53
|
body.scope.type = 'SELECTED_TAGS';
|
|
83
|
-
body.scope.
|
|
54
|
+
body.scope.selectedTags = tags;
|
|
84
55
|
}
|
|
85
56
|
const res = yield axios_1.default.post(`https://api.apifox.com/v1/projects/${projectId}/export-openapi?locale=${locale}`, body, {
|
|
86
57
|
headers: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-request",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.2",
|
|
4
4
|
"description": "Swagger2/OpenAPI3/Apifox to TypeScript/JavaScript, request client(support any client), request mock service, enum and enum translation, react-query/vue-query, type field label, JSON Schemas",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0",
|