@elysiajs/openapi 1.3.11 → 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.
@@ -36,9 +36,10 @@ 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");
@@ -57,25 +58,27 @@ var fromTypes = (targetFilePath, {
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");
60
62
  if (typeof process !== "undefined" && process.platform === "win32") {
61
63
  extendsRef = extendsRef.replace(/\\/g, "/");
62
64
  src = src.replace(/\\/g, "/");
65
+ distDir = distDir.replace(/\\/g, "/");
63
66
  }
64
67
  (0, import_fs.writeFileSync)(
65
68
  (0, import_path.join)(tmpRoot, "tsconfig.json"),
66
69
  `{
67
70
  ${extendsRef}
68
- "compilerOptions": {
69
- "lib": ["ESNext"],
70
- "module": "ESNext",
71
- "noEmit": false,
72
- "declaration": true,
73
- "emitDeclarationOnly": true,
74
- "moduleResolution": "bundler",
75
- "skipLibCheck": true,
76
- "skipDefaultLibCheck": true,
77
- "outDir": "./dist"
78
- },
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
+ }`},
79
82
  "include": ["${src}"]
80
83
  }`
81
84
  );
@@ -117,6 +120,11 @@ var fromTypes = (targetFilePath, {
117
120
  );
118
121
  console.warn(tempFiles);
119
122
  }
123
+ } else {
124
+ console.log(
125
+ "reason: root folter doesn't exists",
126
+ (0, import_path.join)(tmpRoot, "dist")
127
+ );
120
128
  }
121
129
  return;
122
130
  }
@@ -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 {};
@@ -19,9 +19,10 @@ 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");
@@ -40,25 +41,27 @@ var fromTypes = (targetFilePath, {
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");
43
45
  if (typeof process !== "undefined" && process.platform === "win32") {
44
46
  extendsRef = extendsRef.replace(/\\/g, "/");
45
47
  src = src.replace(/\\/g, "/");
48
+ distDir = distDir.replace(/\\/g, "/");
46
49
  }
47
50
  writeFileSync(
48
51
  join(tmpRoot, "tsconfig.json"),
49
52
  `{
50
53
  ${extendsRef}
51
- "compilerOptions": {
52
- "lib": ["ESNext"],
53
- "module": "ESNext",
54
- "noEmit": false,
55
- "declaration": true,
56
- "emitDeclarationOnly": true,
57
- "moduleResolution": "bundler",
58
- "skipLibCheck": true,
59
- "skipDefaultLibCheck": true,
60
- "outDir": "./dist"
61
- },
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
+ }`},
62
65
  "include": ["${src}"]
63
66
  }`
64
67
  );
@@ -100,6 +103,11 @@ var fromTypes = (targetFilePath, {
100
103
  );
101
104
  console.warn(tempFiles);
102
105
  }
106
+ } else {
107
+ console.log(
108
+ "reason: root folter doesn't exists",
109
+ join(tmpRoot, "dist")
110
+ );
103
111
  }
104
112
  return;
105
113
  }
