让Nginx二级目录支持Swagger
This commit is contained in:
parent
8ff1ed357f
commit
626eb06392
@ -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",
|
||||
|
||||
@ -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);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user