Skip to content

Commit

Permalink
Fix JSON serialization exception
Browse files Browse the repository at this point in the history
Fix the JSON source generator not supporting serializing `ProblemDetails`.
  • Loading branch information
martincostello committed Aug 11, 2022
1 parent 1255114 commit 6d37785
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 1 addition & 2 deletions src/API/ApiBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ public static WebApplication Configure(WebApplicationBuilder builder)
{
options.SerializerOptions.PropertyNameCaseInsensitive = false;
options.SerializerOptions.WriteIndented = true;
//// HACK Remove due to issue serializing ProblemDetails for OpenAPI
////options.SerializerOptions.AddContext<ApplicationJsonSerializerContext>();
options.SerializerOptions.AddContext<ApplicationJsonSerializerContext>();
});

builder.Services.AddResponseCompression((options) =>
Expand Down
3 changes: 2 additions & 1 deletion src/API/Swagger/ExampleFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ internal sealed class ExampleFilter : IOperationFilter, IParameterFilter, ISchem
/// <param name="options">The <see cref="JsonOptions"/> to use.</param>
public ExampleFilter(IOptions<JsonOptions> options)
{
_options = options.Value.SerializerOptions;
_options = new(options.Value.SerializerOptions);
_options.TypeInfoResolver = null; // Remove the JsonSerializerContext
}

/// <inheritdoc />
Expand Down

0 comments on commit 6d37785

Please sign in to comment.