diff --git a/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/Common/JsonOptions.cs b/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/Common/JsonOptions.cs new file mode 100644 index 0000000..06d6cea --- /dev/null +++ b/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/Common/JsonOptions.cs @@ -0,0 +1,13 @@ +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace Wemogy.CQRS.Extensions.FastEndpoints.Common; + +public static class JsonOptions +{ + public static JsonSerializerOptions JsonSerializerOptions => new JsonSerializerOptions() + { + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + ReferenceHandler = ReferenceHandler.IgnoreCycles + }; +} diff --git a/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteCommandRunners/HttpRemoteCommandRunner`2.cs b/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteCommandRunners/HttpRemoteCommandRunner`2.cs index a2b798a..04ddac3 100644 --- a/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteCommandRunners/HttpRemoteCommandRunner`2.cs +++ b/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteCommandRunners/HttpRemoteCommandRunner`2.cs @@ -3,6 +3,7 @@ using Wemogy.CQRS.Abstractions; using Wemogy.CQRS.Commands.Abstractions; using Wemogy.CQRS.Common.ValueObjects; +using Wemogy.CQRS.Extensions.FastEndpoints.Common; namespace Wemogy.CQRS.Extensions.FastEndpoints.RemoteCommandRunners; @@ -40,6 +41,6 @@ public async Task RunAsync(CommandRequest command) return default!; } - return JsonSerializer.Deserialize(response.Content) !; + return JsonSerializer.Deserialize(response.Content, JsonOptions.JsonSerializerOptions) !; } } diff --git a/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteQueryRunners/HttpRemoteQueryRunner.cs b/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteQueryRunners/HttpRemoteQueryRunner.cs index bafb894..d0c24e6 100644 --- a/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteQueryRunners/HttpRemoteQueryRunner.cs +++ b/src/extensions/fastEndpoints/Wemogy.CQRS.Extensions.FastEndpoints/RemoteQueryRunners/HttpRemoteQueryRunner.cs @@ -1,7 +1,9 @@ using System.Text.Json; +using System.Text.Json.Serialization; using RestSharp; using Wemogy.CQRS.Abstractions; using Wemogy.CQRS.Common.ValueObjects; +using Wemogy.CQRS.Extensions.FastEndpoints.Common; using Wemogy.CQRS.Queries.Abstractions; namespace Wemogy.CQRS.Extensions.FastEndpoints.RemoteQueryRunners; @@ -42,6 +44,6 @@ public async Task QueryAsync(QueryRequest query, CancellationTo return default!; } - return JsonSerializer.Deserialize(response.Content) !; + return JsonSerializer.Deserialize(response.Content, JsonOptions.JsonSerializerOptions) !; } }