File tree Expand file tree Collapse file tree
5_More/Services/GamesApiDotnet6 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99builder . Services . AddEndpointsApiExplorer ( ) ;
1010builder . Services . AddSwaggerGen ( ) ;
1111
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
1220builder . Services . Configure < JsonOptions > ( options =>
1321{
1422 options . SerializerOptions . DefaultIgnoreCondition = JsonIgnoreCondition . WhenWritingDefault ;
15- options . SerializerOptions . Converters . Add ( new JsonStringEnumConverter ( ) ) ;
1623} ) ;
1724
1825builder . Services . AddSingleton < IGamesRepository , InMemoryGamesRepository > ( ) ;
You can’t perform that action at this time.
0 commit comments