@gopowerteam/request-generate 0.1.9 → 0.1.11
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/index.js +12 -1
- package/dist/index.mjs +12 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -53,7 +53,7 @@ function generateServiceOptions(options) {
|
|
|
53
53
|
|
|
54
54
|
// src/utils/get-camel-name.ts
|
|
55
55
|
function getCamelName(value) {
|
|
56
|
-
return value.replace(/^[^a-zA-Z]+/g, "").replace(/[^\w-]+/g, "
|
|
56
|
+
return value.replace(/^[^a-zA-Z]+/g, "").replace(/[^\w-]+/g, "_").replace(/^\S/, (s) => s.toUpperCase()).replace(/_[a-zA-Z]/g, (s) => s.toUpperCase()).replace(/_/g, "").trim();
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
// src/entities/model.ts
|
|
@@ -147,6 +147,12 @@ function parseSchemaType(schema) {
|
|
|
147
147
|
ref: void 0
|
|
148
148
|
};
|
|
149
149
|
}
|
|
150
|
+
if (!("$ref" in schema) && schema.type === "object") {
|
|
151
|
+
return {
|
|
152
|
+
type: getMappedType(schema.type),
|
|
153
|
+
ref: "any"
|
|
154
|
+
};
|
|
155
|
+
}
|
|
150
156
|
throw new Error("\u65E0\u6CD5\u89E3\u6790\u76F8\u5E94\u7684schema");
|
|
151
157
|
}
|
|
152
158
|
|
|
@@ -327,6 +333,11 @@ function parseParametersQuery(parameters) {
|
|
|
327
333
|
parameter.required = p.required;
|
|
328
334
|
parameter.imports = imports || [];
|
|
329
335
|
parameter.enums = enums;
|
|
336
|
+
if (p.name.includes(".") && !p.name.startsWith(".") && !p.name.endsWith(".")) {
|
|
337
|
+
const [name, subName] = p.name.split(".");
|
|
338
|
+
parameter.name = name;
|
|
339
|
+
parameter.ref = `{ ${subName}${parameter.required ? "?" : ""}: ${ref || "any"} }`;
|
|
340
|
+
}
|
|
330
341
|
r.push(parameter);
|
|
331
342
|
}
|
|
332
343
|
return r;
|
package/dist/index.mjs
CHANGED
|
@@ -54,7 +54,7 @@ function generateServiceOptions(options) {
|
|
|
54
54
|
|
|
55
55
|
// src/utils/get-camel-name.ts
|
|
56
56
|
function getCamelName(value) {
|
|
57
|
-
return value.replace(/^[^a-zA-Z]+/g, "").replace(/[^\w-]+/g, "
|
|
57
|
+
return value.replace(/^[^a-zA-Z]+/g, "").replace(/[^\w-]+/g, "_").replace(/^\S/, (s) => s.toUpperCase()).replace(/_[a-zA-Z]/g, (s) => s.toUpperCase()).replace(/_/g, "").trim();
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
// src/entities/model.ts
|
|
@@ -148,6 +148,12 @@ function parseSchemaType(schema) {
|
|
|
148
148
|
ref: void 0
|
|
149
149
|
};
|
|
150
150
|
}
|
|
151
|
+
if (!("$ref" in schema) && schema.type === "object") {
|
|
152
|
+
return {
|
|
153
|
+
type: getMappedType(schema.type),
|
|
154
|
+
ref: "any"
|
|
155
|
+
};
|
|
156
|
+
}
|
|
151
157
|
throw new Error("\u65E0\u6CD5\u89E3\u6790\u76F8\u5E94\u7684schema");
|
|
152
158
|
}
|
|
153
159
|
|
|
@@ -328,6 +334,11 @@ function parseParametersQuery(parameters) {
|
|
|
328
334
|
parameter.required = p.required;
|
|
329
335
|
parameter.imports = imports || [];
|
|
330
336
|
parameter.enums = enums;
|
|
337
|
+
if (p.name.includes(".") && !p.name.startsWith(".") && !p.name.endsWith(".")) {
|
|
338
|
+
const [name, subName] = p.name.split(".");
|
|
339
|
+
parameter.name = name;
|
|
340
|
+
parameter.ref = `{ ${subName}${parameter.required ? "?" : ""}: ${ref || "any"} }`;
|
|
341
|
+
}
|
|
331
342
|
r.push(parameter);
|
|
332
343
|
}
|
|
333
344
|
return r;
|