feat: integrate Swagger for API documentation

This commit is contained in:
2026-01-31 00:22:30 +01:00
parent 8875060917
commit e81bf53def
2 changed files with 8 additions and 0 deletions

View File

@@ -12,6 +12,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="10.0.2">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="Swashbuckle.AspNetCore" Version="10.1.0" />
</ItemGroup>
<ItemGroup>

View File

@@ -5,6 +5,7 @@ using Microsoft.EntityFrameworkCore;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddOpenApi();
builder.Services.AddSwaggerGen();
builder.Services.AddCors(options =>
{
options.AddDefaultPolicy(policy =>
@@ -30,6 +31,12 @@ var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.MapOpenApi();
app.UseSwagger();
app.UseSwaggerUI(options =>
{
options.SwaggerEndpoint("/openapi/v1.json", "ASTRAIN API");
options.RoutePrefix = "docs";
});
}
// app.UseHttpsRedirection();