HBForge/Examples
10 · Docs / OpenAPI

Interactive Swagger UI docs

swaggerUI({ url }) returns a complete HTML page wired to the Swagger UI CDN — drop in one route.

forge/serverNodeBunDenoCF Workers
Code
swagger-ui.js
const { WebApp, swaggerUI } =
  require(class="tk-str">'@hyperbridge/forge/server');

const app = new WebApp();

app.get(class="tk-str">'/docs', (c) => c.html(
  swaggerUI({ url: class="tk-str">'/openapi.json' })
));

class="tk-cm">// ... openapi.json endpoint ...

app.listen(3000);
How it works

The returned HTML pulls Swagger UI's CSS and JS from a CDN, configured against your spec URL. No npm install, no build step.

Theme, title, layout are all options on swaggerUI() — see the type definitions for the full surface.

For air-gapped deployments, vendor the Swagger UI assets and pass { swaggerUrl: '/static/swagger-ui.css' }.

Try it
Quickstart
open http://localhost:3000/docs
Related modules