- 一、引用Nuget程序包
- 二、设置对应都XML文档生成
- 三、相关配置设置
public class SwaggerConfig
{
public static void Register()
{
var thisAssembly = typeof(SwaggerConfig).Assembly;
GlobalConfiguration.Configuration
.EnableSwagger(c =>
{
c.SingleApiVersion("v1", "MyTestDemoPro");
c.IncludeXmlComments(string.Format("{0}/bin/MyTestDemoPro.XML", System.AppDomain.CurrentDomain.BaseDirectory));
c.IncludeXmlComments(string.Format("{0}/bin/Model.XML", System.AppDomain.CurrentDomain.BaseDirectory));
})
.EnableSwaggerUi(c =>
{
});
}
}
- 四、效果
访问地址:http://localhost:9999/swagger/ui/index