From e4020c21063d62c8408ee09f4e43fb2ea6fdfcaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BE=E5=B0=8F=E5=83=A7?= Date: Wed, 4 Sep 2024 18:30:40 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=98=8A=20=E6=96=B0=E5=A2=9E=20`Swagger`?= =?UTF-8?q?=20=E5=9C=A8=E7=94=9F=E4=BA=A7=E7=8E=AF=E5=A2=83=E4=B8=AD?= =?UTF-8?q?=E5=8F=AF=E8=87=AA=E5=8A=A8=E5=BC=80=E5=90=AF=E7=99=BB=E5=BD=95?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E5=B1=9E=E6=80=A7=20`EnableOnProduction`?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Builders/SpecificationDocumentBuilder.cs | 3 ++- .../SpecificationDocument/Internal/SpecificationLoginInfo.cs | 5 +++++ .../Builders/SpecificationDocumentBuilder.cs | 3 ++- .../SpecificationDocument/Internal/SpecificationLoginInfo.cs | 5 +++++ schemas/v3/furion-schema.json | 5 +++++ schemas/v4/furion-schema.json | 5 +++++ 6 files changed, 24 insertions(+), 2 deletions(-) diff --git a/framework/Furion.Pure/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs b/framework/Furion.Pure/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs index 8911f0e7d5..acf26716e6 100644 --- a/framework/Furion.Pure/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs +++ b/framework/Furion.Pure/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs @@ -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 }); diff --git a/framework/Furion.Pure/SpecificationDocument/Internal/SpecificationLoginInfo.cs b/framework/Furion.Pure/SpecificationDocument/Internal/SpecificationLoginInfo.cs index f213a24f46..9b30ef36fe 100644 --- a/framework/Furion.Pure/SpecificationDocument/Internal/SpecificationLoginInfo.cs +++ b/framework/Furion.Pure/SpecificationDocument/Internal/SpecificationLoginInfo.cs @@ -45,4 +45,9 @@ public sealed class SpecificationLoginInfo /// 提交登录地址 /// public string SubmitUrl { get; set; } + + /// + /// 生产环境自动开启 + /// + public bool EnableOnProduction { get; set; } } \ No newline at end of file diff --git a/framework/Furion/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs b/framework/Furion/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs index 8911f0e7d5..acf26716e6 100644 --- a/framework/Furion/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs +++ b/framework/Furion/SpecificationDocument/Builders/SpecificationDocumentBuilder.cs @@ -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 }); diff --git a/framework/Furion/SpecificationDocument/Internal/SpecificationLoginInfo.cs b/framework/Furion/SpecificationDocument/Internal/SpecificationLoginInfo.cs index f213a24f46..9b30ef36fe 100644 --- a/framework/Furion/SpecificationDocument/Internal/SpecificationLoginInfo.cs +++ b/framework/Furion/SpecificationDocument/Internal/SpecificationLoginInfo.cs @@ -45,4 +45,9 @@ public sealed class SpecificationLoginInfo /// 提交登录地址 /// public string SubmitUrl { get; set; } + + /// + /// 生产环境自动开启 + /// + public bool EnableOnProduction { get; set; } } \ No newline at end of file diff --git a/schemas/v3/furion-schema.json b/schemas/v3/furion-schema.json index 727e4c14e5..643c490822 100644 --- a/schemas/v3/furion-schema.json +++ b/schemas/v3/furion-schema.json @@ -2623,6 +2623,11 @@ "Password": { "type": "string", "description": "密码" + }, + "EnableOnProduction": { + "type": "boolean", + "description": "是否生产环境自动开启", + "default": false } } }, diff --git a/schemas/v4/furion-schema.json b/schemas/v4/furion-schema.json index 727e4c14e5..643c490822 100644 --- a/schemas/v4/furion-schema.json +++ b/schemas/v4/furion-schema.json @@ -2623,6 +2623,11 @@ "Password": { "type": "string", "description": "密码" + }, + "EnableOnProduction": { + "type": "boolean", + "description": "是否生产环境自动开启", + "default": false } } },