private ApiDescriptionProviderContext GetApiDescriptions(IReadOnlyList <ActionDescriptor> actionDescriptors) { if (actionDescriptors == null) { return(new ApiDescriptionProviderContext(new List <ActionDescriptor>())); } foreach (var action in actionDescriptors) { // This is required in order for OnProvidersExecuting() to work var apiExplorerActionData = new ApiDescriptionActionData() { GroupName = "Steeltoe" }; action.SetProperty(apiExplorerActionData); } var context = new ApiDescriptionProviderContext(actionDescriptors); foreach (var provider in _apiDescriptionProviders) { provider.OnProvidersExecuting(context); } return(context); }
private static void AddApiExplorerInfo( ControllerActionDescriptor actionDescriptor, ActionModel action, ControllerModel controller) { var apiExplorerIsVisible = action.ApiExplorer?.IsVisible ?? controller.ApiExplorer?.IsVisible ?? false; if (apiExplorerIsVisible) { var apiExplorerActionData = new ApiDescriptionActionData() { GroupName = action.ApiExplorer?.GroupName ?? controller.ApiExplorer?.GroupName, }; actionDescriptor.SetProperty(apiExplorerActionData); } }
private static void AddApiExplorerInfo( ControllerActionDescriptor actionDescriptor, ApplicationModel application, ControllerModel controller, ActionModel action) { var isVisible = action.ApiExplorer?.IsVisible ?? controller.ApiExplorer?.IsVisible ?? application.ApiExplorer?.IsVisible ?? false; var isVisibleSetOnActionOrController = action.ApiExplorer?.IsVisible ?? controller.ApiExplorer?.IsVisible ?? false; // ApiExplorer isn't supported on conventional-routed actions, but we still allow you to configure // it at the application level when you have a mix of controller types. We'll just skip over enabling // ApiExplorer for conventional-routed controllers when this happens. var isVisibleSetOnApplication = application.ApiExplorer?.IsVisible ?? false; if (isVisibleSetOnActionOrController && !IsAttributeRoutedAction(actionDescriptor)) { // ApiExplorer is only supported on attribute routed actions. throw new InvalidOperationException(Resources.FormatApiExplorer_UnsupportedAction( actionDescriptor.DisplayName)); } else if (isVisibleSetOnApplication && !IsAttributeRoutedAction(actionDescriptor)) { // This is the case where we're going to be lenient, just ignore it. } else if (isVisible) { Debug.Assert(IsAttributeRoutedAction(actionDescriptor)); var apiExplorerActionData = new ApiDescriptionActionData() { GroupName = action.ApiExplorer?.GroupName ?? controller.ApiExplorer?.GroupName, }; actionDescriptor.SetProperty(apiExplorerActionData); } }
private static void AddApiExplorerInfo( ControllerActionDescriptor actionDescriptor, ActionModel action, ControllerModel controller) { var apiExplorerIsVisible = action.ApiExplorer?.IsVisible ?? controller.ApiExplorer?.IsVisible ?? false; if (apiExplorerIsVisible) { if (!IsAttributeRoutedAction(actionDescriptor)) { // ApiExplorer is only supported on attribute routed actions. throw new InvalidOperationException(Resources.FormatApiExplorer_UnsupportedAction( actionDescriptor.DisplayName)); } var apiExplorerActionData = new ApiDescriptionActionData() { GroupName = action.ApiExplorer?.GroupName ?? controller.ApiExplorer?.GroupName, }; actionDescriptor.SetProperty(apiExplorerActionData); } }