Nuget package"Swagger-Net" swagger-ui default ui page 修改 Asp.net mvc5
Nuget package"Swagger-Net" swagger-ui default ui page Modification In Asp.net mvc5
我在 asp.net mvc5 中有一个项目并添加了 Swagger-Net NuGet 包 (https://github.com/heldersepu/Swagger-Net)
的 swagger
这里我需要删除红色矩形内的 HTML 部分
这是 Swagger-Net
提供的默认 UI
您可以将 index.html 完全替换为您自己的,或者使用 CSS 来隐藏 div。
要替换 index.html,请执行以下操作。
httpConfiguration
.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi(c =>
{
c.CustomAsset("index", yourAssembly, "YourWebApiProject.SwaggerExtensions.index.html");
});
替换整个 index.html 文件可能有点矫枉过正,这意味着您需要在 Swagger 更新它时维护它。所以,如果你只想隐藏块,你可以使用 CSS 来实现。
像这样指定自定义样式表:
httpConfiguration
.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi(c =>
{
c.InjectStylesheet(containingAssembly, "Swagger-Net.Dummy.SwaggerExtensions.testStyles1.css");
});
然后在您的自定义样式表 (testStyles1.css) 中输入:
information-container {
display: none;
}
有关这两个选项的详细信息,请参阅 here。
我在 asp.net mvc5 中有一个项目并添加了 Swagger-Net NuGet 包 (https://github.com/heldersepu/Swagger-Net)
的 swagger这里我需要删除红色矩形内的 HTML 部分 这是 Swagger-Net
提供的默认 UI您可以将 index.html 完全替换为您自己的,或者使用 CSS 来隐藏 div。
要替换 index.html,请执行以下操作。
httpConfiguration
.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi(c =>
{
c.CustomAsset("index", yourAssembly, "YourWebApiProject.SwaggerExtensions.index.html");
});
替换整个 index.html 文件可能有点矫枉过正,这意味着您需要在 Swagger 更新它时维护它。所以,如果你只想隐藏块,你可以使用 CSS 来实现。
像这样指定自定义样式表:
httpConfiguration
.EnableSwagger(c => c.SingleApiVersion("v1", "A title for your API"))
.EnableSwaggerUi(c =>
{
c.InjectStylesheet(containingAssembly, "Swagger-Net.Dummy.SwaggerExtensions.testStyles1.css");
});
然后在您的自定义样式表 (testStyles1.css) 中输入:
information-container {
display: none;
}
有关这两个选项的详细信息,请参阅 here。