diff --git a/mock/index.js b/mock/index.js index d9af8ce..dfe0e26 100644 --- a/mock/index.js +++ b/mock/index.js @@ -9,6 +9,7 @@ const cors_1 = tslib_1.__importDefault(require("cors")); const http_1 = tslib_1.__importDefault(require("http")); const path_1 = tslib_1.__importDefault(require("path")); const yamljs_1 = tslib_1.__importDefault(require("yamljs")); +const swaggerUi = require('swagger-ui-express'); const api = tslib_1.__importStar(require("./api")); const security_1 = require("./security"); const app = express_1.default(); @@ -46,6 +47,8 @@ connectSwagger(app); // Print swagger router api summary const apiSummary = summarise(apiDefinition); console.log(apiSummary); +// Swagger ui +app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(apiDefinition)); // Catch 404 error app.use((req, res, next) => { const err = new Error('Not Found'); diff --git a/package.json b/package.json index 0ed9682..aacd8dc 100644 --- a/package.json +++ b/package.json @@ -12,6 +12,7 @@ "@types/express": "^4.17.0", "@types/faker": "^4.1.5", "@types/morgan": "^1.7.35", + "@types/swagger-ui-express": "^4.1.2", "@types/yamljs": "^0.2.30", "compression": "^1.7.4", "cors": "^2.8.5", @@ -19,6 +20,7 @@ "faker": "^4.1.0", "morgan": "^1.9.1", "swagger-routes-express": "^3.0.1", + "swagger-ui-express": "^4.1.6", "tslib": "^1.9.3", "typescript": "3.4.5", "yamljs": "^0.3.0"