-
-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
serve swagger-ui through the swagger-ui-dist; (#39)
- Loading branch information
1 parent
bee8fc7
commit 05ae846
Showing
19 changed files
with
131 additions
and
360 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,5 @@ yarn.lock | |
|
||
package-lock.json | ||
|
||
static | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# nyc test coverage | ||
.nyc_output | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency files and directories | ||
node_modules | ||
jspm_packages | ||
yarn.lock | ||
|
||
# Optional npm cache directory | ||
.npm | ||
|
||
# Optional REPL history | ||
.node_repl_history | ||
|
||
# mac files | ||
.DS_Store | ||
|
||
# vim swap files | ||
*.swp | ||
|
||
package-lock.json | ||
|
||
# project specific | ||
*.tgz | ||
tap-snapshots | ||
test | ||
.travis.yml | ||
var |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const fs = require('fs') | ||
const fse = require('fs-extra') | ||
const swaggerUiAssetPath = require('swagger-ui-dist').getAbsoluteFSPath() | ||
const resolve = require('path').resolve | ||
|
||
fse.emptyDirSync(resolve('./static')) | ||
|
||
// since the original swagger-ui-dist folder contains non UI files | ||
const filesToCopy = ['favicon-16x16.png', | ||
'favicon-32x32.png', | ||
'index.html', | ||
'oauth2-redirect.html', | ||
'swagger-ui-bundle.js', | ||
'swagger-ui-bundle.js.map', | ||
'swagger-ui-standalone-preset.js', | ||
'swagger-ui-standalone-preset.js.map', | ||
'swagger-ui.css', | ||
'swagger-ui.css.map', | ||
'swagger-ui.js', | ||
'swagger-ui.js.map'] | ||
filesToCopy.forEach(filename => { | ||
fse.copySync(`${swaggerUiAssetPath}/${filename}`, resolve(`./static/${filename}`)) | ||
}) | ||
|
||
const newIndex = fs.readFileSync(resolve('./static/index.html'), 'utf8') | ||
.replace('window.ui = ui', `window.ui = ui | ||
function resolveUrl (url) { | ||
const anchor = document.createElement('a') | ||
anchor.href = url | ||
return anchor.href | ||
}`) | ||
.replace( | ||
/url: "(.*)",/, | ||
`url: resolveUrl('./json'), | ||
oauth2RedirectUrl: resolveUrl('./oauth2-redirect.html'),` | ||
) | ||
|
||
fse.writeFileSync(resolve('./static/index.html'), newIndex) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.