Swashbuckle use Newtonsoft and use XMl-Comments

This commit is contained in:
2025-05-26 02:15:59 +02:00
parent 59ade47bd7
commit 86642b5d28
3 changed files with 11 additions and 2 deletions

View File

@ -5,6 +5,8 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);1591</NoWarn>
</PropertyGroup>
<ItemGroup>
@ -16,6 +18,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="8.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="8.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="8.1.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="8.1.2" />

View File

@ -22,7 +22,12 @@ public class Api
});
builder.Services.AddCors(options => options.AddPolicy("AllowAll", p => p.AllowAnyOrigin().AllowAnyMethod()));
builder.Services.AddSwaggerGen();
builder.Services.AddSwaggerGenNewtonsoftSupport();
builder.Services.AddSwaggerGen(opt =>
{
var xmlFilename = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml";
opt.IncludeXmlComments(Path.Combine(AppContext.BaseDirectory, xmlFilename));
});
builder.Services.AddDbContext<Context>(options => options.UseSqlite(builder.Configuration.GetConnectionString("DefaultConnection"), optionsBuilder => optionsBuilder.MigrationsAssembly(Assembly.GetAssembly(GetType())!)));