added swagger for automatic API Documentation
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
|
||||
using Serilog;
|
||||
|
||||
@@ -42,6 +43,11 @@ builder.Services.AddSingleton<ISystemStore, SystemStore>();
|
||||
builder.Services.AddHostedService<NetworkCheck>();
|
||||
builder.Services.AddHostedService<DatabaseCheck>();
|
||||
|
||||
// Swagger API-Dokumentation
|
||||
builder.Services.AddSwaggerGen(options =>
|
||||
{
|
||||
options.SwaggerDoc("v1", new OpenApiInfo { Title = "Watcher-Server API", Version = "v1" });
|
||||
});
|
||||
|
||||
// ---------- Konfiguration ----------
|
||||
DotNetEnv.Env.Load();
|
||||
@@ -213,6 +219,8 @@ if (!app.Environment.IsDevelopment())
|
||||
app.UseHttpsRedirection();
|
||||
app.UseRouting();
|
||||
|
||||
app.UseSwagger();
|
||||
|
||||
app.UseAuthentication();
|
||||
app.UseAuthorization();
|
||||
|
||||
@@ -223,4 +231,11 @@ app.MapControllerRoute(
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}"
|
||||
);
|
||||
|
||||
app.MapSwagger();
|
||||
|
||||
app.UseSwaggerUI(options =>
|
||||
{
|
||||
options.SwaggerEndpoint("v1/swagger.json", "Watcher-Server API v1");
|
||||
});
|
||||
|
||||
app.Run();
|
@@ -23,6 +23,7 @@
|
||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.6" />
|
||||
<PackageReference Include="Serilog.AspNetCore" Version="9.0.0" />
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="7.0.0" />
|
||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="9.0.6" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
Reference in New Issue
Block a user