右键项目- 属性 - 生成 - 勾选XML文档文件

保存后重新运行一下项目,会生成一个XML文件
在ConfigureServices里面需要再配置一段话

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接口注释了

注:AppSetting、FileHelper是我的帮助类,为了就是获取工程下的XML文件