Fix json output con serializzazione globale + update return x Report controller API
This commit is contained in:
+16
-2
@@ -1,11 +1,10 @@
|
||||
using EgwCoreLib.Lux.Data.Services.General;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using NLog.Targets;
|
||||
using NLog.Web;
|
||||
using OpenTelemetry.Resources;
|
||||
using OpenTelemetry.Trace;
|
||||
using System.Reflection;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
var builder = WebApplication.CreateBuilder(args);
|
||||
// recupero env corrente
|
||||
@@ -146,6 +145,21 @@ builder.Services.AddDbContextFactory<DataLayerContext>(options =>
|
||||
.LogTo(_ => { }); // disabilita EF logging;
|
||||
});
|
||||
|
||||
// fix serializazzione senza loop
|
||||
builder.Services.AddControllers().AddJsonOptions(options =>
|
||||
{
|
||||
options.JsonSerializerOptions.ReferenceHandler = ReferenceHandler.IgnoreCycles;
|
||||
});
|
||||
|
||||
//// fix serializzazione con NewtonsoftJson e gestione loop...
|
||||
//builder.Services
|
||||
// .AddControllers()
|
||||
// .AddNewtonsoftJson(options =>
|
||||
// {
|
||||
// options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore;
|
||||
// });
|
||||
|
||||
|
||||
// registrazione in blocco servizi con metodo extension custom
|
||||
builder.Services.AddLuxData(connectionString);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user