@1szx1/vite-plugin-swagger2ts 1.3.14 → 1.3.16
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 -4
- package/dist/index.mjs +4 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -208,7 +208,7 @@ function generatorResponseBodyType(schemas, docsName) {
|
|
|
208
208
|
return jsDoc({ description }, { key: "response", result });
|
|
209
209
|
}
|
|
210
210
|
function jsDoc({ description, title, format, example, default: default1 }, { key, result, isRoot, isExport, isRequired }) {
|
|
211
|
-
if (!(isRoot || isExport) &&
|
|
211
|
+
if (!(isRoot || isExport) && /^[^'"]*$/.test(key))
|
|
212
212
|
key = `'${key}'`;
|
|
213
213
|
const jsDoc2 = `
|
|
214
214
|
/**
|
|
@@ -315,7 +315,7 @@ async function loadSwaggerSource(options) {
|
|
|
315
315
|
return a;
|
|
316
316
|
}, "");
|
|
317
317
|
const outputFile = path.resolve(process.cwd(), output);
|
|
318
|
-
fs.writeFileSync(outputFile, await prettier.format(
|
|
318
|
+
fs.writeFileSync(outputFile, CODE_PREFIX + await prettier.format(code + suffix, { parser: "typescript" }));
|
|
319
319
|
return { sources, interfaces };
|
|
320
320
|
}
|
|
321
321
|
async function loadGlobTypes({ glob, output }) {
|
|
@@ -324,7 +324,7 @@ async function loadGlobTypes({ glob, output }) {
|
|
|
324
324
|
const outputFile = path.resolve(process.cwd(), glob.output || "auto-types.d.ts");
|
|
325
325
|
const importPath = path.relative(outputFile, output).replaceAll("\\", "/").replace(/^\.\.\//, "./");
|
|
326
326
|
const intersection = getPathsName("_Intersection");
|
|
327
|
-
const code =
|
|
327
|
+
const code = `import { ${intersection} } from '${importPath}'
|
|
328
328
|
|
|
329
329
|
type FilterOptional<Source, Condition> = Pick<
|
|
330
330
|
Source,
|
|
@@ -338,7 +338,7 @@ declare global {
|
|
|
338
338
|
${generatorMethodType(intersection)}
|
|
339
339
|
}
|
|
340
340
|
}`;
|
|
341
|
-
fs.writeFileSync(outputFile, await prettier.format(code, { parser: "typescript" }));
|
|
341
|
+
fs.writeFileSync(outputFile, await prettier.format(CODE_PREFIX + code, { parser: "typescript" }));
|
|
342
342
|
}
|
|
343
343
|
function swagger2TsPlugin(userOptions) {
|
|
344
344
|
(async () => {
|
package/dist/index.mjs
CHANGED
|
@@ -199,7 +199,7 @@ function generatorResponseBodyType(schemas, docsName) {
|
|
|
199
199
|
return jsDoc({ description }, { key: "response", result });
|
|
200
200
|
}
|
|
201
201
|
function jsDoc({ description, title, format, example, default: default1 }, { key, result, isRoot, isExport, isRequired }) {
|
|
202
|
-
if (!(isRoot || isExport) &&
|
|
202
|
+
if (!(isRoot || isExport) && /^[^'"]*$/.test(key))
|
|
203
203
|
key = `'${key}'`;
|
|
204
204
|
const jsDoc2 = `
|
|
205
205
|
/**
|
|
@@ -306,7 +306,7 @@ async function loadSwaggerSource(options) {
|
|
|
306
306
|
return a;
|
|
307
307
|
}, "");
|
|
308
308
|
const outputFile = resolve(process.cwd(), output);
|
|
309
|
-
writeFileSync(outputFile, await format(
|
|
309
|
+
writeFileSync(outputFile, CODE_PREFIX + await format(code + suffix, { parser: "typescript" }));
|
|
310
310
|
return { sources, interfaces };
|
|
311
311
|
}
|
|
312
312
|
async function loadGlobTypes({ glob, output }) {
|
|
@@ -315,7 +315,7 @@ async function loadGlobTypes({ glob, output }) {
|
|
|
315
315
|
const outputFile = resolve(process.cwd(), glob.output || "auto-types.d.ts");
|
|
316
316
|
const importPath = relative(outputFile, output).replaceAll("\\", "/").replace(/^\.\.\//, "./");
|
|
317
317
|
const intersection = getPathsName("_Intersection");
|
|
318
|
-
const code =
|
|
318
|
+
const code = `import { ${intersection} } from '${importPath}'
|
|
319
319
|
|
|
320
320
|
type FilterOptional<Source, Condition> = Pick<
|
|
321
321
|
Source,
|
|
@@ -329,7 +329,7 @@ declare global {
|
|
|
329
329
|
${generatorMethodType(intersection)}
|
|
330
330
|
}
|
|
331
331
|
}`;
|
|
332
|
-
writeFileSync(outputFile, await format(code, { parser: "typescript" }));
|
|
332
|
+
writeFileSync(outputFile, await format(CODE_PREFIX + code, { parser: "typescript" }));
|
|
333
333
|
}
|
|
334
334
|
function swagger2TsPlugin(userOptions) {
|
|
335
335
|
(async () => {
|
package/package.json
CHANGED