Add formatter mapping for JSON (#12592)
Fixes https://github.com/aspnet/AspNetCore/issues/12414
This commit is contained in:
parent
b13f2614de
commit
d7bfbb5824
|
|
@ -80,6 +80,9 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
// Set up default input formatters.
|
||||
options.InputFormatters.Add(new SystemTextJsonInputFormatter(_jsonOptions.Value, _loggerFactory.CreateLogger<SystemTextJsonInputFormatter>()));
|
||||
|
||||
// Media type formatter mappings for JSON
|
||||
options.FormatterMappings.SetMediaTypeMappingForFormat("json", MediaTypeHeaderValues.ApplicationJson);
|
||||
|
||||
// Set up default output formatters.
|
||||
options.OutputFormatters.Add(new HttpNoContentOutputFormatter());
|
||||
options.OutputFormatters.Add(new StringOutputFormatter());
|
||||
|
|
|
|||
|
|
@ -111,6 +111,17 @@ namespace Microsoft.AspNetCore.Mvc
|
|||
formatter => Assert.IsType<SystemTextJsonInputFormatter>(formatter));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Setup_SetsUpFormatterMapping()
|
||||
{
|
||||
// Arrange & Act
|
||||
var options = GetOptions<MvcOptions>();
|
||||
|
||||
// Assert
|
||||
var mapping = options.FormatterMappings.GetMediaTypeMappingForFormat("json");
|
||||
Assert.Equal("application/json", mapping);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Setup_SetsUpModelValidatorProviders()
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue