Skip to content

Commit 9095926

Browse files
committed
🔧 fix: use getFlattenedRoutes() to include guard() schemas in OpenAPI spec
Fixes guard() schemas not appearing in generated OpenAPI documentation. Changes: - Replace app.getGlobalRoutes() with app.getFlattenedRoutes?.() ?? app.getGlobalRoutes() - Maintains backward compatibility with older Elysia versions This allows the OpenAPI plugin to access guard() schemas that are now exposed via Elysia's getFlattenedRoutes() method. Requires: elysiajs/elysia#1533
1 parent 070919e commit 9095926

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/openapi.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,10 @@ export function toOpenAPISchema(
295295
const definitions = app.getGlobalDefinitions?.().type
296296

297297
// @ts-ignore private property
298-
const routes = app.getGlobalRoutes()
298+
// Use getFlattenedRoutes() if available (Elysia 1.4.16+) to get guard() schemas
299+
// Falls back to getGlobalRoutes() for older versions
300+
// @ts-ignore
301+
const routes = app.getFlattenedRoutes?.() ?? app.getGlobalRoutes()
299302

300303
if (references) {
301304
if (!Array.isArray(references)) references = [references]

0 commit comments

Comments
 (0)