Revive call to FormattingUtilities in XmlDataContractSerializerOutputFormatter
Fixes #6235
This commit is contained in:
parent
05f5d59e44
commit
fc106ab793
|
|
@ -132,7 +132,9 @@ namespace Microsoft.AspNetCore.Mvc.Formatters
|
|||
|
||||
try
|
||||
{
|
||||
// Use FormattingUtilities here when https://github.com/aspnet/Mvc/issues/6235 is resolved.
|
||||
// Verify that type is a valid data contract by forcing the serializer to try to create a data contract
|
||||
FormattingUtilities.XsdDataContractExporter.GetRootElementName(type);
|
||||
|
||||
// If the serializer does not support this type it will throw an exception.
|
||||
return new DataContractSerializer(type, _serializerSettings);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,9 @@
|
|||
// Copyright (c) .NET Foundation. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc.Formatters;
|
||||
|
|
@ -10,8 +11,6 @@ using Microsoft.AspNetCore.Mvc.ModelBinding;
|
|||
using Microsoft.AspNetCore.Testing.xunit;
|
||||
using Newtonsoft.Json;
|
||||
using Xunit;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Net;
|
||||
|
||||
namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
||||
{
|
||||
|
|
@ -571,7 +570,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var type1 = typeof(ApiExplorerWebSite.Product).FullName;
|
||||
var type2 = typeof(ModelStateDictionary).FullName;
|
||||
var type2 = typeof(SerializableError).FullName;
|
||||
var expectedMediaTypes = new[] { "application/json", "text/json", "application/xml", "text/xml" };
|
||||
|
||||
// Act
|
||||
|
|
@ -603,7 +602,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var type1 = typeof(ApiExplorerWebSite.Product).FullName;
|
||||
var type2 = typeof(ModelStateDictionary).FullName;
|
||||
var type2 = typeof(SerializableError).FullName;
|
||||
var expectedMediaTypes = new[] { "text/xml" };
|
||||
|
||||
// Act
|
||||
|
|
@ -635,7 +634,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var type1 = typeof(ApiExplorerWebSite.Product).FullName;
|
||||
var type2 = typeof(ModelStateDictionary).FullName;
|
||||
var type2 = typeof(SerializableError).FullName;
|
||||
var expectedMediaTypes = new[] { "application/json", "text/json", "application/xml", "text/xml" };
|
||||
|
||||
// Act
|
||||
|
|
@ -667,7 +666,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests
|
|||
{
|
||||
// Arrange
|
||||
var type1 = typeof(ApiExplorerWebSite.Product).FullName;
|
||||
var type2 = typeof(ModelStateDictionary).FullName;
|
||||
var type2 = typeof(SerializableError).FullName;
|
||||
var expectedMediaTypes = new[] { "text/xml" };
|
||||
|
||||
// Act
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding;
|
||||
|
||||
namespace ApiExplorerWebSite
|
||||
{
|
||||
|
|
@ -58,7 +57,7 @@ namespace ApiExplorerWebSite
|
|||
}
|
||||
|
||||
[ProducesResponseType(typeof(Product), 201)]
|
||||
[ProducesResponseType(typeof(ModelStateDictionary), 400)]
|
||||
[ProducesResponseType(typeof(SerializableError), 400)]
|
||||
public Product CreateProductWithDefaultResponseContentTypes(Product product)
|
||||
{
|
||||
return null;
|
||||
|
|
@ -66,21 +65,21 @@ namespace ApiExplorerWebSite
|
|||
|
||||
[Produces("text/xml")] // Has status code as 200 but is not applied as it does not set 'Type'
|
||||
[ProducesResponseType(typeof(Product), 201)]
|
||||
[ProducesResponseType(typeof(ModelStateDictionary), 400)]
|
||||
[ProducesResponseType(typeof(SerializableError), 400)]
|
||||
public Product CreateProductWithLimitedResponseContentTypes(Product product)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[ProducesResponseType(typeof(Product), 200)]
|
||||
[ProducesResponseType(typeof(ModelStateDictionary), 400)]
|
||||
[ProducesResponseType(typeof(SerializableError), 400)]
|
||||
public Product UpdateProductWithDefaultResponseContentTypes(Product product)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
[Produces("text/xml", Type = typeof(Product))] // Has status code as 200
|
||||
[ProducesResponseType(typeof(ModelStateDictionary), 400)]
|
||||
[ProducesResponseType(typeof(SerializableError), 400)]
|
||||
public Product UpdateProductWithLimitedResponseContentTypes(Product product)
|
||||
{
|
||||
return null;
|
||||
|
|
|
|||
Loading…
Reference in New Issue