Socket
Socket
Sign inDemoInstall

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.1 to 1.0.2

12

index.js

@@ -6,3 +6,9 @@ 'use strict'

const setup = swaggerDoc => {
const explorerHtml = `<form id='api_selector'>
<div class='input'><input placeholder="http://example.com/api" id="input_baseUrl" name="baseUrl" type="text"/></div>
<div id='auth_container'></div>
<div class='input'><a id="explore" class="header__btn" href="#" data-sw-translate>Explore</a></div>
</form>`
const setup = (swaggerDoc, explorer) => {
const html = fs.readFileSync(__dirname + '/indexTemplate.html');

@@ -14,3 +20,5 @@ try {

}
const indexHTML = html.toString().replace('<% swaggerDoc %>', JSON.stringify(swaggerDoc));
const htmlWithSwaggerReplaced = html.toString().replace('<% swaggerDoc %>', JSON.stringify(swaggerDoc));
const explorerString = explorer ? explorerHtml : '';
const indexHTML = htmlWithSwaggerReplaced.replace('<% explorerString %>', explorerString)
return (req, res) => res.send(indexHTML);

@@ -17,0 +25,0 @@ }

2

package.json
{
"name": "swagger-ui-express",
"version": "1.0.1",
"version": "1.0.2",
"description": "Swagger UI Express",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",

@@ -36,2 +36,13 @@ # Swagger UI Express

By default the Swagger Explorer bar is hidden, to display it pass true as the second parameter to the setup function:
```javascript
const express = require('express');
const app = express();
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument, true));
```
## Requirements

@@ -38,0 +49,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