1.新建的web項目帶有webapi
2.Nuget包新增Swagger
或者也可以輸入代碼
Install-Package Swashbuckle
3.修改SwaggerConfig,大概108行
c.IncludeXmlComments(GetXmlCommentsPath(thisAssembly.GetName().Name));
增加方法
protected static string GetXmlCommentsPath(string name)
{
return System.String.Format(@"{0}\bin\{1}.xml",System.AppDomain.CurrentDomain.BaseDirectory, name);
}