npm install --save-dev swagger-ui-express @types/swagger-ui-express
{
"swagger": "2.0",
"info": {
"description": "Node Typescript Boilerplate for Microservices. Skeleton for Node.js Apps written in TypeScript (with Setup Instructions for ESLint, Prettier, and Husky)",
"version": "1.0.0",
"title": "Node Boilerplate"
},
"host": "",
"basePath": "/api",
"tags": [{
"name": "node-boilerplate",
"description": "Node Typescript Boilerplate"
}],
"schemes": ["http", "https"],
"paths": {
"/status/system": {
"get": {
"tags": ["node-boilerplate"],
"summary": "get system status",
"description": "",
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
}
},
"security": []
}
},
"/status/time": {
"get": {
"tags": ["node-boilerplate"],
"summary": "get server time",
"description": "",
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
}
},
"security": []
}
},
"/status/usage": {
"get": {
"tags": ["node-boilerplate"],
"summary": "get server usage",
"description": "",
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
}
},
"security": []
}
},
"/status/process": {
"get": {
"tags": ["node-boilerplate"],
"summary": "get server process",
"description": "",
"responses": {
"200": {
"description": "successful operation",
"schema": {
"$ref": "#/definitions/ApiResponse"
}
}
},
"security": []
}
}
},
"securityDefinitions": {},
"definitions": {
"ApiResponse": {
"type": "object",
"properties": {
}
}
},
"externalDocs": {
"description": "Find out more about Node Typescript Boilerplate",
"url": "https://blog.santoshshinde.com/skeleton-for-node-js-apps-written-in-typescript-444fa1695b30"
}
}
"resolveJsonModule": true
import swaggerUi from 'swagger-ui-express';
import swaggerDocument from '../swagger.json'
this.express.use('/docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
The swagger documentation is available at the following url ${host}/docs
: