diff --git a/pkg/api/templates/swagger.html b/pkg/api/templates/swagger.html index 27a9634a..eebb7ded 100644 --- a/pkg/api/templates/swagger.html +++ b/pkg/api/templates/swagger.html @@ -31,12 +31,29 @@ ], layout: "StandaloneLayout", onComplete: function() { - const currentScheme = window.location.protocol.slice(0, -1); - const schemeSelect = document.querySelector('.scheme-container select'); - if (schemeSelect) { - schemeSelect.value = currentScheme; - schemeSelect.dispatchEvent(new Event('change')); - } + setTimeout(function() { + const currentScheme = window.location.protocol.slice(0, -1); + const schemeSelect = document.querySelector('.scheme-container select'); + if (schemeSelect) { + schemeSelect.value = currentScheme; + schemeSelect.dispatchEvent(new Event('change')); + } + }, 100); // Small delay to ensure UI is fully rendered + + // Add this after the setTimeout in the onComplete function + const observer = new MutationObserver(function(mutations) { + mutations.forEach(function(mutation) { + if (mutation.type === 'childList' && mutation.addedNodes.length > 0) { + const schemeSelect = document.querySelector('.scheme-container select'); + if (schemeSelect && schemeSelect.value !== currentScheme) { + schemeSelect.value = currentScheme; + schemeSelect.dispatchEvent(new Event('change')); + } + } + }); + }); + + observer.observe(document.body, { childList: true, subtree: true }); } }); }