Fix json output con serializzazione globale + update return x Report controller API

This commit is contained in:
Samuele Locatelli
2026-03-31 18:33:33 +02:00
parent e405942d03
commit bd51f368b1
3 changed files with 21 additions and 7 deletions
+16 -2
View File
@@ -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);