File tree 3 files changed +15
-6
lines changed 3 files changed +15
-6
lines changed Original file line number Diff line number Diff line change @@ -3,14 +3,23 @@ namespace ExampleWebApp.Backend.WebApi;
3
3
public static partial class Extensions
4
4
{
5
5
6
- public static IMvcBuilder SetupControllers ( this IServiceCollection serviceCollection )
6
+ public static IMvcBuilder SetupControllers ( this WebApplicationBuilder builder )
7
7
{
8
- var res = serviceCollection . AddControllers ( options =>
8
+ var sp = builder . Services . BuildServiceProvider ( ) ;
9
+
10
+ var res = builder . Services . AddControllers ( options =>
11
+ {
12
+ // options.Filters.Add<JWTFilter>();
13
+ } )
14
+
15
+ . AddJsonOptions ( options =>
9
16
{
10
- options . Filters . Add < JWTFilter > ( ) ;
17
+ var util = sp . GetRequiredService < IUtilService > ( ) ;
18
+
19
+ util . ConfigureJsonSerializerOptions ( options . JsonSerializerOptions ) ;
11
20
} ) ;
12
21
13
- return res ;
22
+ return res ;
14
23
}
15
24
16
25
}
Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ IConfiguration configuration
24
24
public JsonSerializerOptions ConfigureJsonSerializerOptions ( JsonSerializerOptions options )
25
25
{
26
26
options . Converters . Add ( new JsonStringEnumConverter ( ) ) ;
27
- options . ReferenceHandler = ReferenceHandler . IgnoreCycles ; // TOOD: verify if can use All
27
+ options . ReferenceHandler = ReferenceHandler . Preserve ;
28
28
29
29
options . PropertyNamingPolicy = JsonNamingPolicy . CamelCase ;
30
30
Original file line number Diff line number Diff line change 38
38
builder . Services . SetupRoles ( ) ;
39
39
40
40
// add controllers
41
- builder . Services . SetupControllers ( ) ;
41
+ builder . SetupControllers ( ) ;
42
42
43
43
builder . Services . AddProblemDetails ( ) ;
44
44
You can’t perform that action at this time.
0 commit comments