From 4520b6a46ed446469b7b38f241265fda36e7b7d5 Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Thu, 25 Apr 2024 13:28:23 -0700 Subject: [PATCH 1/6] NSwag 14 supports only v3 of Swagger UI spec (#32400) --- aspnetcore/tutorials/getting-started-with-NSwag.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/tutorials/getting-started-with-NSwag.md b/aspnetcore/tutorials/getting-started-with-NSwag.md index 257913dc98..92459e3c5b 100644 --- a/aspnetcore/tutorials/getting-started-with-NSwag.md +++ b/aspnetcore/tutorials/getting-started-with-NSwag.md @@ -29,7 +29,7 @@ Install NSwag to: * Serve the Swagger UI to browse and test the web API. * Serve the Redoc to add API documentation for the Web API. -To use the [NSwag](https://github.com/RicoSuter/NSwag) ASP.NET Core middleware, install the [NSwag.AspNetCore](https://www.nuget.org/packages/NSwag.AspNetCore/) NuGet package. This package contains the middleware to generate and serve the Swagger specification, Swagger UI (v2 and v3), and [ReDoc UI](https://github.com/Rebilly/ReDoc). +To use the [NSwag](https://github.com/RicoSuter/NSwag) ASP.NET Core middleware, install the [NSwag.AspNetCore](https://www.nuget.org/packages/NSwag.AspNetCore/) NuGet package. This package contains the middleware to generate and serve the Swagger specification, Swagger UI (v2 and v3), and [ReDoc UI](https://github.com/Rebilly/ReDoc). NSwag 14 supports only v3 of the Swagger UI spec. Use one of the following approaches to install the NSwag NuGet package: From e8192ed48a44738f5f5186f60542180a78aa57cc Mon Sep 17 00:00:00 2001 From: Tom Dykstra Date: Thu, 25 Apr 2024 13:35:49 -0700 Subject: [PATCH 2/6] Note location of SignInAsync (#32401) --- aspnetcore/security/authentication/cookie.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/security/authentication/cookie.md b/aspnetcore/security/authentication/cookie.md index cf0beb6f38..4b47bb96db 100644 --- a/aspnetcore/security/authentication/cookie.md +++ b/aspnetcore/security/authentication/cookie.md @@ -70,7 +70,7 @@ The Cookie Policy Middleware setting for `MinimumSameSitePolicy` can affect the To create a cookie holding user information, construct a . The user information is serialized and stored in the cookie. -Create a with any required s and call to sign in the user: +Create a with any required s and call to sign in the user. `Login.cshtml.cs` in the sample app contains the following code: [!code-csharp[](cookie/samples/6.x/CookieSample/Pages/Account/Login.cshtml.cs?name=snippet1&highlight=22-59)] From 0a5c1dacb70d2740d9e2c51dfd93dd2e858d9464 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 25 Apr 2024 13:47:26 -0700 Subject: [PATCH 3/6] Move `UseSwaggerUi3` call inside IsDevelopment block (#32405) --- aspnetcore/web-api/http-repl/samples/SwaggerApp/Startup.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/web-api/http-repl/samples/SwaggerApp/Startup.cs b/aspnetcore/web-api/http-repl/samples/SwaggerApp/Startup.cs index 472651a805..7e2fb45d5e 100644 --- a/aspnetcore/web-api/http-repl/samples/SwaggerApp/Startup.cs +++ b/aspnetcore/web-api/http-repl/samples/SwaggerApp/Startup.cs @@ -32,11 +32,11 @@ namespace SwaggerApp public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseOpenApi(); - app.UseSwaggerUi3(); if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); + app.UseSwaggerUi3(); } else { From 1049a17f2ddec9f227a7b364e2791de2fa099edf Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 25 Apr 2024 13:47:38 -0700 Subject: [PATCH 4/6] Add IsDevelopment guard to Swagger UI in snipppets (#32404) --- .../samples/6.x/SwashbuckleSample/Snippets/Program.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/6.x/SwashbuckleSample/Snippets/Program.cs b/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/6.x/SwashbuckleSample/Snippets/Program.cs index 76f45ead14..76c8f1b0c2 100644 --- a/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/6.x/SwashbuckleSample/Snippets/Program.cs +++ b/aspnetcore/tutorials/web-api-help-pages-using-swagger/samples/6.x/SwashbuckleSample/Snippets/Program.cs @@ -23,11 +23,14 @@ public static class Program // // - app.UseSwaggerUI(options => + if (builder.Environment.IsDevelopment()) { - options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); - options.RoutePrefix = string.Empty; - }); + app.UseSwaggerUI(options => + { + options.SwaggerEndpoint("/swagger/v1/swagger.json", "v1"); + options.RoutePrefix = string.Empty; + }); + } // } From 1c96dd8a4177d79fbb34fa15f048ef1c9d239d6e Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 25 Apr 2024 13:47:47 -0700 Subject: [PATCH 5/6] Add IsDevelopment check to Swagger UI in JSON transcoding docs (pt. 2) (#32403) --- aspnetcore/grpc/json-transcoding-binding/Program.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/aspnetcore/grpc/json-transcoding-binding/Program.cs b/aspnetcore/grpc/json-transcoding-binding/Program.cs index b7fa23db76..504cad5172 100644 --- a/aspnetcore/grpc/json-transcoding-binding/Program.cs +++ b/aspnetcore/grpc/json-transcoding-binding/Program.cs @@ -10,10 +10,13 @@ builder.Services.AddSwaggerGen(c => var app = builder.Build(); app.UseSwagger(); -app.UseSwaggerUI(c => +if (app.Environment.IsDevelopment()) { - c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); -}); + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); + }); +} app.MapGrpcService(); app.Run(); From 0a9bc7618aff73b615afc3ac42243c5e97c56bc6 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 25 Apr 2024 13:47:56 -0700 Subject: [PATCH 6/6] Add IsDevelopment guard to Swagger UI in JSON transcoding docs (#32402) --- aspnetcore/grpc/json-transcoding-openapi/Program2.cs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/aspnetcore/grpc/json-transcoding-openapi/Program2.cs b/aspnetcore/grpc/json-transcoding-openapi/Program2.cs index 1ccc96856c..b41abc57b4 100644 --- a/aspnetcore/grpc/json-transcoding-openapi/Program2.cs +++ b/aspnetcore/grpc/json-transcoding-openapi/Program2.cs @@ -15,10 +15,13 @@ builder.Services.AddSwaggerGen(c => var app = builder.Build(); app.UseSwagger(); -app.UseSwaggerUI(c => -{ - c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); -}); +if (app.Environment.IsDevelopment()) +{ + app.UseSwaggerUI(c => + { + c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); + }); +} app.MapGrpcService(); app.Run();