Skip to content

Commit

Permalink
add support for Microsoft.AspNetCore.Http.Json.JsonOptions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bonuspunkt committed Jan 24, 2024
1 parent 116c636 commit a585cda
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 a585cda

Please sign in to comment.