@sebspark/openapi-typegen 2.1.0 → 2.3.0
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.js +17 -7
- package/package.json +4 -3
package/dist/index.js
CHANGED
|
@@ -354,12 +354,18 @@ var generateArgs = (args, isServer) => {
|
|
|
354
354
|
const arg = args[part];
|
|
355
355
|
if (arg) {
|
|
356
356
|
const partName = part === "path" ? "params" : part === "header" ? "headers" : part;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
generateType(arg)
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
357
|
+
if (partName === "query") {
|
|
358
|
+
tokens.push(
|
|
359
|
+
`${partName}${arg.optional ? "?" : ""}: Serialized<${generateType(arg)}>`
|
|
360
|
+
);
|
|
361
|
+
} else {
|
|
362
|
+
tokens.push(
|
|
363
|
+
`${partName}${arg.optional ? "?" : ""}: ${wrapArgs(
|
|
364
|
+
generateType(arg),
|
|
365
|
+
isServer && part === "header"
|
|
366
|
+
)}`
|
|
367
|
+
);
|
|
368
|
+
}
|
|
363
369
|
}
|
|
364
370
|
}
|
|
365
371
|
if (!tokens.length) return "";
|
|
@@ -409,11 +415,15 @@ var generateResponses = (path) => Object.entries(path.responses).filter(([code])
|
|
|
409
415
|
// src/generator/server.ts
|
|
410
416
|
var generateServer = (name, paths) => {
|
|
411
417
|
const tokens = [];
|
|
412
|
-
tokens.push(`export type ${name}
|
|
418
|
+
tokens.push(`export type ${name}ServerPaths = {`);
|
|
413
419
|
for (const [url, methods] of Object.entries(groupPathsByUrl(paths))) {
|
|
414
420
|
tokens.push(generatePath(url, methods));
|
|
415
421
|
}
|
|
416
422
|
tokens.push("}");
|
|
423
|
+
tokens.push("\n");
|
|
424
|
+
tokens.push(
|
|
425
|
+
`export type ${name}Server = APIServerDefinition & ${name}ServerPaths`
|
|
426
|
+
);
|
|
417
427
|
return tokens.join("\n");
|
|
418
428
|
};
|
|
419
429
|
var groupPathsByUrl = (paths) => paths.reduce(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/openapi-typegen",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -18,7 +18,8 @@
|
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/yargs": "17.0.33",
|
|
21
|
-
"tsconfig": "*"
|
|
21
|
+
"tsconfig": "*",
|
|
22
|
+
"vitest": "3.1.2"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"@sebspark/openapi-core": "*",
|
|
@@ -26,7 +27,7 @@
|
|
|
26
27
|
"chalk": "<5",
|
|
27
28
|
"change-case": "4.1.2",
|
|
28
29
|
"prettier": "3.5.3",
|
|
29
|
-
"yaml": "2.7.
|
|
30
|
+
"yaml": "2.7.1",
|
|
30
31
|
"yargs": "17.7.2"
|
|
31
32
|
}
|
|
32
33
|
}
|