Skip to content

Feature(swagger): add swagger ui #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions mock/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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');
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@
"@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",
"express": "^4.17.1",
"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"
Expand Down