diff --git a/lib/ui.js b/lib/ui.js index d2c2469..ee18130 100644 --- a/lib/ui.js +++ b/lib/ui.js @@ -3,7 +3,7 @@ const path = require('path') const serve = require('serve-static') module.exports.serveSwaggerUI = function serveSwaggerUI (documentUrl, opts = {}) { - const { plugins, ...options } = opts + const { plugins, cdnBaseUrl, ...options } = opts return [serve(path.resolve(require.resolve('swagger-ui-dist'), '..'), { index: false }), function returnUiInit (req, res, next) { @@ -24,12 +24,12 @@ module.exports.serveSwaggerUI = function serveSwaggerUI (documentUrl, opts = {}) }, function renderSwaggerHtml (req, res) { res.type('html').send(renderHtmlPage('Swagger UI', ` - + `, `
- - - + + + `)) } ] diff --git a/test/index.js b/test/index.js index 77122ef..d813450 100644 --- a/test/index.js +++ b/test/index.js @@ -653,6 +653,26 @@ suite(name, function () { }) }) + test('use a CDN', (done) => { + const app = express() + const oapi = openapi(undefined, { basePath: '/base-path' }) + + app.use(oapi) + + app.get(oapi.routePrefix, oapi.swaggerui({ cdnBaseUrl: 'https://notARealURL' })) + + supertest(app) + .get(oapi.routePrefix) + .expect(200, (err, res) => { + assert(!err, err) + assert(res.text.includes('')) + assert(res.text.includes('')) + assert(res.text.includes('')) + assert(res.text.includes('')) + done() + }) + }) + // Other tests require('./_validate')() require('./_routes')()