@1szx1/vite-plugin-swagger2ts 1.2.1 → 1.2.3
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 +4 -3
- package/dist/index.mjs +4 -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 = "";
|
|
@@ -198,6 +197,8 @@ function generatorResponseBodyType(schemas, docsName) {
|
|
|
198
197
|
return jsDoc({ description }, { key: "response", result });
|
|
199
198
|
}
|
|
200
199
|
function jsDoc({ description, title, format, example, default: default1 }, { key, result, isRoot, isExport, isRequired }) {
|
|
200
|
+
if (!/(^\[.+\]$)|(^[^\[\]]*$)/.test(key))
|
|
201
|
+
key = `'${key}'`;
|
|
201
202
|
const jsDoc2 = `
|
|
202
203
|
/**
|
|
203
204
|
${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 = "";
|
|
@@ -190,6 +189,8 @@ function generatorResponseBodyType(schemas, docsName) {
|
|
|
190
189
|
return jsDoc({ description }, { key: "response", result });
|
|
191
190
|
}
|
|
192
191
|
function jsDoc({ description, title, format, example, default: default1 }, { key, result, isRoot, isExport, isRequired }) {
|
|
192
|
+
if (!/(^\[.+\]$)|(^[^\[\]]*$)/.test(key))
|
|
193
|
+
key = `'${key}'`;
|
|
193
194
|
const jsDoc2 = `
|
|
194
195
|
/**
|
|
195
196
|
${title ? ` * @title ${title}
|
package/package.json
CHANGED