From aa644872f38acc34c66f0065e74243f61be7b118 Mon Sep 17 00:00:00 2001 From: martincostello Date: Thu, 13 Jun 2024 13:47:22 +0100 Subject: [PATCH] Use OpenAPI package Migrate from NSwag to the new Microsoft.AspNetCore.OpenApi NuGet package. --- src/TodoApp/Program.cs | 13 ++++++++----- src/TodoApp/TodoApp.csproj | 2 +- src/TodoApp/wwwroot/swagger-ui/index.html | 2 +- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/TodoApp/Program.cs b/src/TodoApp/Program.cs index 355b7b72..b9871c4b 100644 --- a/src/TodoApp/Program.cs +++ b/src/TodoApp/Program.cs @@ -17,11 +17,14 @@ builder.Services.AddRazorPages(); // Configure OpenAPI documentation for the Todo API -builder.Services.AddEndpointsApiExplorer(); -builder.Services.AddOpenApiDocument(options => +builder.Services.AddOpenApi(options => { - options.Title = "Todo API"; - options.Version = "v1"; + options.UseTransformer((document, _, _) => + { + document.Info.Title = "Todo API"; + document.Info.Version = "v1"; + return Task.CompletedTask; + }); }); if (string.Equals(builder.Configuration["CODESPACES"], "true", StringComparison.OrdinalIgnoreCase)) @@ -57,7 +60,7 @@ app.UseAuthorization(); // Add endpoint for OpenAPI -app.UseOpenApi(); +app.MapOpenApi(); // Add the HTTP endpoints app.MapAuthenticationRoutes(); diff --git a/src/TodoApp/TodoApp.csproj b/src/TodoApp/TodoApp.csproj index 5e30c5d9..5522c635 100644 --- a/src/TodoApp/TodoApp.csproj +++ b/src/TodoApp/TodoApp.csproj @@ -11,9 +11,9 @@ + - diff --git a/src/TodoApp/wwwroot/swagger-ui/index.html b/src/TodoApp/wwwroot/swagger-ui/index.html index f74da4ba..eea5b38b 100644 --- a/src/TodoApp/wwwroot/swagger-ui/index.html +++ b/src/TodoApp/wwwroot/swagger-ui/index.html @@ -32,7 +32,7 @@