swagger updates api-docs and api-docs-ui

Signed-off-by: Nakul Manchanda <nakul.manchanda@ibm.com>
This commit is contained in:
Nakul Manchanda
2020-07-23 11:48:54 -04:00
parent 7a2315e8ad
commit 03b21e0c91
4 changed files with 23 additions and 9 deletions

View File

@@ -1,8 +1,8 @@
#
services:
- serviceId: sample-node-api
title: Sample Node API
description: Example Node.js Application
title: Sample-Node-API
description: Sample Node API
catalogUiTileId: sample-node-api
instanceBaseUrls:
- https://mymainframe.ibm.com:18000/
@@ -13,9 +13,11 @@ services:
apiInfo:
- apiId: com.ibm.sample-node-api
gatewayUrl: api/v1
version: 0.0.1
version: 1.0.0
swaggerUrl: https://mymainframe.ibm.com:18000/api-docs
documentationUrl: https://mymainframe.ibm.com:18000/api-docs-ui
catalogUiTiles:
sample-node-api:
title: Sample-Node-Api
description: Example Node.js Application
title: Sample-Node-API
description: Sample Node API

View File

@@ -126,10 +126,17 @@ const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
var options = {
explorer: true
explorer: false
};
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
// app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options));
app.use('/api-docs-ui', function(req, res, next){
swaggerDocument.host = req.get('host');
req.swaggerDoc = swaggerDocument;
next();
}, swaggerUi.serve, swaggerUi.setup());
//TODO: use for whitelist only
app.use(cors());
const routes = require('./routes/index.route');
@@ -145,6 +152,11 @@ app.get('/health', (req, res) => {
});
app.use(routes);
app.use('/api-docs',function(req, res, next){
swaggerDocument.host = req.get('host');
res.send(swaggerDocument);
});
const httpServer = http.createServer(app);
const httpsServer = https.createServer(credentials, app);

View File

@@ -1,5 +1,5 @@
{
"port": "18000",
"port": "18000",
"https": {
"key": "../sslcert/server.key",
"cert": "../sslcert/server.cert"

View File

@@ -1,6 +1,6 @@
{
"swagger":"2.0"
,"info":{"description":"Sample Node API\n\n[Swagger/OpenAPI JSON Document](https://mainframe.ibm.com:47554/api/v1/apicatalog/apidoc/sample-node-api-http/v1)"
,"info":{"description":"Sample Node API"
,"version":"1.0"
,"title":"Sample Node API"}
,"host":"localhost:8080"