From 057aecee5527c8e3fc86c2dd53b0e6f1c85035d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E5=81=9A=E7=A0=81=E5=86=9C?= <599854767@qq.com> Date: Fri, 3 Dec 2021 21:57:27 +0800 Subject: [PATCH] =?UTF-8?q?swagger=E6=96=B0=E5=A2=9E=E5=8A=A0=E6=8E=88?= =?UTF-8?q?=E6=9D=83jwt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ZR.Admin.WebApi/Startup.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ZR.Admin.WebApi/Startup.cs b/ZR.Admin.WebApi/Startup.cs index d1407f8..1614b35 100644 --- a/ZR.Admin.WebApi/Startup.cs +++ b/ZR.Admin.WebApi/Startup.cs @@ -96,8 +96,17 @@ namespace ZR.Admin.WebApi //添加文档注释 c.IncludeXmlComments(Path.Combine(CurrentEnvironment.ContentRootPath, "ZRAdmin.xml"), true); //} + c.AddSecurityDefinition("Bearer", + new OpenApiSecurityScheme + { + In = ParameterLocation.Header, + Description = "请输入OAuth接口返回的Token,前置Bearer。示例:Bearer {Token}", + Name = "Authorization",//jwt默认的参数名称, + Type = SecuritySchemeType.ApiKey, //指定ApiKey + BearerFormat = "JWT",//标识承载令牌的格式 该信息主要是出于文档目的 + Scheme = JwtBearerDefaults.AuthenticationScheme//授权中要使用的HTTP授权方案的名称 + }); }); - } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.