@elysiajs/openapi 1.3.10 → 1.3.12
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/LICENSE +7 -7
- package/README.md +101 -101
- package/bun.lock +537 -537
- package/dist/cjs/gen/index.js +27 -15
- package/dist/gen/index.d.ts +16 -1
- package/dist/gen/index.mjs +27 -15
- package/package.json +1 -1
package/dist/cjs/gen/index.js
CHANGED
|
@@ -36,15 +36,16 @@ var fromTypes = (targetFilePath, {
|
|
|
36
36
|
instanceName,
|
|
37
37
|
projectRoot = process.cwd(),
|
|
38
38
|
overrideOutputPath,
|
|
39
|
-
debug = false
|
|
39
|
+
debug = false,
|
|
40
|
+
compilerOptions,
|
|
41
|
+
tmpRoot = (0, import_path.join)((0, import_os.tmpdir)(), ".ElysiaAutoOpenAPI")
|
|
40
42
|
} = {}) => () => {
|
|
41
|
-
const tmpRoot = (0, import_path.join)((0, import_os.tmpdir)(), ".ElysiaAutoOpenAPI");
|
|
42
43
|
try {
|
|
43
44
|
if (!targetFilePath.endsWith(".ts") && !targetFilePath.endsWith(".tsx"))
|
|
44
45
|
throw new Error("Only .ts files are supported");
|
|
45
46
|
if (targetFilePath.startsWith("./"))
|
|
46
47
|
targetFilePath = targetFilePath.slice(2);
|
|
47
|
-
|
|
48
|
+
let src = targetFilePath.startsWith("/") ? targetFilePath : (0, import_path.join)(projectRoot, targetFilePath);
|
|
48
49
|
if (!(0, import_fs.existsSync)(src))
|
|
49
50
|
throw new Error(
|
|
50
51
|
`Couldn't find "${targetFilePath}" from ${projectRoot}`
|
|
@@ -56,22 +57,28 @@ var fromTypes = (targetFilePath, {
|
|
|
56
57
|
(0, import_fs.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
57
58
|
(0, import_fs.mkdirSync)(tmpRoot, { recursive: true });
|
|
58
59
|
const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : (0, import_path.join)(projectRoot, tsconfigPath);
|
|
59
|
-
|
|
60
|
+
let extendsRef = (0, import_fs.existsSync)(tsconfig) ? `"extends": "${(0, import_path.join)(projectRoot, "tsconfig.json")}",` : "";
|
|
61
|
+
let distDir = (0, import_path.join)(tmpRoot, "dist");
|
|
62
|
+
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
63
|
+
extendsRef = extendsRef.replace(/\\/g, "/");
|
|
64
|
+
src = src.replace(/\\/g, "/");
|
|
65
|
+
distDir = distDir.replace(/\\/g, "/");
|
|
66
|
+
}
|
|
60
67
|
(0, import_fs.writeFileSync)(
|
|
61
68
|
(0, import_path.join)(tmpRoot, "tsconfig.json"),
|
|
62
69
|
`{
|
|
63
70
|
${extendsRef}
|
|
64
|
-
"compilerOptions": {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
71
|
+
"compilerOptions": ${compilerOptions ? JSON.stringify(compilerOptions) : `{
|
|
72
|
+
"lib": ["ESNext"],
|
|
73
|
+
"module": "ESNext",
|
|
74
|
+
"noEmit": false,
|
|
75
|
+
"declaration": true,
|
|
76
|
+
"emitDeclarationOnly": true,
|
|
77
|
+
"moduleResolution": "bundler",
|
|
78
|
+
"skipLibCheck": true,
|
|
79
|
+
"skipDefaultLibCheck": true,
|
|
80
|
+
"outDir": "${distDir}"
|
|
81
|
+
}`},
|
|
75
82
|
"include": ["${src}"]
|
|
76
83
|
}`
|
|
77
84
|
);
|
|
@@ -113,6 +120,11 @@ var fromTypes = (targetFilePath, {
|
|
|
113
120
|
);
|
|
114
121
|
console.warn(tempFiles);
|
|
115
122
|
}
|
|
123
|
+
} else {
|
|
124
|
+
console.log(
|
|
125
|
+
"reason: root folter doesn't exists",
|
|
126
|
+
(0, import_path.join)(tmpRoot, "dist")
|
|
127
|
+
);
|
|
116
128
|
}
|
|
117
129
|
return;
|
|
118
130
|
}
|
package/dist/gen/index.d.ts
CHANGED
|
@@ -31,6 +31,21 @@ interface OpenAPIGeneratorOptions {
|
|
|
31
31
|
* @default false
|
|
32
32
|
*/
|
|
33
33
|
debug?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* compilerOptions
|
|
36
|
+
*
|
|
37
|
+
* Override tsconfig.json compilerOptions
|
|
38
|
+
*/
|
|
39
|
+
compilerOptions?: Record<string, any>;
|
|
40
|
+
/**
|
|
41
|
+
* Temporary root
|
|
42
|
+
*
|
|
43
|
+
* a folder where temporary files are stored
|
|
44
|
+
* @default os.tmpdir()/.ElysiaAutoOpenAPI
|
|
45
|
+
*
|
|
46
|
+
* ! be careful that the folder will be removed after the process ends
|
|
47
|
+
*/
|
|
48
|
+
tmpRoot?: string;
|
|
34
49
|
}
|
|
35
50
|
/**
|
|
36
51
|
* Auto generate OpenAPI schema from Elysia instance
|
|
@@ -45,5 +60,5 @@ export declare const fromTypes: (
|
|
|
45
60
|
*
|
|
46
61
|
* The path must export an Elysia instance
|
|
47
62
|
*/
|
|
48
|
-
targetFilePath: string, { tsconfigPath, instanceName, projectRoot, overrideOutputPath, debug }?: OpenAPIGeneratorOptions) => () => AdditionalReference | undefined;
|
|
63
|
+
targetFilePath: string, { tsconfigPath, instanceName, projectRoot, overrideOutputPath, debug, compilerOptions, tmpRoot }?: OpenAPIGeneratorOptions) => () => AdditionalReference | undefined;
|
|
49
64
|
export {};
|
package/dist/gen/index.mjs
CHANGED
|
@@ -19,15 +19,16 @@ var fromTypes = (targetFilePath, {
|
|
|
19
19
|
instanceName,
|
|
20
20
|
projectRoot = process.cwd(),
|
|
21
21
|
overrideOutputPath,
|
|
22
|
-
debug = false
|
|
22
|
+
debug = false,
|
|
23
|
+
compilerOptions,
|
|
24
|
+
tmpRoot = join(tmpdir(), ".ElysiaAutoOpenAPI")
|
|
23
25
|
} = {}) => () => {
|
|
24
|
-
const tmpRoot = join(tmpdir(), ".ElysiaAutoOpenAPI");
|
|
25
26
|
try {
|
|
26
27
|
if (!targetFilePath.endsWith(".ts") && !targetFilePath.endsWith(".tsx"))
|
|
27
28
|
throw new Error("Only .ts files are supported");
|
|
28
29
|
if (targetFilePath.startsWith("./"))
|
|
29
30
|
targetFilePath = targetFilePath.slice(2);
|
|
30
|
-
|
|
31
|
+
let src = targetFilePath.startsWith("/") ? targetFilePath : join(projectRoot, targetFilePath);
|
|
31
32
|
if (!existsSync(src))
|
|
32
33
|
throw new Error(
|
|
33
34
|
`Couldn't find "${targetFilePath}" from ${projectRoot}`
|
|
@@ -39,22 +40,28 @@ var fromTypes = (targetFilePath, {
|
|
|
39
40
|
rmSync(tmpRoot, { recursive: true, force: true });
|
|
40
41
|
mkdirSync(tmpRoot, { recursive: true });
|
|
41
42
|
const tsconfig = tsconfigPath.startsWith("/") ? tsconfigPath : join(projectRoot, tsconfigPath);
|
|
42
|
-
|
|
43
|
+
let extendsRef = existsSync(tsconfig) ? `"extends": "${join(projectRoot, "tsconfig.json")}",` : "";
|
|
44
|
+
let distDir = join(tmpRoot, "dist");
|
|
45
|
+
if (typeof process !== "undefined" && process.platform === "win32") {
|
|
46
|
+
extendsRef = extendsRef.replace(/\\/g, "/");
|
|
47
|
+
src = src.replace(/\\/g, "/");
|
|
48
|
+
distDir = distDir.replace(/\\/g, "/");
|
|
49
|
+
}
|
|
43
50
|
writeFileSync(
|
|
44
51
|
join(tmpRoot, "tsconfig.json"),
|
|
45
52
|
`{
|
|
46
53
|
${extendsRef}
|
|
47
|
-
"compilerOptions": {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
54
|
+
"compilerOptions": ${compilerOptions ? JSON.stringify(compilerOptions) : `{
|
|
55
|
+
"lib": ["ESNext"],
|
|
56
|
+
"module": "ESNext",
|
|
57
|
+
"noEmit": false,
|
|
58
|
+
"declaration": true,
|
|
59
|
+
"emitDeclarationOnly": true,
|
|
60
|
+
"moduleResolution": "bundler",
|
|
61
|
+
"skipLibCheck": true,
|
|
62
|
+
"skipDefaultLibCheck": true,
|
|
63
|
+
"outDir": "${distDir}"
|
|
64
|
+
}`},
|
|
58
65
|
"include": ["${src}"]
|
|
59
66
|
}`
|
|
60
67
|
);
|
|
@@ -96,6 +103,11 @@ var fromTypes = (targetFilePath, {
|
|
|
96
103
|
);
|
|
97
104
|
console.warn(tempFiles);
|
|
98
105
|
}
|
|
106
|
+
} else {
|
|
107
|
+
console.log(
|
|
108
|
+
"reason: root folter doesn't exists",
|
|
109
|
+
join(tmpRoot, "dist")
|
|
110
|
+
);
|
|
99
111
|
}
|
|
100
112
|
return;
|
|
101
113
|
}
|