Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save TerenceCLZhang/d528e8567a17c1d188efd3b72e1ab4d9 to your computer and use it in GitHub Desktop.

Select an option

Save TerenceCLZhang/d528e8567a17c1d188efd3b72e1ab4d9 to your computer and use it in GitHub Desktop.
builder.Services.AddSwaggerGen(options =>
{
options.AddSecurityDefinition(
"Bearer",
new OpenApiSecurityScheme
{
In = ParameterLocation.Header,
Description = "Please enter a valid token.",
Name = "Authorization",
Type = SecuritySchemeType.Http,
BearerFormat = "JWT",
Scheme = "Bearer",
}
);
options.AddSecurityRequirement(document =>
new() { [new OpenApiSecuritySchemeReference("Bearer", document)] = [] }
);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment