hutongqing
2024-10-25 9eeca6aa905cffea1c95d965b4790fbd20ce2275
WIDESEAWCS_Server/WIDESEAWCS_Core/Extensions/SwaggerSetup.cs
@@ -20,8 +20,6 @@
    /// </summary>
    public static class SwaggerSetup
    {
        /// <summary>
        /// Swagger
        /// </summary>
@@ -32,8 +30,7 @@
            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 =>
            {
@@ -45,23 +42,21 @@
                        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);
                    c.OrderActionsBy(o => o.RelativePath);
                });
                c.UseInlineDefinitionsForEnums();
                try
                {
                    //这个就是刚刚配置的xml文件名
                    //var xmlPath = Path.Combine(basePath, "Blog.Core.xml");
                    var xmlPath = Path.Combine(basePath, "WIDESEAWCS_Server.xml");
                    //默认的第二个参数是false,这个是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>();
                // 在header中添加token,传递到后台
                //c.OperationFilter<SecurityRequirementsOperationFilter>();
                c.OperationFilter<SecurityRequirementsOperationFilter>();
                c.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme
                {