Closed angularsen closed 3 months ago
Hello @angularsen
Thank you for your time and proposal. Allowing the external configuration of a JSON serializer is a great idea.
Internally, the Newtonsoft.Json
is configured with TypeNameHandling.All
to include the .NET type name when serializing.
I will look into it and prepare a pre-release for you to test.
That's awesome, I'm happy to give it a test
Hello @angularsen,
I appreciate your patience. As a first step, we can configure the existing Newtonsoft SerializerSettings
to be backward compatible. Afterward, in a major release, we could configure the serialization as you described (configuring JSON serializer externally).
I have prepared the IdempotentAPI v2.5.0-issue-74-01 pre-release version, in which we can configure the Newtonsoft SerializerSettings
as follows in the Startup.cs
:
IdempotencyOptions idempotencyOptions = new()
{
CacheOnlySuccessResponses = true,
DistributedLockTimeoutMilli = 2000,
SerializerSettings = new JsonSerializerSettings(){}
.ConfigureForNodaTime(DateTimeZoneProviders.Tzdb)
};
// Register the IdempotentAPI Core services.
services.AddIdempotentAPI(idempotencyOptions);
Thanks, serialization seems to work now with the pre-release nuget.
However, I ran into a new problem of getting 406 Not Accepted
and 0 bytes written:
https://github.com/ikyriak/IdempotentAPI/issues/78
I created a separate issue for this: https://github.com/ikyriak/IdempotentAPI/issues/78
This issue is resolved in the stable version of the IdempotentAPI v2.5.0.
We use NodaTime in our DTOs for things like
Instant
andLocalDate
, which requires a custom JSON serializer NodaTime.Serialization.SystemTextJson.Problem: JsonSerializationException on unsupported property types in DTO
IdempotentAPI does serialize the first successful request, but fails to deserialize the second request with Newtonsoft.Json.JsonSerializationException:
called from
It seems Newtonsoft JSON is used internally and without any support for configurable JSON serializers.
Proposal
b. FusionCacheSystemTextJsonSerializerExtensions.AddFusionCacheSystemTextJsonSerializer().
Our setup