HonoH
Hono15mo ago
DGCP3

Adding swagger to hono API

I want to add a swagger doc to my API and when I add middleware to any new OpenAPIHono instance the .openapi method disappears.

/**
 * Creates a base instance of Hono with middleware.
 * @returns {Hono} The base instance of Hono.
 */
const base = () => new OpenAPIHono().use(databaseMiddleware).use(bucketMiddleware).use(cacheMiddleware);

/**
 * Represents a public route.
 * @returns {Hono}
 */
export const publicHonoRoute = () => base(); // public route

/**
 * Marks a route as protected.
 * @returns {Hono}
 */
export const protectedHonoRoute = () => base().use(protect).use(typesenseMiddleware); // protected route


this is my factory method. the instance returned doesn't have .openapi, so I can pass my schema returned by createRoute().
Was this page helpful?