Patch Changes
-
#728
3952b4bThanks @omeraplak! - feat: automatic detection and display of custom routes in console logs and Swagger UICustom routes added via
configureAppcallback are now automatically detected and displayed in both server startup logs and Swagger UI documentation.What Changed
Previously, only OpenAPI-registered routes were visible in:
- Server startup console logs
- Swagger UI documentation (
/ui)
Now all custom routes are automatically detected, including:
- Regular Hono routes (
app.get(),app.post(), etc.) - OpenAPI routes with full documentation
- Routes with path parameters (
:id,{id})
Usage Example
import { honoServer } from "@voltagent/server-hono"; new VoltAgent({ agents: { myAgent }, server: honoServer({ configureApp: (app) => { // These routes are now automatically detected! app.get("/api/health", (c) => c.json({ status: "ok" })); app.post("/api/calculate", async (c) => { const { a, b } = await c.req.json(); return c.json({ result: a + b }); }); }, }), });
Console Output
══════════════════════════════════════════════════ VOLTAGENT SERVER STARTED SUCCESSFULLY ══════════════════════════════════════════════════ ✓ HTTP Server: http://localhost:3141 ✓ Swagger UI: http://localhost:3141/ui ✓ Registered Endpoints: 2 total Custom Endpoints GET /api/health POST /api/calculate ══════════════════════════════════════════════════Improvements
- ✅ Extracts routes from
app.routesarray (includes all Hono routes) - ✅ Merges with OpenAPI document routes for descriptions
- ✅ Filters out built-in VoltAgent paths using exact matching (not regex)
- ✅ Custom routes like
/agents-dashboardor/workflows-managerare now correctly detected - ✅ Normalizes path formatting (removes duplicate slashes)
- ✅ Handles both
:paramand{param}path parameter formats - ✅ Adds custom routes to Swagger UI with auto-generated schemas
- ✅ Comprehensive test coverage (44 unit tests)
Implementation Details
The
extractCustomEndpoints()function now:- Extracts all routes from
app.routes(regular Hono routes) - Merges with OpenAPI document routes (for descriptions)
- Deduplicates and filters built-in VoltAgent routes
- Returns a complete list of custom endpoints
The
getEnhancedOpenApiDoc()function:- Adds custom routes to OpenAPI document for Swagger UI
- Generates response schemas for undocumented routes
- Preserves existing OpenAPI documentation
- Supports path parameters and request bodies
-
Updated dependencies [
59da0b5]:- @voltagent/core@1.1.34