/// <summary> /// Determines whether the controller should be considered for <see cref="P:System.Web.Http.Description.IApiExplorer.ApiDescriptions" /> generation. Called when initializing the <see cref="P:System.Web.Http.Description.ApiExplorer.ApiDescriptions" />. /// </summary> /// <param name="controllerVariableValue">The controller variable value from the route.</param> /// <param name="controllerDescriptor">The controller descriptor.</param> /// <param name="route">The route.</param> /// <returns> /// true if the controller should be considered for <see cref="P:System.Web.Http.Description.IApiExplorer.ApiDescriptions" /> generation, false otherwise. /// </returns> /// <exception cref="T:System.ArgumentNullException">controllerDescriptor</exception> /// <exception cref="T:System.ArgumentNullException">route</exception> public virtual bool ShouldExploreController(string controllerVariableValue, HttpControllerDescriptor controllerDescriptor, IHttpRoute route) { //if (string.IsNullOrEmpty(this.Area)) // return false; Throw.IfArgumentNull(controllerDescriptor, "controllerDescriptor"); Throw.IfArgumentNull(route, "route"); ApiExplorerSettingsAttribute setting = controllerDescriptor.GetCustomAttributes <ApiExplorerSettingsAttribute>().FirstOrDefault(); var controllerType = controllerDescriptor.ControllerType.FullName; string area = route.Defaults.ContainsKey("area") ? route.Defaults["area"].ToString().ToLower() : string.Empty; bool shouldExplore = (setting == null || !setting.IgnoreApi) && (string.IsNullOrEmpty(area) || string.IsNullOrEmpty(this.Area) || area == this.Area.ToLower()) && (controllerType.ToLower().Contains(string.Format(".{0}.", area)) && controllerType.ToLower().EndsWith(string.Format(".{0}{1}", controllerDescriptor.ControllerName.ToLower(), DefaultHttpControllerSelector.ControllerSuffix.ToLower()))) && MatchRegexConstraint(route, ControllerVariableName, controllerVariableValue) && this._version == controllerDescriptor.Version(); return(shouldExplore); }