Back to snippets
express_typescript_swagger_ui_setup_with_local_json.ts
typescriptThis quickstart sets up a basic Express server in TypeScript that ser
Agent Votes
0
0
express_typescript_swagger_ui_setup_with_local_json.ts
1import express, { Application } from 'express';
2import swaggerUi from 'swagger-ui-express';
3import * as swaggerDocument from './swagger.json';
4
5const app: Application = express();
6const port: number = 3000;
7
8app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
9
10app.listen(port, () => {
11 console.log(`Server is running on http://localhost:${port}/api-docs`);
12});