File tree 1 file changed +8
-1
lines changed
5_More/Services/GamesApiDotnet6
1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change 9
9
builder . Services . AddEndpointsApiExplorer ( ) ;
10
10
builder . Services . AddSwaggerGen ( ) ;
11
11
12
+ // two different JsonOptions, swagger description uses Microsoft.AspNetCore.Mvc.Json
13
+ builder . Services . Configure < Microsoft . AspNetCore . Mvc . JsonOptions > ( options =>
14
+ {
15
+ options . JsonSerializerOptions . Converters . Add ( new JsonStringEnumConverter ( ) ) ;
16
+ options . JsonSerializerOptions . DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingDefault ;
17
+ } ) ;
18
+
19
+ // typed results use Microsoft.AspNetCore.Http.Json
12
20
builder . Services . Configure < JsonOptions > ( options =>
13
21
{
14
22
options . SerializerOptions . DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingDefault ;
15
- options . SerializerOptions . Converters . Add ( new JsonStringEnumConverter ( ) ) ;
16
23
} ) ;
17
24
18
25
builder . Services . AddSingleton < IGamesRepository , InMemoryGamesRepository > ( ) ;
You can’t perform that action at this time.
0 commit comments