openapi-ts-request 1.3.2 → 1.3.4
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/dist/generator/util.js
CHANGED
|
@@ -27,8 +27,9 @@ const tslib_1 = require("tslib");
|
|
|
27
27
|
const lodash_1 = require("lodash");
|
|
28
28
|
const reserved_words_1 = tslib_1.__importDefault(require("reserved-words"));
|
|
29
29
|
const tiny_pinyin_1 = tslib_1.__importDefault(require("tiny-pinyin"));
|
|
30
|
+
const config_1 = require("../config");
|
|
30
31
|
const log_1 = tslib_1.__importDefault(require("../log"));
|
|
31
|
-
const
|
|
32
|
+
const config_2 = require("./config");
|
|
32
33
|
function stripDot(str) {
|
|
33
34
|
return str.replace(/[-_ .](\w)/g, (_all, letter) => letter.toUpperCase());
|
|
34
35
|
}
|
|
@@ -105,13 +106,13 @@ function getDefaultType(schemaObject, namespace = '', schemas) {
|
|
|
105
106
|
if (type === 'null') {
|
|
106
107
|
return 'null';
|
|
107
108
|
}
|
|
108
|
-
if (
|
|
109
|
+
if (config_2.numberEnum.includes(schemaObject.format)) {
|
|
109
110
|
type = 'number';
|
|
110
111
|
}
|
|
111
112
|
if (schemaObject.enum) {
|
|
112
113
|
type = 'enum';
|
|
113
114
|
}
|
|
114
|
-
if (
|
|
115
|
+
if (config_2.numberEnum.includes(type)) {
|
|
115
116
|
return 'number';
|
|
116
117
|
}
|
|
117
118
|
if (dateEnum.includes(type)) {
|
|
@@ -170,6 +171,10 @@ function getDefaultType(schemaObject, namespace = '', schemas) {
|
|
|
170
171
|
return `(${allofList.join(' & ')})`;
|
|
171
172
|
}
|
|
172
173
|
if (schemaObject.type === 'object' || schemaObject.properties) {
|
|
174
|
+
if ((0, lodash_1.isObject)(schemaObject.additionalProperties)) {
|
|
175
|
+
const type = getDefaultType(schemaObject.additionalProperties, namespace, schemas);
|
|
176
|
+
return `Record<string, ${type}>`;
|
|
177
|
+
}
|
|
173
178
|
if (!(0, lodash_1.keys)(schemaObject.properties).length) {
|
|
174
179
|
return 'Record<string, unknown>';
|
|
175
180
|
}
|
|
@@ -314,8 +319,10 @@ function isNonArraySchemaObject(schema) {
|
|
|
314
319
|
(schema === null || schema === void 0 ? void 0 : schema.properties) !== undefined);
|
|
315
320
|
}
|
|
316
321
|
function isArraySchemaObject(schema) {
|
|
317
|
-
return (((schema === null || schema === void 0 ? void 0 : schema.type) ===
|
|
318
|
-
|
|
322
|
+
return (((schema === null || schema === void 0 ? void 0 : schema.type) === config_1.SchemaObjectType.array ||
|
|
323
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
324
|
+
// @ts-expect-error
|
|
325
|
+
(schema === null || schema === void 0 ? void 0 : schema.type) === config_1.SchemaObjectType.stringArray) &&
|
|
319
326
|
(schema === null || schema === void 0 ? void 0 : schema.items) !== undefined);
|
|
320
327
|
}
|
|
321
328
|
function isBinaryArraySchemaObject(schema) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openapi-ts-request",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.4",
|
|
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",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"lint-staged": "^15.3.0",
|
|
70
70
|
"openapi-types": "^12.1.3",
|
|
71
71
|
"ts-node": "^10.9.2",
|
|
72
|
-
"typescript": "5.8.
|
|
72
|
+
"typescript": "5.8.3"
|
|
73
73
|
},
|
|
74
74
|
"keywords": [
|
|
75
75
|
"openapi",
|