Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build(deps-dev): Bump swagger-ui-dist from 5.10.5 to 5.11.2 #122

Merged
merged 2 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 27 additions & 6 deletions lib/swagger-initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,26 @@ function swaggerInitializer (opts) {
const logoData = `data:${opts.logo.type};base64,${logoBase64}`

return `window.onload = function () {
function waitForElement(selector) {
return new Promise(resolve => {
if (document.querySelector(selector)) {
return resolve(document.querySelector(selector));
}

const observer = new MutationObserver(mutations => {
if (document.querySelector(selector)) {
observer.disconnect();
resolve(document.querySelector(selector));
}
});

// If you get "parameter 1 is not of type 'Node'" error, see https://stackoverflow.com/a/77855838/492336
observer.observe(document.body, {
childList: true,
subtree: true
});
});
}
function resolveUrl(url) {
const anchor = document.createElement('a')
anchor.href = url
Expand Down Expand Up @@ -35,12 +55,13 @@ function swaggerInitializer (opts) {
const logoData = '${logoData}'

if (logoData && resConfig.layout === 'StandaloneLayout') {
const link = document.querySelector('#swagger-ui > section > div.topbar > div > div > a')
const img = document.createElement('img')
img.height = 40
img.src = logoData
link.innerHTML = ''
link.appendChild(img)
waitForElement('#swagger-ui > section > div.topbar > div > div > a').then((link) => {
const img = document.createElement('img')
img.height = 40
img.src = logoData
link.innerHTML = ''
link.appendChild(img)
})
}

ui.initOAuth(${serialize(opts.initOAuth)})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"fs-extra": "^11.0.0",
"qs": "^6.11.0",
"standard": "^17.0.0",
"swagger-ui-dist": "5.10.5",
"swagger-ui-dist": "5.11.2",
"tap": "^18.6.1",
"tsd": "^0.30.0"
},
Expand Down
Loading