Serve the Swagger UI

You can serve the generated Swagger UI directly from your Hono application using the included zero-dependency swaggerUI middleware:

typescript
import { swaggerUI } from '@mmtq/hono-swagger/helpers';
import * as fs from 'fs/promises';

// 1. Serve the generated OpenAPI JSON
app.get('/docs/openapi.json', async (c) => {
  const spec = await fs.readFile('./docs/openapi.json', 'utf-8');
  return c.json(JSON.parse(spec));
});

// 2. Serve the Swagger UI!
/** @openapi-ignore */
app.get('/docs', swaggerUI({ url: '/docs/openapi.json' }));
Built with ❤️ for the Hono community