Der DiP-Modus (Development in production) wurde für Swagger- und Test-Controller integriert.
This commit is contained in:
parent
1664b5739e
commit
ed25482cee
@ -18,6 +18,8 @@ using System.Text.Encodings.Web;
|
||||
using Ganss.Xss;
|
||||
using Microsoft.Extensions.Options;
|
||||
using DigitalData.EmailProfilerDispatcher.Application;
|
||||
using EnvelopeGenerator.Application;
|
||||
using EnvelopeGenerator.Application.Resources;
|
||||
|
||||
var logger = LogManager.Setup().LoadConfigurationFromAppSettings().GetCurrentClassLogger();
|
||||
logger.Info("Logging initialized!");
|
||||
@ -56,15 +58,16 @@ try
|
||||
{
|
||||
//remove option for Test*Controller
|
||||
options.Conventions.Add(new RemoveIfControllerConvention()
|
||||
.AndIf(_ => !builder.IsDevOrDiP())
|
||||
.AndIf(c => c.ControllerName.StartsWith("Test"))
|
||||
.AndIf(c => !config.GetValue<bool>("EnableTestControllers")));
|
||||
.AndIf(_ => !config.GetValue<bool>("EnableTestControllers")));
|
||||
}).AddJsonOptions(q =>
|
||||
{
|
||||
// Prevents serialization error when serializing SvgBitmap in EnvelopeReceiver
|
||||
q.JsonSerializerOptions.ReferenceHandler = System.Text.Json.Serialization.ReferenceHandler.IgnoreCycles;
|
||||
});
|
||||
|
||||
if (config.GetValue<bool>("EnableSwagger"))
|
||||
if (config.GetValue<bool>("EnableSwagger") && builder.IsDevOrDiP())
|
||||
{
|
||||
builder.Services.AddEndpointsApiExplorer();
|
||||
builder.Services.AddSwaggerGen();
|
||||
@ -198,7 +201,7 @@ try
|
||||
}
|
||||
}
|
||||
|
||||
if (config.GetValue<bool>("EnableSwagger"))
|
||||
if (config.GetValue<bool>("EnableSwagger") && builder.IsDevOrDiP())
|
||||
{
|
||||
app.UseSwagger();
|
||||
app.UseSwaggerUI();
|
||||
|
||||
@ -1,4 +1,5 @@
|
||||
{
|
||||
"DipMode": false, //Please be careful when enabling Development in Production (DiP) mode. It allows Swagger and test controllers to be enabled in a production environment.
|
||||
"EnableSwagger": true,
|
||||
"EnableTestControllers": true,
|
||||
"DetailedErrors": true,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user