diff --git a/sample-node-api.yml b/sample-node-api.yml index e4deede..079e16b 100644 --- a/sample-node-api.yml +++ b/sample-node-api.yml @@ -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 \ No newline at end of file + title: Sample-Node-API + description: Sample Node API \ No newline at end of file diff --git a/server/app.js b/server/app.js index ef7026a..0490ed3 100644 --- a/server/app.js +++ b/server/app.js @@ -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); diff --git a/server/config.json b/server/config.json index 51b8132..2c24c78 100644 --- a/server/config.json +++ b/server/config.json @@ -1,5 +1,5 @@ { - "port": "18000", + "port": "18000", "https": { "key": "../sslcert/server.key", "cert": "../sslcert/server.cert" diff --git a/server/swagger.json b/server/swagger.json index 76067f9..5e3f88a 100644 --- a/server/swagger.json +++ b/server/swagger.json @@ -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"