Merge pull request #32406 from dotnet/main

Merge to Live
pull/32426/head
Rick Anderson 2024-04-25 11:02:00 -10:00 committed by GitHub
commit 1489107ed7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 14 deletions

View File

@ -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<GreeterService>();
app.Run();

View File

@ -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<GreeterService>();
app.Run();

View File

@ -70,7 +70,7 @@ The Cookie Policy Middleware setting for `MinimumSameSitePolicy` can affect the
To create a cookie holding user information, construct a <xref:System.Security.Claims.ClaimsPrincipal>. The user information is serialized and stored in the cookie.
Create a <xref:System.Security.Claims.ClaimsIdentity> with any required <xref:System.Security.Claims.Claim>s and call <xref:Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignInAsync*> to sign in the user:
Create a <xref:System.Security.Claims.ClaimsIdentity> with any required <xref:System.Security.Claims.Claim>s and call <xref:Microsoft.AspNetCore.Authentication.AuthenticationHttpContextExtensions.SignInAsync*> 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)]

View File

@ -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:

View File

@ -23,11 +23,14 @@ public static class Program
// </snippet_MiddlewareJsonV2>
// <snippet_MiddlewareRoutePrefix>
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;
});
}
// </snippet_MiddlewareRoutePrefix>
}

View File

@ -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
{