I\'m trying to add authorization header into SwaggerUI api test. below is my Startup.cs
public void ConfigureServices(IServiceCollection services)
{
Note that some parameter's type has been changed since .Net Core 3.0 as follows:
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
{
Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"",
Name = "Authorization",
In = ParameterLocation.Header,
Type = SecuritySchemeType.ApiKey
});
});
Reference: https://ppolyzos.com/2017/10/30/add-jwt-bearer-authorization-to-swagger-and-asp-net-core/