swagger新增查看Model注解

This commit is contained in:
不做码农
2023-02-13 21:40:38 +08:00
parent 47c3e41eb1
commit 2ac2583d1e
4 changed files with 13 additions and 5 deletions

View File

@@ -38,7 +38,7 @@ namespace ZR.Admin.WebApi.Extensions
public static void AddSwaggerConfig(this IServiceCollection services)
{
if (services == null) throw new ArgumentNullException(nameof(services));
//IWebHostEnvironment hostEnvironment = App.GetRequiredService<IWebHostEnvironment>();
IWebHostEnvironment hostEnvironment = App.GetRequiredService<IWebHostEnvironment>();
services.AddSwaggerGen(c =>
{
@@ -50,8 +50,11 @@ namespace ZR.Admin.WebApi.Extensions
});
try
{
var tempPath = hostEnvironment.ContentRootPath;
//添加文档注释
c.IncludeXmlComments("ZRAdmin.xml", true);
c.IncludeXmlComments(Path.Combine(tempPath, "ZRAdmin.xml"), true);
c.IncludeXmlComments(Path.Combine(tempPath, "ZRModel.xml"), true);
//c.IncludeXmlComments(Path.Combine(Directory.GetParent(tempPath).FullName, "ZR.Model", "ZRModel.xml"), true);
}
catch (Exception ex)
{