diff --git a/src/Microsoft.AspNetCore.Mvc.ApiExplorer/ProblemDetailsApiDescriptionProvider.cs b/src/Microsoft.AspNetCore.Mvc.ApiExplorer/ApiControllerApiDescriptionProvider.cs similarity index 91% rename from src/Microsoft.AspNetCore.Mvc.ApiExplorer/ProblemDetailsApiDescriptionProvider.cs rename to src/Microsoft.AspNetCore.Mvc.ApiExplorer/ApiControllerApiDescriptionProvider.cs index 917588f86c..4856b19cbd 100644 --- a/src/Microsoft.AspNetCore.Mvc.ApiExplorer/ProblemDetailsApiDescriptionProvider.cs +++ b/src/Microsoft.AspNetCore.Mvc.ApiExplorer/ApiControllerApiDescriptionProvider.cs @@ -5,15 +5,16 @@ using System; using System.Collections.Generic; using System.Linq; using Microsoft.AspNetCore.Http; +using Microsoft.AspNetCore.Mvc.Internal; using Microsoft.AspNetCore.Mvc.ModelBinding; namespace Microsoft.AspNetCore.Mvc.ApiExplorer { - public class ProblemDetailsApiDescriptionProvider : IApiDescriptionProvider + public class ApiControllerApiDescriptionProvider : IApiDescriptionProvider { private readonly IModelMetadataProvider _modelMetadaProvider; - public ProblemDetailsApiDescriptionProvider(IModelMetadataProvider modelMetadataProvider) + public ApiControllerApiDescriptionProvider(IModelMetadataProvider modelMetadataProvider) { _modelMetadaProvider = modelMetadataProvider; } @@ -31,7 +32,7 @@ namespace Microsoft.AspNetCore.Mvc.ApiExplorer { foreach (var apiDescription in context.Results) { - if (!apiDescription.ActionDescriptor.FilterDescriptors.Any(f => f.Filter is ProblemDetailsAttribute)) + if (!apiDescription.ActionDescriptor.FilterDescriptors.Any(f => f.Filter is IApiBehaviorMetadata)) { continue; } diff --git a/src/Microsoft.AspNetCore.Mvc.ApiExplorer/DependencyInjection/MvcApiExplorerMvcCoreBuilderExtensions.cs b/src/Microsoft.AspNetCore.Mvc.ApiExplorer/DependencyInjection/MvcApiExplorerMvcCoreBuilderExtensions.cs index 9f7668d194..bb823c3ecb 100644 --- a/src/Microsoft.AspNetCore.Mvc.ApiExplorer/DependencyInjection/MvcApiExplorerMvcCoreBuilderExtensions.cs +++ b/src/Microsoft.AspNetCore.Mvc.ApiExplorer/DependencyInjection/MvcApiExplorerMvcCoreBuilderExtensions.cs @@ -27,7 +27,7 @@ namespace Microsoft.Extensions.DependencyInjection services.TryAddEnumerable( ServiceDescriptor.Transient()); services.TryAddEnumerable( - ServiceDescriptor.Transient()); + ServiceDescriptor.Transient()); } } } diff --git a/src/Microsoft.AspNetCore.Mvc.Core/ProblemDetailsAttribute.cs b/src/Microsoft.AspNetCore.Mvc.Core/ProblemDetailsAttribute.cs deleted file mode 100644 index e837470761..0000000000 --- a/src/Microsoft.AspNetCore.Mvc.Core/ProblemDetailsAttribute.cs +++ /dev/null @@ -1,16 +0,0 @@ -// 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; -using Microsoft.AspNetCore.Mvc.Filters; - -namespace Microsoft.AspNetCore.Mvc -{ - /// - /// Adds an that indicates to the framework that the current action conforms to well-known API behavior. - /// - [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = false, Inherited = true)] - public class ProblemDetailsAttribute : Attribute, IFilterMetadata - { - } -} diff --git a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ApiExplorerTest.cs b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ApiExplorerTest.cs index 322ca76658..3d969234b6 100644 --- a/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ApiExplorerTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.FunctionalTests/ApiExplorerTest.cs @@ -1069,7 +1069,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests public async Task ProblemDetails_AddsProblemAsDefaultErrorResult() { // Act - var body = await Client.GetStringAsync("ApiExplorerProblemDetails/ActionWithoutParameters"); + var body = await Client.GetStringAsync("ApiExplorerApiController/ActionWithoutParameters"); var result = JsonConvert.DeserializeObject>(body); // Assert @@ -1087,7 +1087,7 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests public async Task ProblemDetails_AddsProblemAsErrorResultForBadResult_WhenActionHasParameters() { // Act - var body = await Client.GetStringAsync("ApiExplorerProblemDetails/ActionWithSomeParameters"); + var body = await Client.GetStringAsync("ApiExplorerApiController/ActionWithSomeParameters"); var result = JsonConvert.DeserializeObject>(body); // Assert @@ -1108,8 +1108,8 @@ namespace Microsoft.AspNetCore.Mvc.FunctionalTests } [Theory] - [InlineData("ApiExplorerProblemDetails/ActionWithIdParameter")] - [InlineData("ApiExplorerProblemDetails/ActionWithIdSuffixParameter")] + [InlineData("ApiExplorerApiController/ActionWithIdParameter")] + [InlineData("ApiExplorerApiController/ActionWithIdSuffixParameter")] public async Task ProblemDetails_AddsProblemAsErrorResultForNotFoundResult_WhenActionHasAnIdParameters(string url) { // Act diff --git a/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs b/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs index 8f34600cc9..c71cb03802 100644 --- a/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs +++ b/test/Microsoft.AspNetCore.Mvc.Test/MvcServiceCollectionExtensionsTest.cs @@ -425,7 +425,7 @@ namespace Microsoft.AspNetCore.Mvc new Type[] { typeof(DefaultApiDescriptionProvider), - typeof(ProblemDetailsApiDescriptionProvider), + typeof(ApiControllerApiDescriptionProvider), typeof(JsonPatchOperationsArrayProvider), } }, diff --git a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerProblemDetailsController.cs b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerApiController.cs similarity index 80% rename from test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerProblemDetailsController.cs rename to test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerApiController.cs index cdf82b6336..da1cadaa64 100644 --- a/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerProblemDetailsController.cs +++ b/test/WebSites/ApiExplorerWebSite/Controllers/ApiExplorerApiController.cs @@ -5,9 +5,9 @@ using Microsoft.AspNetCore.Mvc; namespace ApiExplorerWebSite { - [Route("ApiExplorerProblemDetails/[action]")] - [ProblemDetails] - public class ApiExplorerProblemDetailsController : Controller + [Route("ApiExplorerApiController/[action]")] + [ApiController] + public class ApiExplorerApiController : Controller { public IActionResult ActionWithoutParameters() => Ok();