swagger-ui-express
Advanced tools
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 @@ } |
{ | ||
"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
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
3002980
35155
56