-
Notifications
You must be signed in to change notification settings - Fork 87
Open
Description
I’m using @elysia/openapi/gen
to generate TypeScript types for my Elysia routes. It works fine when all routes are in a single file. However, when I split routes into multiple routers and import them using .use()
, I get the following error:
Couldn't find generated declaration file
You can override with `overrideOutputPath` with one of the following:
- plugins/openapi.d.ts
- routes/posts.d.ts
Steps to reproduce
- Create a main router (app.ts) and a secondary router (posts.ts).
- In posts.ts:
import { Elysia } from "elysia";
interface Post {
id: number;
title: string;
content: string;
}
const data: Post[] = [{ id: 1, title: "Post 1", content: "Content 1" }];
export const posts = new Elysia({ prefix: "/posts" }).get("/", () => {
return data;
});
- In app.ts:
import { openapi } from "@elysiajs/openapi";
import { fromTypes } from "@elysiajs/openapi/gen";
import { Elysia } from "elysia";
import { posts } from "./routes/posts";
export const app = new Elysia()
// Plugins
.use(
openapi({
path: "/docs",
references: fromTypes("src/server.ts"),
}),
)
// Routes
.use(posts);
app.listen(3000);
Expected Behavior
Types should be generated correctly for all routes, including imported routers.
Actual Behavior
gen fails with the “Couldn't find generated declaration file” error.
Notes
- Works fine if all routes are in a single file.
- Seems like the issue happens only if the imported routes has a type/interface in it
carlosmfreitas2409
Metadata
Metadata
Assignees
Labels
No labels