Search code examples
asp.net-web-apiswagger-uiswashbuckle

How to replace Swagger UI header logo in Swashbuckle


I am using the Swashbuckle package for WebAPI and am attempting to customize the look and feel of the swagger UI default page. I would like to customize the default swagger logo/header. I have added the following to SwaggerConfig:

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

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?


Solution

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