Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

swagger-ui-express

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swagger-ui-express - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

7

index.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc