😊 新增 `Swagger` 在生产环境中可自动开启登录配置属性 `EnableOnProduction`

pull/885/MERGE
百小僧 5 months ago
parent 5ea3dea7d2
commit e4020c2106

@ -32,6 +32,7 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
@ -663,7 +664,7 @@ public static class SpecificationDocumentBuilder
{
swaggerUIOptions.ConfigObject.AdditionalItems.Add(nameof(_specificationDocumentSettings.LoginInfo), new JsonObject
{
[nameof(SpecificationLoginInfo.Enabled)] = additionals.Enabled,
[nameof(SpecificationLoginInfo.Enabled)] = additionals.Enabled || (App.HostEnvironment.IsProduction() && additionals.EnableOnProduction),
[nameof(SpecificationLoginInfo.CheckUrl)] = additionals.CheckUrl,
[nameof(SpecificationLoginInfo.SubmitUrl)] = additionals.SubmitUrl
});

@ -45,4 +45,9 @@ public sealed class SpecificationLoginInfo
/// 提交登录地址
/// </summary>
public string SubmitUrl { get; set; }
/// <summary>
/// 生产环境自动开启
/// </summary>
public bool EnableOnProduction { get; set; }
}

@ -32,6 +32,7 @@ using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
@ -663,7 +664,7 @@ public static class SpecificationDocumentBuilder
{
swaggerUIOptions.ConfigObject.AdditionalItems.Add(nameof(_specificationDocumentSettings.LoginInfo), new JsonObject
{
[nameof(SpecificationLoginInfo.Enabled)] = additionals.Enabled,
[nameof(SpecificationLoginInfo.Enabled)] = additionals.Enabled || (App.HostEnvironment.IsProduction() && additionals.EnableOnProduction),
[nameof(SpecificationLoginInfo.CheckUrl)] = additionals.CheckUrl,
[nameof(SpecificationLoginInfo.SubmitUrl)] = additionals.SubmitUrl
});

@ -45,4 +45,9 @@ public sealed class SpecificationLoginInfo
/// 提交登录地址
/// </summary>
public string SubmitUrl { get; set; }
/// <summary>
/// 生产环境自动开启
/// </summary>
public bool EnableOnProduction { get; set; }
}

@ -2623,6 +2623,11 @@
"Password": {
"type": "string",
"description": "密码"
},
"EnableOnProduction": {
"type": "boolean",
"description": "是否生产环境自动开启",
"default": false
}
}
},

@ -2623,6 +2623,11 @@
"Password": {
"type": "string",
"description": "密码"
},
"EnableOnProduction": {
"type": "boolean",
"description": "是否生产环境自动开启",
"default": false
}
}
},

Loading…
Cancel
Save