Reputation: 589
I am having a project in asp.net mvc5 and added swagger which Swagger-Net NuGet package (https://github.com/heldersepu/Swagger-Net)
and here I need to remove HTML section which is inside of red rectangle this is default UI provided by Swagger-Net
Upvotes: 1
Views: 348
Reputation: 1286
You could either replace index.html with your own entirely or use CSS to hide the div.
To replace index.html, do something like this.
httpConfiguration
.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi(c =>
{
c.CustomAsset("index", yourAssembly, "YourWebApiProject.SwaggerExtensions.index.html");
});
Replacing the entire index.html file may be a bit of an overkill for this and will mean you need to maintain this as Swagger updates it. So, if you wanted to just hide the block you could do that with CSS.
Specify a custom stylesheet like so:
httpConfiguration
.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi(c =>
{
c.InjectStylesheet(containingAssembly, "Swagger-Net.Dummy.SwaggerExtensions.testStyles1.css");
});
and then in your custom stylesheet (testStyles1.css) put:
information-container {
display: none;
}
See here for more information about both options.
Upvotes: 2