swagger-ui-express
Advanced tools
Comparing version 2.0.11 to 2.0.12
16
index.js
@@ -10,5 +10,17 @@ 'use strict' | ||
var setup = function(swaggerDoc, explorer, options, customCss, customfavIcon, swaggerUrl, customeSiteTitle) { | ||
var setup = function(swaggerDoc, opts, options, customCss, customfavIcon, swaggerUrl, customeSiteTitle) { | ||
var isExplorer | ||
if (typeof opts === 'object') { | ||
isExplorer = opts.explorer | ||
options = opts.swaggerOptions | ||
customCss = opts.customCss | ||
customfavIcon = opts.customfavIcon | ||
swaggerUrl = opts.swaggerUrl | ||
customeSiteTitle = opts.customSiteTitle | ||
} else { | ||
//support legacy params based function | ||
isExplorer = opts | ||
} | ||
options = options || {}; | ||
var explorerString = explorer ? '' : '.swagger-ui .topbar .download-url-wrapper { display: none }'; | ||
var explorerString = isExplorer ? '' : '.swagger-ui .topbar .download-url-wrapper { display: none }'; | ||
customCss = explorerString + ' ' + customCss || explorerString; | ||
@@ -15,0 +27,0 @@ customfavIcon = customfavIcon || false; |
{ | ||
"name": "swagger-ui-express", | ||
"version": "2.0.11", | ||
"version": "2.0.12", | ||
"description": "Swagger UI Express", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -40,3 +40,3 @@ # Swagger UI Express | ||
By default the Swagger Explorer bar is hidden, to display it pass true as the second parameter to the setup function: | ||
By default the Swagger Explorer bar is hidden, to display it pass true as the 'explorer' property of the options to the setup function: | ||
@@ -49,5 +49,7 @@ ```javascript | ||
var showExplorer = true; | ||
var options = { | ||
explorer : true | ||
}; | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, showExplorer)); | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options)); | ||
``` | ||
@@ -57,3 +59,3 @@ | ||
To pass custom options e.g. validatorUrl, to the SwaggerUi client pass an object as the third parameter: | ||
To pass custom options e.g. validatorUrl, to the SwaggerUi client pass an object as the 'swaggerOptions' property of the options to the setup function: | ||
@@ -66,8 +68,9 @@ ```javascript | ||
var showExplorer = true; | ||
var options = { | ||
validatorUrl : null | ||
swaggerOptions: { | ||
validatorUrl : null | ||
} | ||
}; | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, showExplorer, options)); | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options)); | ||
``` | ||
@@ -77,3 +80,3 @@ | ||
To customize the style of the swagger page, you can pass custom CSS as the fourth parameter. | ||
To customize the style of the swagger page, you can pass custom CSS as the 'customCss' property of the options to the setup function. | ||
@@ -88,7 +91,7 @@ E.g. to hide the swagger header: | ||
var showExplorer = false; | ||
var options = {}; | ||
var customCss = '#header { display: none }'; | ||
var options = { | ||
customCss: '#header { display: none }' | ||
}; | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, showExplorer, options, customCss)); | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, options)); | ||
``` | ||
@@ -98,3 +101,3 @@ | ||
To load your swagger from a url instead of injecting the document, pass `null` as the first parameter, and pass the relative or absolute URL as the sixth parameter. | ||
To load your swagger from a url instead of injecting the document, pass `null` as the first parameter, and pass the relative or absolute URL as the 'swaggerUrl' property of the options to the setup function. | ||
@@ -108,4 +111,7 @@ ```javascript | ||
app.static | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(null, null, null, null, null, 'http://petstore.swagger.io/v2/swagger.json')); | ||
var options = { | ||
swaggerUrl: 'http://petstore.swagger.io/v2/swagger.json' | ||
} | ||
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(null, options)); | ||
``` | ||
@@ -112,0 +118,0 @@ |
@@ -37,3 +37,7 @@ | ||
if (customOptions.authAction) { | ||
ui.authActions.authorize(customOptions.authAction) | ||
} | ||
window.ui = ui | ||
} |
15377126
7834
138