Skip to content

Commit

Permalink
feat: added Swagger UI integration
Browse files Browse the repository at this point in the history
  • Loading branch information
mvegter committed May 10, 2020
1 parent bd446e0 commit 679b153
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 16 deletions.
6 changes: 6 additions & 0 deletions lib/server/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

const path = require('path');
const { HttpServer } = require('@aliceo2/web-ui');
const swaggerUi = require('swagger-ui-express');
const YAML = require('yamljs');
const { IServer } = require('../application/interfaces');
const buildEndpoints = require('./routers');

Expand Down Expand Up @@ -57,6 +59,10 @@ class WebUiServer extends IServer {
}));

buildEndpoints(this.http);

const swaggerDocument = YAML.load(path.resolve(__dirname, '..', '..', 'spec', 'openapi.yaml'));
this.http.routerStatics.use('/api-docs', swaggerUi.serve);
this.http.routerStatics.get('/api-docs', swaggerUi.setup(swaggerDocument));
}

/**
Expand Down
42 changes: 27 additions & 15 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
"mariadb": "2.3.1",
"sequelize": "5.21.8",
"structure": "2.0.0",
"umzug": "2.3.0"
"swagger-ui-express": "4.1.4",
"umzug": "2.3.0",
"yamljs": "0.3.0"
},
"devDependencies": {
"chai": "4.2.0",
Expand Down

0 comments on commit 679b153

Please sign in to comment.