Swagger 之 Jwt验证

实现扩展

public static void AddBearerInput(this SwaggerGenOptions c)
{
    c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme()
    {
        Description = "在下框中输入请求头中需要添加Jwt授权Token:Bearer Token",
        Name = "Authorization",
        In = ParameterLocation.Header,
        Type = SecuritySchemeType.ApiKey,
        BearerFormat = "JWT",
        Scheme = "Bearer"
    });
    
    c.AddSecurityRequirement(new OpenApiSecurityRequirement
    {
        {
            new OpenApiSecurityScheme{
                Reference = new OpenApiReference {
                    Type = ReferenceType.SecurityScheme,
                    Id = "Bearer"}
                   },
            System.Array.Empty<string>()
        }
    });
}

效果

Swagger 之 Jwt验证

Swagger 之 Jwt验证

上一篇:React使用wangeditor富文本编辑器--@types依赖包找不到、404


下一篇:后端返回的文件下载并修改名称