Skip to content

Commit

Permalink
add support for Microsoft.AspNetCore.Http.Json.JsonOptions (#4733)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonuspunkt committed Mar 14, 2024
1 parent 57fcd55 commit 68d0125
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,13 @@ public static IServiceCollection AddSwaggerDocument(this IServiceCollection serv
var mvcOptions = services.GetRequiredService<IOptions<MvcOptions>>();
var newtonsoftSettings = AspNetCoreOpenApiDocumentGenerator.GetJsonSerializerSettings(services);
var systemTextJsonOptions = mvcOptions.Value.OutputFormatters
.Any(f => f.GetType().Name == "SystemTextJsonOutputFormatter") ?
AspNetCoreOpenApiDocumentGenerator.GetSystemTextJsonSettings(services) : null;
.Any(f => f.GetType().Name == "SystemTextJsonOutputFormatter")
? AspNetCoreOpenApiDocumentGenerator.GetSystemTextJsonSettings(services)
#if NET6_0_OR_GREATER
: services.GetService<IOptions<Microsoft.AspNetCore.Http.Json.JsonOptions>>()?.Value.SerializerOptions;
#else
: null;
#endif
if (systemTextJsonOptions != null)
{
Expand Down

0 comments on commit 68d0125

Please sign in to comment.