From 9ca96199d92168fe221dda9aba56f55520a561d8 Mon Sep 17 00:00:00 2001 From: hutongqing <hutongqing@hnkhzn.com> Date: 星期二, 29 十月 2024 17:30:59 +0800 Subject: [PATCH] 1 --- WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/SwaggerSetup.cs | 39 +++++++++++++++------------------------ 1 files changed, 15 insertions(+), 24 deletions(-) diff --git a/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/SwaggerSetup.cs b/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/SwaggerSetup.cs index d80ac85..2e5a1ce 100644 --- a/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/SwaggerSetup.cs +++ b/WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/SwaggerSetup.cs @@ -20,8 +20,6 @@ /// </summary> public static class SwaggerSetup { - - /// <summary> /// Swagger /// </summary> @@ -32,36 +30,33 @@ if (services == null) throw new ArgumentNullException(nameof(services)); var basePath = AppContext.BaseDirectory; - //var basePath2 = Microsoft.DotNet.PlatformAbstractions.ApplicationEnvironment.ApplicationBasePath; - var ApiName = AppSettings.app(new string[] { "ApiName" }); + var ApiName = AppSettings.Get(new string[] { "ApiName" }); services.AddSwaggerGen(c => { //閬嶅巻鍑哄叏閮ㄧ殑鐗堟湰锛屽仛鏂囨。淇℃伅灞曠ず - typeof(ApiVersions).GetEnumNames().ToList().ForEach(version => + //typeof(ApiVersions).GetEnumNames().ToList().ForEach(version => + //{ + c.SwaggerDoc("v1", new OpenApiInfo { - c.SwaggerDoc(version, new OpenApiInfo - { - Version = version, - Title = $"{ApiName} 鎺ュ彛鏂囨。鈥斺�攞RuntimeInformation.FrameworkDescription}", - Description = $"{ApiName} HTTP API " + version, - //Contact = new OpenApiContact { Name = ApiName, Email = "Blog.Core@xxx.com", Url = new Uri("https://neters.club") }, - //License = new OpenApiLicense { Name = ApiName + " 瀹樻柟鏂囨。", Url = new Uri("http://apk.neters.club/.doc/") } - }); - //c.OrderActionsBy(o => o.RelativePath); + Version = "v1", + Title = $"{ApiName} 鎺ュ彛鏂囨。鈥斺�攞RuntimeInformation.FrameworkDescription}", + Description = $"{ApiName} HTTP API " + "v1" }); + c.OrderActionsBy(o => o.RelativePath); + //}); c.UseInlineDefinitionsForEnums(); try { //杩欎釜灏辨槸鍒氬垰閰嶇疆鐨剎ml鏂囦欢鍚� - //var xmlPath = Path.Combine(basePath, "Blog.Core.xml"); + var xmlPath = Path.Combine(basePath, "WIDESEAWCS_Server.xml"); //榛樿鐨勭浜屼釜鍙傛暟鏄痜alse锛岃繖涓槸controller鐨勬敞閲婏紝璁板緱淇敼 - //c.IncludeXmlComments(xmlPath, true); + c.IncludeXmlComments(xmlPath, true); //杩欎釜灏辨槸Model灞傜殑xml鏂囦欢鍚� - //var xmlModelPath = Path.Combine(basePath, "Blog.Core.Model.xml"); - //c.IncludeXmlComments(xmlModelPath); + var xmlModelPath = Path.Combine(basePath, "WIDESEAWCS_Server.Model.xml"); + c.IncludeXmlComments(xmlModelPath); } catch (Exception ex) { @@ -73,7 +68,7 @@ c.OperationFilter<AppendAuthorizeToSummaryOperationFilter>(); // 鍦╤eader涓坊鍔爐oken锛屼紶閫掑埌鍚庡彴 - //c.OperationFilter<SecurityRequirementsOperationFilter>(); + c.OperationFilter<SecurityRequirementsOperationFilter>(); c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme { @@ -125,11 +120,7 @@ /// <summary> /// V1 鐗堟湰 /// </summary> - V1 = 1, - /// <summary> - /// V2 鐗堟湰 - /// </summary> - V2 = 2, + V1 = 1 } } } -- Gitblit v1.9.3