Skip to content

Commit

Permalink
Merge pull request #91 from wemogy/fix/json-options
Browse files Browse the repository at this point in the history
fix: added JsonSerializerOptions to CommandRunner and QueryRunner
  • Loading branch information
SebastianKuesters authored Jul 1, 2024
2 parents 8aa8073 + 68ae662 commit 6839f1a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -40,6 +41,6 @@ public async Task<TResult> RunAsync(CommandRequest<TCommand> command)
return default!;
}

return JsonSerializer.Deserialize<TResult>(response.Content) !;
return JsonSerializer.Deserialize<TResult>(response.Content, JsonOptions.JsonSerializerOptions) !;
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -42,6 +44,6 @@ public async Task<TResult> QueryAsync(QueryRequest<TQuery> query, CancellationTo
return default!;
}

return JsonSerializer.Deserialize<TResult>(response.Content) !;
return JsonSerializer.Deserialize<TResult>(response.Content, JsonOptions.JsonSerializerOptions) !;
}
}

0 comments on commit 6839f1a

Please sign in to comment.