Merge pull request '让Swagger可以调试Nginx二级目录转发的地址' (#220) from koy07555/Admin.NET.Pro:让Nginx二级目录支持Swagger into v2

Reviewed-on: http://101.43.53.74:3000/Admin.NET/Admin.NET.Pro/pulls/220
This commit is contained in:
zuohuaijun 2025-01-06 17:19:12 +08:00
commit eb63382891
2 changed files with 14 additions and 2 deletions

View File

@ -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", // ListFullNone
"EnableAllGroups": true,
//"ServerDir": "t490", // Nginx Servers
"HideServers": false,
"Servers": [
{
"Url": "https://ip/二级",
"Description": "发布地址名称"
}
],
"LoginInfo": {
"Enabled": true, // Swagger
"CheckUrl": "/api/swagger/checkUrl",

View File

@ -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);
}
});