若想在项目启动时默认显示 Swigger UI,需要设置 Properties/launchSettings.json 中的 launchUrl 值为空字符串:
"launchUrl": "",
调试环境下,自动开启 Swigger UI 文档,生产环境下设置 OpenInterfaceDoc 为 true 才会开启。
有两种开启方式:
1、在 “appsettings.json” 中配置 OpenInterfaceDoc 为 true。
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"OpenInterfaceDoc": true
}
2、Program.cs 文件 中初始化框架时开启:
using FlexibleCore;
FlexibleCoreInit.Build(args, opt => {
opt.OpenInterfaceDoc = true;
}).Run();
在 json 文件中配置的方式优先级要高于代码方式。如果“appsettings.json” 中配置为 true,Program.cs 中设置 opt.OpenInterfaceDoc = false; 最终框架以 true 为准。