chore(udt-011): register DateOnlyJsonConverter in Program.cs AddJsonOptions

This commit is contained in:
2026-04-18 09:47:19 -03:00
parent a75d2f75a0
commit 3c264aa7a1
2 changed files with 50 additions and 2 deletions

View File

@@ -2,12 +2,13 @@ using Microsoft.AspNetCore.Authorization;
using Serilog;
using Scalar.AspNetCore;
using SIGCM2.Api.Authorization;
using SIGCM2.Api.Filters;
using SIGCM2.Api.HealthChecks;
using SIGCM2.Api.Json;
using SIGCM2.Api.Middleware;
using SIGCM2.Application;
using SIGCM2.Infrastructure;
using SIGCM2.Infrastructure.Audit.Jobs;
using SIGCM2.Api.Filters;
// Bootstrap logger — before DI is built
Log.Logger = new LoggerConfiguration()
@@ -36,10 +37,15 @@ builder.Services.AddAuthorization();
builder.Services.AddScoped<IAuthorizationHandler, PermissionAuthorizationHandler>();
builder.Services.AddSingleton<IAuthorizationMiddlewareResultHandler, ForbiddenProblemDetailsHandler>();
// Controllers with exception filter
// Controllers with exception filter + JSON options
// UDT-011: DateOnlyJsonConverter ensures Cat2 date fields serialize as "yyyy-MM-dd"
// and never as "2026-05-01T00:00:00" or with a UTC "Z" suffix.
builder.Services.AddControllers(opts =>
{
opts.Filters.Add<ExceptionFilter>();
}).AddJsonOptions(jsonOpts =>
{
jsonOpts.JsonSerializerOptions.Converters.Add(new DateOnlyJsonConverter());
});
// OpenAPI / Scalar