tnblog
首页
视频
资源
登录

ABP Xml为Swagger接口页添加详细注释

4235人阅读 2021/8/31 18:41 总访问:1056743 评论:0 收藏:0 手机
分类: ABP
  1. 我们选中我们Application层的项目,右键属性,勾选为Xml生成文档,如下图所示。

  2. 在你的 项目名.Web.Host startup目录下,找到StartUp.cs类,在它的ConfigureServices方法中,找到services.AddSwaggerGen 方法,将生成的Xml配置进去。核心代码如下:


    方法1.// Set the comments path for the Swagger JSON and UI.

    //路径,路径为XML文档文件路径去玩后的名称

     var xmlFile = @"SCBC.SMES.Application.xml";

     var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);

     options.IncludeXmlComments(xmlPath,true);

    方法二.// 为 Swagger JSON and UI设置xml文档注释路径

      var basePath = Path.GetDirectoryName(typeof(Program).Assembly.Location);//获取应用程序所在目录(绝对,不受工作目录影响,建议采用此方法获取路径)

     var xmlPath1 = Path.Combine(basePath, "Myprop.Application.xml");//这个就是应用层配置的xml文件名

     options.IncludeXmlComments(xmlPath1, true);

     var xmlPath2 = Path.Combine(basePath, "Myprop.Core.xml");//这个就是给领域层配置的xml文件名

 options.IncludeXmlComments(xmlPath2, true);



评价
没有个性,不需要签名
排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
欢迎加群交流技术