From 5c3d25d3adad2482027db27f46b7052d6a80e100 Mon Sep 17 00:00:00 2001 From: Safia Abdalla Date: Thu, 16 Sep 2021 19:20:52 +0000 Subject: [PATCH] Avoid using invalid content type for ValidationProblemDetails --- .../OpenApiDelegateEndpointConventionBuilderExtensions.cs | 4 ++-- src/Mvc/Mvc.ApiExplorer/test/ApiResponseTypeProviderTest.cs | 4 ++-- .../test/EndpointMetadataApiDescriptionProviderTest.cs | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Http/Routing/src/Builder/OpenApiDelegateEndpointConventionBuilderExtensions.cs b/src/Http/Routing/src/Builder/OpenApiDelegateEndpointConventionBuilderExtensions.cs index f6e65e088454..c968ce59f72c 100644 --- a/src/Http/Routing/src/Builder/OpenApiDelegateEndpointConventionBuilderExtensions.cs +++ b/src/Http/Routing/src/Builder/OpenApiDelegateEndpointConventionBuilderExtensions.cs @@ -109,7 +109,7 @@ public static DelegateEndpointConventionBuilder ProducesProblem(this DelegateEnd /// /// The . /// The response status code. Defaults to StatusCodes.Status400BadRequest. - /// The response content type. Defaults to "application/validationproblem+json". + /// The response content type. Defaults to "application/problem+json". /// A that can be used to further customize the endpoint. public static DelegateEndpointConventionBuilder ProducesValidationProblem(this DelegateEndpointConventionBuilder builder, int statusCode = StatusCodes.Status400BadRequest, @@ -117,7 +117,7 @@ public static DelegateEndpointConventionBuilder ProducesValidationProblem(this D { if (string.IsNullOrEmpty(contentType)) { - contentType = "application/validationproblem+json"; + contentType = "application/problem+json"; } return Produces(builder, statusCode, contentType); diff --git a/src/Mvc/Mvc.ApiExplorer/test/ApiResponseTypeProviderTest.cs b/src/Mvc/Mvc.ApiExplorer/test/ApiResponseTypeProviderTest.cs index fe0225df8e97..92f04f4c3451 100644 --- a/src/Mvc/Mvc.ApiExplorer/test/ApiResponseTypeProviderTest.cs +++ b/src/Mvc/Mvc.ApiExplorer/test/ApiResponseTypeProviderTest.cs @@ -715,7 +715,7 @@ public void GetApiResponseTypes_HandlesActionWithMultipleContentTypesAndProduces // Arrange var actionDescriptor = GetControllerActionDescriptor(typeof(TestController), nameof(TestController.GetUser)); actionDescriptor.FilterDescriptors.Add(new FilterDescriptor(new ProducesAttribute("text/xml") { Type = typeof(BaseModel) }, FilterScope.Action)); - actionDescriptor.FilterDescriptors.Add(new FilterDescriptor(new ProducesResponseTypeAttribute(typeof(ValidationProblemDetails), 400, "application/validationproblem+json"), FilterScope.Action)); + actionDescriptor.FilterDescriptors.Add(new FilterDescriptor(new ProducesResponseTypeAttribute(typeof(ValidationProblemDetails), 400, "application/problem+json"), FilterScope.Action)); actionDescriptor.FilterDescriptors.Add(new FilterDescriptor(new ProducesResponseTypeAttribute(typeof(ProblemDetails), 404, "application/problem+json"), FilterScope.Action)); actionDescriptor.FilterDescriptors.Add(new FilterDescriptor(new ProducesResponseTypeAttribute(409), FilterScope.Action)); @@ -738,7 +738,7 @@ public void GetApiResponseTypes_HandlesActionWithMultipleContentTypesAndProduces { Assert.Equal(typeof(ValidationProblemDetails), responseType.Type); Assert.Equal(400, responseType.StatusCode); - Assert.Equal(new[] { "application/validationproblem+json" }, GetSortedMediaTypes(responseType)); + Assert.Equal(new[] { "application/problem+json" }, GetSortedMediaTypes(responseType)); }, responseType => { diff --git a/src/Mvc/Mvc.ApiExplorer/test/EndpointMetadataApiDescriptionProviderTest.cs b/src/Mvc/Mvc.ApiExplorer/test/EndpointMetadataApiDescriptionProviderTest.cs index 5515afe2a538..4feb202701f6 100644 --- a/src/Mvc/Mvc.ApiExplorer/test/EndpointMetadataApiDescriptionProviderTest.cs +++ b/src/Mvc/Mvc.ApiExplorer/test/EndpointMetadataApiDescriptionProviderTest.cs @@ -561,7 +561,7 @@ public void HandlesProducesWithProducesProblem() { Assert.Equal(typeof(HttpValidationProblemDetails), responseType.Type); Assert.Equal(400, responseType.StatusCode); - Assert.Equal(new[] { "application/validationproblem+json" }, GetSortedMediaTypes(responseType)); + Assert.Equal(new[] { "application/problem+json" }, GetSortedMediaTypes(responseType)); }, responseType => {