右键项目- 属性 - 生成 - 勾选XML文档文件
![](https://i-blog.csdnimg.cn/blog_migrate/48322c40eb61e7cd7f2067744777229a.png)
保存后重新运行一下项目,会生成一个XML文件
在ConfigureServices里面需要再配置一段话
![](https://i-blog.csdnimg.cn/blog_migrate/b124065f603c002d3680d7a8976f3802.png)
string xmlFile = AppSetting.GetConfiguration("Startup.Swagger.XmlFiles");
List<string> xmlFiles = xmlFile.CombineList(",");
if (xmlFiles.Any())
{
xmlFiles.ForEach(xmlFile =>
{
if (!string.IsNullOrWhiteSpace(xmlFile))
{
string xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
if (FileHelper.FileExists(xmlPath))
{
options.IncludeXmlComments(xmlPath, true);
}
}
});
}
再次运行就能得到我们想要的weagger接口注释了
![](https://i-blog.csdnimg.cn/blog_migrate/4068ccc5eb7eaa831cf11156ba649165.png)
注:AppSetting、FileHelper是我的帮助类,为了就是获取工程下的XML文件