openapi-ts-request 1.9.1 → 1.9.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 +1 -1
- package/dist/bin/openapi.js +1 -2
- package/dist/generator/serviceGenarator.js +9 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -190,7 +190,7 @@ $ openapi --help
|
|
|
190
190
|
-f, --full <boolean> full replacement (default: true)
|
|
191
191
|
--enableLogging <boolean> open the log (default: false)
|
|
192
192
|
--priorityRule <string> priority rule, include/exclude/both (default: "include")
|
|
193
|
-
--filterCaseInsensitive <boolean> whether to perform a case-insensitive match with includeTags, includePaths, excludeTags, excludePaths filters
|
|
193
|
+
--filterCaseInsensitive <boolean> whether to perform a case-insensitive match with includeTags, includePaths, excludeTags, excludePaths filters (default: false)
|
|
194
194
|
--includeTags <(string|RegExp)[]> generate code from include tags
|
|
195
195
|
--includePaths <(string|RegExp)[]> generate code from include paths
|
|
196
196
|
--excludeTags <(string|RegExp)[]> generate code from exclude tags
|
package/dist/bin/openapi.js
CHANGED
|
@@ -21,8 +21,7 @@ const params = commander_1.program
|
|
|
21
21
|
.option('--requestLibPath <string>', 'custom request lib path, for example: "@/request", "node-fetch" (default: "axios")')
|
|
22
22
|
.option('-f, --full <boolean>', 'full replacement', true)
|
|
23
23
|
.option('--enableLogging <boolean>', 'open the log', false)
|
|
24
|
-
.option('--
|
|
25
|
-
.option('--includeTags <(string|RegExp)[]>', 'generate code from include tags')
|
|
24
|
+
.option('--priorityRule <string>', 'priority rule, include/exclude/both (default: "include")')
|
|
26
25
|
.option('--filterCaseInsensitive <boolean>', 'whether to perform a case-insensitive match with includeTags, includePaths, excludeTags, excludePaths filters', false)
|
|
27
26
|
.option('--includeTags <(string|RegExp)[]>', 'generate code from include tags')
|
|
28
27
|
.option('--includePaths <(string|RegExp)[]>', 'generate code from include paths')
|
|
@@ -391,7 +391,7 @@ class ServiceGenerator {
|
|
|
391
391
|
// 暂不支持变量, path 需要普通前缀请使用例如: apiPrefix: "`api`", path 需要变量前缀请使用例如: apiPrefix: "api"
|
|
392
392
|
!api.path.includes('${'))
|
|
393
393
|
.map((api) => {
|
|
394
|
-
var _a, _b, _c, _d, _e, _f;
|
|
394
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
395
395
|
const newApi = api;
|
|
396
396
|
try {
|
|
397
397
|
const params = this.getParamsTP(newApi.parameters, newApi.path) || {};
|
|
@@ -422,9 +422,13 @@ class ServiceGenerator {
|
|
|
422
422
|
}
|
|
423
423
|
if (response === null || response === void 0 ? void 0 : response.isAnonymous) {
|
|
424
424
|
const responseName = (0, lodash_1.upperFirst)(`${functionName}Response`);
|
|
425
|
+
// 使用正则表达式移除 response?.type 中包含 this.config.namespace 的部分,isAnonymous模式不需要 this.config.namespace 前缀
|
|
426
|
+
const cleanType = ((_b = response === null || response === void 0 ? void 0 : response.type) === null || _b === void 0 ? void 0 : _b.includes(`${this.config.namespace}.`))
|
|
427
|
+
? (_c = response === null || response === void 0 ? void 0 : response.type) === null || _c === void 0 ? void 0 : _c.replace(new RegExp(`${this.config.namespace}\\.`, 'g'), '')
|
|
428
|
+
: (response === null || response === void 0 ? void 0 : response.type) || '';
|
|
425
429
|
this.interfaceTPConfigs.push({
|
|
426
430
|
typeName: responseName,
|
|
427
|
-
type:
|
|
431
|
+
type: cleanType,
|
|
428
432
|
isEnum: false,
|
|
429
433
|
props: [],
|
|
430
434
|
});
|
|
@@ -494,13 +498,13 @@ class ServiceGenerator {
|
|
|
494
498
|
: [
|
|
495
499
|
newApi.summary,
|
|
496
500
|
newApi.description,
|
|
497
|
-
((
|
|
498
|
-
? `返回值: ${((
|
|
501
|
+
((_e = (_d = newApi.responses) === null || _d === void 0 ? void 0 : _d.default) === null || _e === void 0 ? void 0 : _e.description)
|
|
502
|
+
? `返回值: ${((_f = newApi.responses) === null || _f === void 0 ? void 0 : _f.default).description}`
|
|
499
503
|
: '',
|
|
500
504
|
]
|
|
501
505
|
.filter((s) => s)
|
|
502
506
|
.join(' ')
|
|
503
|
-
.replace(config_2.lineBreakReg, ''), hasHeader: !!(params === null || params === void 0 ? void 0 : params.header) || !!(body === null || body === void 0 ? void 0 : body.mediaType), params: finalParams, hasParams: Boolean((0, lodash_1.keys)(finalParams).length), options: ((
|
|
507
|
+
.replace(config_2.lineBreakReg, ''), hasHeader: !!(params === null || params === void 0 ? void 0 : params.header) || !!(body === null || body === void 0 ? void 0 : body.mediaType), params: finalParams, hasParams: Boolean((0, lodash_1.keys)(finalParams).length), options: ((_h = (_g = this.config.hook) === null || _g === void 0 ? void 0 : _g.customOptionsDefaultValue) === null || _h === void 0 ? void 0 : _h.call(_g, newApi)) || {}, body,
|
|
504
508
|
file, hasFormData: formData, response });
|
|
505
509
|
}
|
|
506
510
|
catch (error) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-request",
|
|
3
|
-
"version": "1.9.
|
|
3
|
+
"version": "1.9.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",
|