新增注解文件生成配置

This commit is contained in:
不做码农 2023-02-13 21:41:08 +08:00
parent 2ac2583d1e
commit 723ba3e313
3 changed files with 12 additions and 8 deletions

View File

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

View File

@ -3,6 +3,7 @@
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -2,13 +2,16 @@
<PropertyGroup> <PropertyGroup>
<TargetFramework>net7.0</TargetFramework> <TargetFramework>net7.0</TargetFramework>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DocumentationFile>../ZR.Admin.WebApi/ZRModel.xml</DocumentationFile>
<NoWarn>1701;1702;1591;1570</NoWarn>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="MiniExcel" Version="1.29.0" /> <PackageReference Include="MiniExcel" Version="1.29.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.35" /> <PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.35" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" /> <PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>