From 909592648342f3f6a1b471c512b13702e65c122a Mon Sep 17 00:00:00 2001 From: MarcelOlsen Date: Thu, 6 Nov 2025 23:10:29 +0100 Subject: [PATCH 1/2] :wrench: 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 --- src/openapi.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/openapi.ts b/src/openapi.ts index d99e9c7..30ab4af 100644 --- a/src/openapi.ts +++ b/src/openapi.ts @@ -295,7 +295,10 @@ export function toOpenAPISchema( const definitions = app.getGlobalDefinitions?.().type // @ts-ignore private property - const routes = app.getGlobalRoutes() + // Use getFlattenedRoutes() if available (Elysia 1.4.16+) to get guard() schemas + // Falls back to getGlobalRoutes() for older versions + // @ts-ignore + const routes = app.getFlattenedRoutes?.() ?? app.getGlobalRoutes() if (references) { if (!Array.isArray(references)) references = [references] From da02e4def9acf8ecdd1e4e10c88f78a546afe83d Mon Sep 17 00:00:00 2001 From: MarcelOlsen Date: Fri, 7 Nov 2025 10:30:25 +0100 Subject: [PATCH 2/2] :wrench: fix: use @ts-expect-error instead of @ts-ignore Addresses coderabbitai feedback on PR #300. Changed from @ts-ignore to @ts-expect-error for better type safety. This ensures the suppression is still necessary - if the error goes away in the future (e.g., after types are updated), @ts-expect-error will fail the build, alerting us to remove it. Also improved the comment to be more descriptive about why the suppression is needed. --- src/openapi.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/openapi.ts b/src/openapi.ts index 30ab4af..55c411b 100644 --- a/src/openapi.ts +++ b/src/openapi.ts @@ -294,10 +294,9 @@ export function toOpenAPISchema( // @ts-ignore const definitions = app.getGlobalDefinitions?.().type - // @ts-ignore private property // Use getFlattenedRoutes() if available (Elysia 1.4.16+) to get guard() schemas // Falls back to getGlobalRoutes() for older versions - // @ts-ignore + // @ts-expect-error - getFlattenedRoutes is a protected method not in public types const routes = app.getFlattenedRoutes?.() ?? app.getGlobalRoutes() if (references) {