diff --git a/Admin.NET/Admin.NET.Application/Configuration/Swagger.json b/Admin.NET/Admin.NET.Application/Configuration/Swagger.json index d59a3d4c..9273013b 100644 --- a/Admin.NET/Admin.NET.Application/Configuration/Swagger.json +++ b/Admin.NET/Admin.NET.Application/Configuration/Swagger.json @@ -1,4 +1,4 @@ -{ +{ "$schema": "https://gitee.com/dotnetchina/Furion/raw/v4/schemas/v4/furion-schema.json", "SpecificationDocumentSettings": { @@ -22,6 +22,14 @@ "DefaultGroupName": "Default", // 默认分组名 "DocExpansionState": "List", // List、Full、None "EnableAllGroups": true, + //"ServerDir": "t490", // Nginx 有二级目录的,把二级目录设置在这里,并且开启 Servers的选择列表 + "HideServers": false, + "Servers": [ + { + "Url": "https://ip/二级", + "Description": "发布地址名称" + } + ], "LoginInfo": { "Enabled": true, // 是否开启Swagger登录 "CheckUrl": "/api/swagger/checkUrl", diff --git a/Admin.NET/Admin.NET.Web.Core/Startup.cs b/Admin.NET/Admin.NET.Web.Core/Startup.cs index 5e2876f6..dddde9c9 100644 --- a/Admin.NET/Admin.NET.Web.Core/Startup.cs +++ b/Admin.NET/Admin.NET.Web.Core/Startup.cs @@ -356,9 +356,13 @@ public class Startup : AppStartup app.UseKnife4UI(options => { options.RoutePrefix = "kapi"; + options.ConfigObject.DisplayOperationId = true; + options.ConfigObject.DisplayRequestDuration = true; foreach (var groupInfo in SpecificationDocumentBuilder.GetOpenApiGroups()) { - options.SwaggerEndpoint("/" + groupInfo.RouteTemplate, groupInfo.Title); + // 这里因为兼容 Nginx 使用二级目录转发的情况 + // Nginx 配置了二级域名转发,还要使用 Swagger.json 的 ServerDir 配置项 + options.SwaggerEndpoint(".." + groupInfo.RouteTemplate.Substring(groupInfo.RouteTemplate.IndexOf("/swagger/")), groupInfo.Title); } });