Skip to content

Commit fe789d8

Browse files
authoredNov 30, 2021
Update README.md
1 parent d07439b commit fe789d8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
 

‎README.md

+20
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,26 @@ app.use('/api-docs-one', swaggerUi.serveFiles(swaggerDocumentOne, options), swag
248248
app.use('/api-docs-two', swaggerUi.serveFiles(swaggerDocumentTwo, options), swaggerUi.setup(swaggerDocumentTwo));
249249
```
250250

251+
### Link to Swagger document
252+
253+
To render a link to the swagger document for downloading within the swagger ui - then serve the swagger doc as an endpoint and use the url option to point to it:
254+
255+
```javascript
256+
const express = require('express');
257+
const app = express();
258+
const swaggerUi = require('swagger-ui-express');
259+
const swaggerDocument = require('./swagger.json');
260+
261+
var options = {
262+
swaggerOptions: {
263+
url: "/api-docs/swagger.json",
264+
},
265+
}
266+
267+
app.use('/api-docs', swaggerUi.serveFiles(null, options), swaggerUi.setup(null, options));
268+
app.get("/api-docs/swagger.json", (req, res) => res.json(swaggerDocument));
269+
```
270+
251271

252272
## Requirements
253273

0 commit comments

Comments
 (0)
Please sign in to comment.