From 8c62d16c70c77e9c8b4e791e3c7e32003219ed19 Mon Sep 17 00:00:00 2001
From: sunpengfei <i@angelzzz.com>
Date: 星期一, 09 六月 2025 10:23:20 +0800
Subject: [PATCH] feat:开通swagger
---
LifePayment/LifePayment.Host/appsettings.json | 1 +
LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs | 17 +++++++++++------
2 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs b/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs
index 65763af..e35f536 100644
--- a/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs
+++ b/LifePayment/LifePayment.Host/LifePaymentServiceHostModule.cs
@@ -170,13 +170,18 @@
app.UseIdentityServer();
app.UseAuthorization();
app.UseAbpClaimsMap();
-#if DEBUG
- app.UseSwagger();
- app.UseSwaggerUI(options =>
+
+ var configuration = context.ServiceProvider.GetRequiredService<IConfiguration>();
+ var openSwagger = configuration["OpenSwagger"].ToBoolOrNull();
+ if (openSwagger == true)
{
- options.SwaggerEndpoint("/swagger/v1/swagger.json", "LifePayment Service API");
- });
-#endif
+ app.UseSwagger();
+ app.UseSwaggerUI(options =>
+ {
+ options.SwaggerEndpoint("/swagger/v1/swagger.json", "LifePayment Service API");
+ });
+ }
+
app.UseAuditing();
app.UseConfiguredEndpoints();
AsyncHelper.RunSync(async () =>
diff --git a/LifePayment/LifePayment.Host/appsettings.json b/LifePayment/LifePayment.Host/appsettings.json
index bb30686..bcbf82b 100644
--- a/LifePayment/LifePayment.Host/appsettings.json
+++ b/LifePayment/LifePayment.Host/appsettings.json
@@ -3,6 +3,7 @@
"Authority": "http://localhost:58190",
"ApiName": "IdentityService"
},
+ "OpenSwagger": true,
"BaiDuAI": {
"Ocr": {
"Key": "Htx3y6eFnlW92WvHx9aW44f8",
--
Gitblit v1.9.1