Swagger / Swashbuckle授权。默认情况下检查的范围

问题描述 投票:8回答:1

是否有可能在asp.net Core 2.0 Web API的Swashbuckle UI上设置默认选中的身份验证范围复选框?

我使用“ openid”作用域,我希望每次都对其进行检查。

谢谢。

enter image description here

swagger openid asp.net-core-webapi swashbuckle authorize
1个回答
0
投票

这里是现代浏览器的hacktastic解决方法,可以将其注入index.html

function checkScopes(container) {
  const inputNodes = container.querySelectorAll(".scopes input");
  for (const checkbox of inputNodes) {
    checkbox.checked = true;
    console.log('Scope checkbox modified: ' + checkbox.id);
  }
}

function watchDOM() {
  // target element that we will observe
  const target = document.body;

  // subscriber function
  function subscriber(mutations) {
    mutations.forEach((mutation) => {
      if (mutation.target.className == 'auth-wrapper') {
        checkScopes(mutation.target);
      }
    });
  }

  // instantiating observer
  const observer = new MutationObserver(subscriber);

  // observing target
  observer.observe(target, { childList: true, subtree: true });
};

document.addEventListener('DOMContentLoaded', watchDOM);
© www.soinside.com 2019 - 2024. All rights reserved.