WebAPI纯净版中增加Swagger

WebAPI纯净版的基础上

  • 添加nuget包   a). Swashbuckle    b). Swagger.Net.UI

  • 取消文件SwaggerConfig.cs中 c.IncludeXmlComments(GetXmlCommentsPath());的注释
  • 并在此类中添加方法:GetXmlCommentsPath()
1 private static string GetXmlCommentsPath()
2         {
3             return string.Format(@"{0}\bin\WebApi.XML", AppDomain.CurrentDomain.BaseDirectory);
4         }

  • bin\WebApi.XML这个路径的由来:

  • 注释掉SwaggerNet.cs文件中的部分代码,见下图

  • 运行工程:

猜你喜欢

转载自www.cnblogs.com/ErricShih/p/10333136.html