swagger-ui-express
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -12,4 +12,5 @@ 'use strict' | ||
var setup = function(swaggerDoc, explorer, options) { | ||
var setup = function(swaggerDoc, explorer, options, customCss) { | ||
options = options || {}; | ||
customCss = customCss || ''; | ||
var html = fs.readFileSync(__dirname + '/indexTemplate.html'); | ||
@@ -25,3 +26,5 @@ try { | ||
var indexHTML = explorerHtmlWithSwagger.replace('<% customOptions %>', JSON.stringify(options)) | ||
return function(req, res) { res.send(indexHTML) }; | ||
var htmlWithCustomCss = indexHTML.replace('<% customCss %>', customCss); | ||
return function(req, res) { res.send(htmlWithCustomCss) }; | ||
}; | ||
@@ -28,0 +31,0 @@ |
{ | ||
"name": "swagger-ui-express", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Swagger UI Express", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -25,3 +25,3 @@ # Swagger UI Express | ||
## [swagger-jsdoc](https://www.npmjs.com/package/swagger-jsdoc) | ||
### [swagger-jsdoc](https://www.npmjs.com/package/swagger-jsdoc) | ||
@@ -37,2 +37,4 @@ If you are using swagger-jsdoc simply pass the swaggerSpec into the setup function: | ||
### Swagger Explorer | ||
By default the Swagger Explorer bar is hidden, to display it pass true as the second parameter to the setup function: | ||
@@ -46,5 +48,9 @@ | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, true)); | ||
var showExplorer = true; | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, showExplorer)); | ||
``` | ||
### Custom swagger options | ||
To pass custom options e.g. validatorUrl, to the SwaggerUi client pass an object as the third parameter: | ||
@@ -58,2 +64,3 @@ | ||
var showExplorer = true; | ||
var options = { | ||
@@ -63,5 +70,24 @@ validatorUrl : null | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, true, options)); | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, showExplorer, options)); | ||
``` | ||
### Custom CSS styles | ||
To customize the style of the swagger page, you can pass custom CSS as the fourth parameter. | ||
E.g. to hide the swagger header: | ||
```javascript | ||
const express = require('express'); | ||
const app = express(); | ||
const swaggerUi = require('swagger-ui-express'); | ||
const swaggerDocument = require('./swagger.json'); | ||
var showExplorer = false; | ||
var options = {}; | ||
var customCss = '#header { display: none }'; | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, showExplorer, options, customCss)); | ||
``` | ||
## Requirements | ||
@@ -68,0 +94,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3004689
35160
98