Add conditional MapOpenApi for .NET 9.0 or newer

Introduced a preprocessor directive `#if NET9_0_OR_GREATER` to conditionally include the `app.MapOpenApi();` method call. This ensures that the `MapOpenApi` functionality is only executed when the application targets .NET 9.0 or later, maintaining compatibility with earlier .NET versions.
This commit is contained in:
2026-05-30 16:46:27 +02:00
parent c1a10cc0fa
commit 76cfe4dc46

View File

@@ -290,7 +290,9 @@ try
app.UseMiddleware<ExceptionHandlingMiddleware>();
#if NET9_0_OR_GREATER
app.MapOpenApi();
#endif
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment() || (app.IsDevOrDiP() && config.GetValue<bool>("UseSwagger")))