package/package.json CHANGED
@@ -1,92 +1,92 @@
1
- {
2
- "name": "@elysiajs/openapi",
3
- "version": "1.3.11",
4
- "description": "Plugin for Elysia to auto-generate API documentation",
5
- "author": {
6
- "name": "saltyAom",
7
- "url": "https://github.com/SaltyAom",
8
- "email": "saltyaom@gmail.com"
9
- },
10
- "main": "./dist/cjs/index.js",
11
- "module": "./dist/index.mjs",
12
- "types": "./dist/index.d.ts",
13
- "exports": {
14
- "./package.json": "./package.json",
15
- ".": {
16
- "types": "./dist/index.d.ts",
17
- "import": "./dist/index.mjs",
18
- "require": "./dist/cjs/index.js"
19
- },
20
- "./gen": {
21
- "types": "./dist/gen/index.d.ts",
22
- "import": "./dist/gen/index.mjs",
23
- "require": "./dist/cjs/gen/index.js"
24
- },
25
- "./openapi": {
26
- "types": "./dist/openapi.d.ts",
27
- "import": "./dist/openapi.mjs",
28
- "require": "./dist/cjs/openapi.js"
29
- },
30
- "./scalar": {
31
- "types": "./dist/scalar/index.d.ts",
32
- "import": "./dist/scalar/index.mjs",
33
- "require": "./dist/cjs/scalar/index.js"
34
- },
35
- "./scalar/theme": {
36
- "types": "./dist/scalar/theme.d.ts",
37
- "import": "./dist/scalar/theme.mjs",
38
- "require": "./dist/cjs/scalar/theme.js"
39
- },
40
- "./swagger": {
41
- "types": "./dist/swagger/index.d.ts",
42
- "import": "./dist/swagger/index.mjs",
43
- "require": "./dist/cjs/swagger/index.js"
44
- },
45
- "./swagger/types": {
46
- "types": "./dist/swagger/types.d.ts",
47
- "import": "./dist/swagger/types.mjs",
48
- "require": "./dist/cjs/swagger/types.js"
49
- },
50
- "./types": {
51
- "types": "./dist/types.d.ts",
52
- "import": "./dist/types.mjs",
53
- "require": "./dist/cjs/types.js"
54
- }
55
- },
56
- "keywords": [
57
- "elysia",
58
- "openapi",
59
- "swagger",
60
- "scalar"
61
- ],
62
- "homepage": "https://github.com/elysiajs/elysia-openapi",
63
- "repository": {
64
- "type": "git",
65
- "url": "https://github.com/elysiajs/elysia-openapi"
66
- },
67
- "bugs": "https://github.com/elysiajs/elysia-openapi/issues",
68
- "license": "MIT",
69
- "scripts": {
70
- "dev": "bun run --watch example/index.ts",
71
- "test": "bun test && npm run test:node",
72
- "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
73
- "build": "bun build.ts",
74
- "release": "npm run build && npm run test && npm publish --access public"
75
- },
76
- "peerDependencies": {
77
- "elysia": ">= 1.3.0"
78
- },
79
- "devDependencies": {
80
- "@apidevtools/swagger-parser": "^12.0.0",
81
- "@types/bun": "1.2.20",
82
- "@scalar/types": "^0.2.13",
83
- "elysia": "1.3.21",
84
- "eslint": "9.6.0",
85
- "tsup": "^8.5.0",
86
- "typescript": "^5.9.2"
87
- },
88
- "dependencies": {
89
- "@sinclair/typemap": "^0.10.1",
90
- "openapi-types": "^12.1.3"
91
- }
92
- }
1
+ {
2
+ "name": "@elysiajs/openapi",
3
+ "version": "1.3.12",
4
+ "description": "Plugin for Elysia to auto-generate API documentation",
5
+ "author": {
6
+ "name": "saltyAom",
7
+ "url": "https://github.com/SaltyAom",
8
+ "email": "saltyaom@gmail.com"
9
+ },
10
+ "main": "./dist/cjs/index.js",
11
+ "module": "./dist/index.mjs",
12
+ "types": "./dist/index.d.ts",
13
+ "exports": {
14
+ "./package.json": "./package.json",
15
+ ".": {
16
+ "types": "./dist/index.d.ts",
17
+ "import": "./dist/index.mjs",
18
+ "require": "./dist/cjs/index.js"
19
+ },
20
+ "./gen": {
21
+ "types": "./dist/gen/index.d.ts",
22
+ "import": "./dist/gen/index.mjs",
23
+ "require": "./dist/cjs/gen/index.js"
24
+ },
25
+ "./openapi": {
26
+ "types": "./dist/openapi.d.ts",
27
+ "import": "./dist/openapi.mjs",
28
+ "require": "./dist/cjs/openapi.js"
29
+ },
30
+ "./scalar": {
31
+ "types": "./dist/scalar/index.d.ts",
32
+ "import": "./dist/scalar/index.mjs",
33
+ "require": "./dist/cjs/scalar/index.js"
34
+ },
35
+ "./scalar/theme": {
36
+ "types": "./dist/scalar/theme.d.ts",
37
+ "import": "./dist/scalar/theme.mjs",
38
+ "require": "./dist/cjs/scalar/theme.js"
39
+ },
40
+ "./swagger": {
41
+ "types": "./dist/swagger/index.d.ts",
42
+ "import": "./dist/swagger/index.mjs",
43
+ "require": "./dist/cjs/swagger/index.js"
44
+ },
45
+ "./swagger/types": {
46
+ "types": "./dist/swagger/types.d.ts",
47
+ "import": "./dist/swagger/types.mjs",
48
+ "require": "./dist/cjs/swagger/types.js"
49
+ },
50
+ "./types": {
51
+ "types": "./dist/types.d.ts",
52
+ "import": "./dist/types.mjs",
53
+ "require": "./dist/cjs/types.js"
54
+ }
55
+ },
56
+ "keywords": [
57
+ "elysia",
58
+ "openapi",
59
+ "swagger",
60
+ "scalar"
61
+ ],
62
+ "homepage": "https://github.com/elysiajs/elysia-openapi",
63
+ "repository": {
64
+ "type": "git",
65
+ "url": "https://github.com/elysiajs/elysia-openapi"
66
+ },
67
+ "bugs": "https://github.com/elysiajs/elysia-openapi/issues",
68
+ "license": "MIT",
69
+ "scripts": {
70
+ "dev": "bun run --watch example/index.ts",
71
+ "test": "bun test && npm run test:node",
72
+ "test:node": "npm install --prefix ./test/node/cjs/ && npm install --prefix ./test/node/esm/ && node ./test/node/cjs/index.js && node ./test/node/esm/index.js",
73
+ "build": "bun build.ts",
74
+ "release": "npm run build && npm run test && npm publish --access public"
75
+ },
76
+ "peerDependencies": {
77
+ "elysia": ">= 1.3.0"
78
+ },
79
+ "devDependencies": {
80
+ "@apidevtools/swagger-parser": "^12.0.0",
81
+ "@types/bun": "1.2.20",
82
+ "@scalar/types": "^0.2.13",
83
+ "elysia": "1.3.21",
84
+ "eslint": "9.6.0",
85
+ "tsup": "^8.5.0",
86
+ "typescript": "^5.9.2"
87
+ },
88
+ "dependencies": {
89
+ "@sinclair/typemap": "^0.10.1",
90
+ "openapi-types": "^12.1.3"
91
+ }
92
+ }