wuyubing

1,通过NuGet引用Swashbuckle

2,打开项目属性-->生成,勾选XML文档文件,保存

3,找到项目App_Start文件夹下WebApiConfig查找GetXmlCommentsPath然后去掉注释再加一个model的xml展示如图

 

 

 

4,创建方法GetXmlCommentsPath

private static string GetModelXmlCommentsPath()
        {
            return string.Format("{0}/bin/WSR.Models.xml", System.AppDomain.CurrentDomain.BaseDirectory);
        }

        private static string GetXmlCommentsPath()
        {
            return string.Format("{0}/bin/WSR.WebApi.xml", System.AppDomain.CurrentDomain.BaseDirectory) ;
        }

 

5,大功告成,运行项目访问路径http://localhost:61914/swagger/ui/index(61714是项目运行默认的端口号根据自己的项目不是固定)

 

分类:

技术点:

相关文章:

  • 2021-12-10
  • 2021-05-17
  • 2021-10-30
  • 2022-12-23
  • 2022-12-23
  • 2021-08-04
  • 2022-12-23
猜你喜欢
  • 2021-06-24
  • 2021-11-20
  • 2022-12-23
  • 2022-01-14
  • 2022-12-23
  • 2022-12-23
  • 2021-10-17
相关资源
相似解决方案