Skip to content

Commit 5452912

Browse files
Add support for application/vnd.api+json in SystemTextJsonInputFormatter
1 parent 2dcfb45 commit 5452912

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

JsonApiToolkit/Extensions/ServiceCollectionExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,18 @@ public static IServiceCollection AddJsonApiToolkit(this IServiceCollection servi
9595
{
9696
jsonOutputFormatter.SupportedMediaTypes.Add("application/vnd.api+json");
9797
}
98+
99+
SystemTextJsonInputFormatter? jsonInputFormatter = options
100+
.InputFormatters.OfType<SystemTextJsonInputFormatter>()
101+
.FirstOrDefault();
102+
103+
if (
104+
jsonInputFormatter?.SupportedMediaTypes.Contains("application/vnd.api+json")
105+
== false
106+
)
107+
{
108+
jsonInputFormatter.SupportedMediaTypes.Add("application/vnd.api+json");
109+
}
98110
});
99111

100112
services.AddScoped<JsonApiExceptionFilter>();

0 commit comments

Comments
 (0)