Add an OpenAPI Documentation UI to Express
Unlike FastAPI or NestJS, Express doesn’t generate or serve anything OpenAPI-related on its own — whether
your spec comes from hand-written YAML, swagger-jsdoc comments, or a schema library like
zod-to-openapi, you’re always wiring up the JSON route and the viewer yourself. That’s actually the
simple case for GetMan: there’s no bundled UI to disable first, just two routes to add.
Serve the spec
If you already have a static openapi.json file:
const openapiSpec = require('./openapi.json');
app.get('/openapi.json', (req, res) => res.json(openapiSpec));
If you’re generating it at runtime with swagger-jsdoc, call the generator once at startup and serve the
result the same way:
const swaggerJsdoc = require('swagger-jsdoc');
const openapiSpec = swaggerJsdoc({
definition: { openapi: '3.0.0', info: { title: 'My API', version: '1.0.0' } },
apis: ['./routes/*.js'],
});
app.get('/openapi.json', (req, res) => res.json(openapiSpec));
Serve the docs UI
app.get('/docs', (req, res) => {
res.send(`
<div id="api-docs" style="height: 100vh"></div>
<script src="https://cdn.getman.dev/latest/getman-ui.js"></script>
<script>
GetMan.launch(document.getElementById('api-docs'), { url: '/openapi.json' });
</script>
`);
});
That’s the whole integration — no swagger-ui-express middleware, no bundled assets to configure, and no
build step. Visiting /docs fetches /openapi.json client-side and renders it the same way any of
GetMan’s other embeds do.
Since Express has no bundled UI of its own to compare against, see the Swagger UI alternative comparison for feature-by-feature differences against the viewer most other frameworks default to.
Try it with your own spec
Paste any OpenAPI or Swagger URL and see it rendered live — no signup, no install.
Open the explorer