接口文档工具 - Swashbuckle

Swashbuckle

用来生成 Web Api 接口文档

 

第一步: 安装

Install-Package Swashbuckle

 

第二步: 在项目属性中启用生成 xml 文档

 

第三步: 配置 SwaggerConfig.cs

public class SwaggerConfig
{
    public static void Register()
    {
        var thisAssembly = typeof(SwaggerConfig).Assembly;

        GlobalConfiguration.Configuration 
            .EnableSwagger(c =>
                {
                    c.SingleApiVersion("v1", "WebApplication7");
                    c.IncludeXmlComments(GetXmlCommentsPath());
                })
            .EnableSwaggerUi(c =>
                {
                });
    }

    protected static string GetXmlCommentsPath()
    {
        return System.String.Format(@"{0}\bin\WebApplication7.xml", System.AppDomain.CurrentDomain.BaseDirectory);
    }
}

 

第四步: 浏览地址

http://localhost:10000/swagger/ui/index

posted @ 2017-06-28 17:21  `Laimic  阅读(338)  评论(0)    收藏  举报