Skip to content

Commit 4bd258f

Browse files
committed
fix(openapi): Correctly handle generating spec with a "/" endpoint
1 parent a86e6a3 commit 4bd258f

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

src/open-api.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,14 @@ export function buildOpenApiDocs(
3939
};
4040
for (const [method, methodEntry] of Object.entries(app["~zeta"].routes)) {
4141
for (const [path, routerData] of Object.entries(methodEntry)) {
42-
const openApiPath = path
43-
// Replace parameters with OpenAPI format
44-
.replace(/\/:([^/]+)/g, "/{$1}")
45-
// Remove trailing slash
46-
.replace(/\/$/, "");
42+
const openApiPath =
43+
path
44+
// Replace parameters with OpenAPI format
45+
.replace(/\/:([^/]+)/g, "/{$1}")
46+
// Remove trailing slash
47+
.replace(/\/$/, "") ||
48+
// Convert "" -> "/"
49+
"/";
4750
const { headers, params, query, body, responses, ...openApiOperation } =
4851
routerData.def ?? {};
4952
docs.paths ??= {};

0 commit comments

Comments
 (0)