@elysiajs/openapi 1.3.6-exp.0 → 1.3.7
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/bunfig.toml +2 -0
- package/dist/cjs/gen/index.js +18 -10
- package/dist/gen/index.mjs +18 -10
- package/package.json +1 -1
package/bunfig.toml
ADDED
package/dist/cjs/gen/index.js
CHANGED
|
@@ -29,7 +29,7 @@ var import_os = require("os");
|
|
|
29
29
|
var import_path = require("path");
|
|
30
30
|
var import_child_process = require("child_process");
|
|
31
31
|
var matchRoute = /: Elysia<(.*)>/gs;
|
|
32
|
-
var matchStatus = /(\d{3}):/
|
|
32
|
+
var matchStatus = /(\d{3}):/g;
|
|
33
33
|
var wrapStatusInQuote = (value) => value.replace(matchStatus, '"$1":');
|
|
34
34
|
var exec = (command, cwd) => (0, import_child_process.spawnSync)(command, {
|
|
35
35
|
shell: true,
|
|
@@ -89,20 +89,26 @@ var fromTypes = (targetFilePath, {
|
|
|
89
89
|
)?.[0];
|
|
90
90
|
if (!instance) return;
|
|
91
91
|
for (let i = 0; i < 3; i++)
|
|
92
|
-
instance = instance.slice(
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
instance = instance.slice(
|
|
93
|
+
instance.indexOf(
|
|
94
|
+
"}, {",
|
|
95
|
+
// remove just `}, `, leaving `{`
|
|
96
|
+
3
|
|
97
|
+
)
|
|
98
|
+
);
|
|
99
|
+
const routesString = wrapStatusInQuote(
|
|
100
|
+
// Intentionally not adding "}"
|
|
101
|
+
// to avoid mismatched bracket in loop below
|
|
102
|
+
instance.slice(3, instance.indexOf("}, {", 4))
|
|
103
|
+
);
|
|
97
104
|
const routes = {};
|
|
98
|
-
for (
|
|
99
|
-
|
|
100
|
-
let schema = (0, import_typemap.TypeBox)(route);
|
|
105
|
+
for (const route of routesString.slice(1).split("} & {")) {
|
|
106
|
+
let schema = (0, import_typemap.TypeBox)(`{${route}}`);
|
|
101
107
|
if (schema.type !== "object") continue;
|
|
102
108
|
const paths = [];
|
|
103
109
|
while (true) {
|
|
104
110
|
const keys = Object.keys(schema.properties);
|
|
105
|
-
if (
|
|
111
|
+
if (keys.length !== 1) break;
|
|
106
112
|
paths.push(keys[0]);
|
|
107
113
|
schema = schema.properties[keys[0]];
|
|
108
114
|
if (!schema?.properties) break;
|
|
@@ -126,6 +132,8 @@ var fromTypes = (targetFilePath, {
|
|
|
126
132
|
);
|
|
127
133
|
console.warn(error);
|
|
128
134
|
return;
|
|
135
|
+
} finally {
|
|
136
|
+
(0, import_fs.rmSync)(tmpRoot, { recursive: true, force: true });
|
|
129
137
|
}
|
|
130
138
|
};
|
|
131
139
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/gen/index.mjs
CHANGED
|
@@ -11,7 +11,7 @@ import { tmpdir } from "os";
|
|
|
11
11
|
import { join } from "path";
|
|
12
12
|
import { spawnSync } from "child_process";
|
|
13
13
|
var matchRoute = /: Elysia<(.*)>/gs;
|
|
14
|
-
var matchStatus = /(\d{3}):/
|
|
14
|
+
var matchStatus = /(\d{3}):/g;
|
|
15
15
|
var wrapStatusInQuote = (value) => value.replace(matchStatus, '"$1":');
|
|
16
16
|
var exec = (command, cwd) => spawnSync(command, {
|
|
17
17
|
shell: true,
|
|
@@ -71,20 +71,26 @@ var fromTypes = (targetFilePath, {
|
|
|
71
71
|
)?.[0];
|
|
72
72
|
if (!instance) return;
|
|
73
73
|
for (let i = 0; i < 3; i++)
|
|
74
|
-
instance = instance.slice(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
instance = instance.slice(
|
|
75
|
+
instance.indexOf(
|
|
76
|
+
"}, {",
|
|
77
|
+
// remove just `}, `, leaving `{`
|
|
78
|
+
3
|
|
79
|
+
)
|
|
80
|
+
);
|
|
81
|
+
const routesString = wrapStatusInQuote(
|
|
82
|
+
// Intentionally not adding "}"
|
|
83
|
+
// to avoid mismatched bracket in loop below
|
|
84
|
+
instance.slice(3, instance.indexOf("}, {", 4))
|
|
85
|
+
);
|
|
79
86
|
const routes = {};
|
|
80
|
-
for (
|
|
81
|
-
|
|
82
|
-
let schema = TypeBox(route);
|
|
87
|
+
for (const route of routesString.slice(1).split("} & {")) {
|
|
88
|
+
let schema = TypeBox(`{${route}}`);
|
|
83
89
|
if (schema.type !== "object") continue;
|
|
84
90
|
const paths = [];
|
|
85
91
|
while (true) {
|
|
86
92
|
const keys = Object.keys(schema.properties);
|
|
87
|
-
if (
|
|
93
|
+
if (keys.length !== 1) break;
|
|
88
94
|
paths.push(keys[0]);
|
|
89
95
|
schema = schema.properties[keys[0]];
|
|
90
96
|
if (!schema?.properties) break;
|
|
@@ -108,6 +114,8 @@ var fromTypes = (targetFilePath, {
|
|
|
108
114
|
);
|
|
109
115
|
console.warn(error);
|
|
110
116
|
return;
|
|
117
|
+
} finally {
|
|
118
|
+
rmSync(tmpRoot, { recursive: true, force: true });
|
|
111
119
|
}
|
|
112
120
|
};
|
|
113
121
|
export {
|