From 08f4a0877b8929dafdb8b718f6f71d156738ce8e Mon Sep 17 00:00:00 2001 From: hang <872297557@qq.com> Date: Tue, 15 Oct 2024 09:22:15 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B8=85=E7=90=86swagger=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../_ServiceExtensions/SwaggerSetup.cs | 50 +++++++------------ 1 file changed, 18 insertions(+), 32 deletions(-) diff --git a/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs b/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs index 7ef4bce72..1632056c7 100644 --- a/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs +++ b/IRaCIS.Core.API/_ServiceExtensions/SwaggerSetup.cs @@ -74,6 +74,15 @@ public static class SwaggerSetup return versions.Any(v => v.ToString() == docName); }); + + //添加注释 + var basePath = AppContext.BaseDirectory; + var xmlPath1 = Path.Combine(basePath, "IRaCIS.Core.Application.xml"); + var xmlPath2 = Path.Combine(basePath, "IRaCIS.Core.API.xml"); + options.IncludeXmlComments(xmlPath1, true); + options.IncludeXmlComments(xmlPath2, true); + + // 在header中添加token,传递到后台 options.OperationFilter(); @@ -87,17 +96,6 @@ public static class SwaggerSetup //Type = "apiKey" }); - //添加注释 - var basePath = AppContext.BaseDirectory; - var xmlPath1 = Path.Combine(basePath, "IRaCIS.Core.Application.xml"); - var xmlPath2 = Path.Combine(basePath, "IRaCIS.Core.API.xml"); - options.IncludeXmlComments(xmlPath1, true); - options.IncludeXmlComments(xmlPath2, true); - - // 在header中添加token,传递到后台 - options.OperationFilter(); - - //// 添加登录按钮 //options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme() //{ @@ -140,19 +138,7 @@ public static class SwaggerSetup return versions.Any(v => v.ToString() == docName); }); - options.OperationFilter(); - - - // 添加登录按钮 - options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme() - { - Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", - Name = "Authorization", - - //In = "header", - //Type = "apiKey" - }); - + //添加注释 var basePath = AppContext.BaseDirectory; var xmlPath1 = Path.Combine(basePath, "IRaCIS.Core.Application.xml"); @@ -164,15 +150,15 @@ public static class SwaggerSetup options.OperationFilter(); - //// 添加登录按钮 - //options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme() - //{ - // Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", - // Name = "Authorization", + // 添加登录按钮 + options.AddSecurityDefinition("bearerAuth", new OpenApiSecurityScheme() + { + Description = "JWT Authorization header using the Bearer scheme. Example: \"Authorization: Bearer {token}\"", + Name = "Authorization", + //In = "header", + //Type = "apiKey" + }); - // //In = "header", - // //Type = "apiKey" - //}); }); }