Skip to content

Commit b3de9bd

Browse files
committed
refactor: reuse default SerializerOptions in Minimal APIs
1 parent fde75c1 commit b3de9bd

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

src/Cnblogs.Architecture.Ddd.Cqrs.AspNetCore/CqrsHttpOptions.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Text.Json;
22
using Cnblogs.Architecture.Ddd.Cqrs.Abstractions;
33
using Microsoft.AspNetCore.Http;
4+
using Microsoft.AspNetCore.Http.Json;
45

56
namespace Cnblogs.Architecture.Ddd.Cqrs.AspNetCore;
67

@@ -25,5 +26,5 @@ public class CqrsHttpOptions
2526
/// <remarks>
2627
/// For Controllers, please use <c>builder.AddControllers().AddLongToStringJsonConverter();</c>
2728
/// </remarks>
28-
public JsonSerializerOptions DefaultJsonSerializerOptions { get; set; } = new(JsonSerializerDefaults.Web);
29+
public JsonSerializerOptions DefaultJsonSerializerOptions { get; set; } = new JsonOptions().SerializerOptions;
2930
}

test/Cnblogs.Architecture.IntegrationTestProject/Application/Queries/ListStringsQuery.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33

44
namespace Cnblogs.Architecture.IntegrationTestProject.Application.Queries;
55

6-
public record ListStringsQuery(PagingParams? PagingParams, string? OrderByString, string? culture) : IPageableQuery<string>;
6+
public record ListStringsQuery(PagingParams? PagingParams, string? OrderByString) : IPageableQuery<string>;

test/Cnblogs.Architecture.IntegrationTests/MinimalApiTests.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ public async Task ResponseJsonWithChineseChars_RemainUnencodedAsync()
1515
var response = await builder.CreateClient().GetAsync("/api/v1/articles");
1616
var content = await response.Content.ReadAsStringAsync();
1717

18-
Console.WriteLine(content);
19-
2018
// Assert
2119
Assert.True(response.IsSuccessStatusCode);
2220
Assert.Contains("开发者", content);

0 commit comments

Comments
 (0)