From 6d1d165ababa073eb9d0909884c85791f00d0288 Mon Sep 17 00:00:00 2001 From: Daniel Triendl Date: Thu, 9 Apr 2026 14:10:02 +0200 Subject: [PATCH] Added OpenAPI --- server/src/CPATapi.Server/.gitignore | 1 + server/src/CPATapi.Server/CPATapi.Server.csproj | 9 ++++++++- server/src/CPATapi.Server/Program.cs | 8 ++++++++ server/src/CPATapi.Server/Properties/launchSettings.json | 4 ++-- 4 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 server/src/CPATapi.Server/.gitignore diff --git a/server/src/CPATapi.Server/.gitignore b/server/src/CPATapi.Server/.gitignore new file mode 100644 index 0000000..db54190 --- /dev/null +++ b/server/src/CPATapi.Server/.gitignore @@ -0,0 +1 @@ +CPATapi.Server.json diff --git a/server/src/CPATapi.Server/CPATapi.Server.csproj b/server/src/CPATapi.Server/CPATapi.Server.csproj index 9ce8ef0..0e88536 100644 --- a/server/src/CPATapi.Server/CPATapi.Server.csproj +++ b/server/src/CPATapi.Server/CPATapi.Server.csproj @@ -7,16 +7,23 @@ a7b40068-a2f6-4c63-bbd9-0fd346908fb0 Linux ..\.. + . + 9.4.0 + + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + - diff --git a/server/src/CPATapi.Server/Program.cs b/server/src/CPATapi.Server/Program.cs index d7ea583..7116cf3 100644 --- a/server/src/CPATapi.Server/Program.cs +++ b/server/src/CPATapi.Server/Program.cs @@ -14,6 +14,8 @@ builder.Services.AddSerilog(config => .WriteTo.Console(); }); +builder.Services.AddOpenApi(); + builder.Services.AddTransient(); builder.Services.AddTransient(); @@ -28,6 +30,12 @@ if (app.Environment.IsDevelopment()) app.UseDeveloperExceptionPage(); } +app.MapOpenApi(); +app.UseSwaggerUI(options => +{ + options.SwaggerEndpoint("/openapi/v1.json", "v1"); +}); + app.UseAuthorization(); app.MapControllers(); diff --git a/server/src/CPATapi.Server/Properties/launchSettings.json b/server/src/CPATapi.Server/Properties/launchSettings.json index 3c16350..a552761 100644 --- a/server/src/CPATapi.Server/Properties/launchSettings.json +++ b/server/src/CPATapi.Server/Properties/launchSettings.json @@ -3,7 +3,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "contact", + "launchUrl": "swagger/index.html", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -37,4 +37,4 @@ "sslPort": 0 } } -} \ No newline at end of file +}