如何在Swashbuckle中替换Swagger UI标头徽标 [英] How to replace Swagger UI header logo in Swashbuckle

查看:148
本文介绍了如何在Swashbuckle中替换Swagger UI标头徽标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Swashbuckle软件包用于WebAPI,并尝试自定义swagger ui默认页面的外观.我想自定义默认的招摇徽标/标题.我已将以下内容添加到SwaggerConfig

  .EnableSwaggerUi(c =>{c.InjectJavaScript(thisAssembly,typeof(SwaggerConfig).Namespace +".SwaggerExtensions.custom-js.js");} 

custom-js.js的内容如下:

  $(#logo").replaceWith(< span id = \" test \> test</span&";) 

这在大多数情况下都有效,但视觉效果有点刺耳,因为页面加载时默认的swagger标头可见,并且在短暂的延迟后,下面的jquery出现了,并且#logo元素的内容已更新

有没有一种方法可以避免这种情况,从而使jQuery作为初始加载/渲染的一部分而插入,并且看起来是无缝的?

解决方案

我最终基于

The contents of custom-js.js are as follows:

$("#logo").replaceWith("<span id=\"test\">test</span>");

This works for the most part but the visual is a bit jarring, in that the default swagger header is visible while the page loads and after a brief delay the jquery below kicks and the content of the #logo element is updated

Is there a way to avoid this so that the jquery kicks in as part of the initial load/render and it appears seamless?

解决方案

I ended up adding a new "index.html" based off this version instead of trying to modify the behavior of the default generated one

这篇关于如何在Swashbuckle中替换Swagger UI标头徽标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