@1szx1/vite-plugin-swagger2ts 1.2.1 → 1.2.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/dist/index.cjs +6 -3
- package/dist/index.mjs +6 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -139,9 +139,8 @@ const TYPES = {
|
|
|
139
139
|
};
|
|
140
140
|
function generatorSchemaType(key, schema, { isRoot = false, isRequired, isExport = false, docsName = "" } = {}) {
|
|
141
141
|
if (isTypeAny(schema)) {
|
|
142
|
-
return `
|
|
143
|
-
${key}${isRequired === false ? "?" : ""}: any
|
|
144
|
-
`;
|
|
142
|
+
return `${key && `
|
|
143
|
+
${key}${isRequired === false ? "?" : ""}: `}any${key && `;`}`;
|
|
145
144
|
}
|
|
146
145
|
const { type, $ref, enum: Enum, items, properties, oneOf, additionalProperties, required, allOf } = schema;
|
|
147
146
|
let result = "";
|
|
@@ -195,9 +194,13 @@ function generatorResponseBodyType(schemas, docsName) {
|
|
|
195
194
|
} else {
|
|
196
195
|
result = generatorSchemaType("", schema, { docsName });
|
|
197
196
|
}
|
|
197
|
+
if (result.includes("any;"))
|
|
198
|
+
console.log(jsDoc({ description }, { key: "response", result }));
|
|
198
199
|
return jsDoc({ description }, { key: "response", result });
|
|
199
200
|
}
|
|
200
201
|
function jsDoc({ description, title, format, example, default: default1 }, { key, result, isRoot, isExport, isRequired }) {
|
|
202
|
+
if (!/(^\[.+\]$)|(^[^\[\]]*$)/.test(key))
|
|
203
|
+
key = `'${key}'`;
|
|
201
204
|
const jsDoc2 = `
|
|
202
205
|
/**
|
|
203
206
|
${title ? ` * @title ${title}
|
package/dist/index.mjs
CHANGED
|
@@ -131,9 +131,8 @@ const TYPES = {
|
|
|
131
131
|
};
|
|
132
132
|
function generatorSchemaType(key, schema, { isRoot = false, isRequired, isExport = false, docsName = "" } = {}) {
|
|
133
133
|
if (isTypeAny(schema)) {
|
|
134
|
-
return `
|
|
135
|
-
${key}${isRequired === false ? "?" : ""}: any
|
|
136
|
-
`;
|
|
134
|
+
return `${key && `
|
|
135
|
+
${key}${isRequired === false ? "?" : ""}: `}any${key && `;`}`;
|
|
137
136
|
}
|
|
138
137
|
const { type, $ref, enum: Enum, items, properties, oneOf, additionalProperties, required, allOf } = schema;
|
|
139
138
|
let result = "";
|
|
@@ -187,9 +186,13 @@ function generatorResponseBodyType(schemas, docsName) {
|
|
|
187
186
|
} else {
|
|
188
187
|
result = generatorSchemaType("", schema, { docsName });
|
|
189
188
|
}
|
|
189
|
+
if (result.includes("any;"))
|
|
190
|
+
console.log(jsDoc({ description }, { key: "response", result }));
|
|
190
191
|
return jsDoc({ description }, { key: "response", result });
|
|
191
192
|
}
|
|
192
193
|
function jsDoc({ description, title, format, example, default: default1 }, { key, result, isRoot, isExport, isRequired }) {
|
|
194
|
+
if (!/(^\[.+\]$)|(^[^\[\]]*$)/.test(key))
|
|
195
|
+
key = `'${key}'`;
|
|
193
196
|
const jsDoc2 = `
|
|
194
197
|
/**
|
|
195
198
|
${title ? ` * @title ${title}
|
package/package.json
CHANGED