private void PopulateActionDescriptions(HttpActionDescriptor actionDescriptor, IHttpRoute route, string localPath, Collection<ApiDescription> apiDescriptions) { string apiDocumentation = GetApiDocumentation(actionDescriptor); // parameters IList<ApiParameterDescription> parameterDescriptions = CreateParameterDescriptions(actionDescriptor); // expand all parameter variables string finalPath; if (!TryExpandUriParameters(route, localPath, actionDescriptor, parameterDescriptions, out finalPath)) { // the action cannot be reached due to parameter mismatch, e.g. routeTemplate = "/users/{name}" and GetUsers(id) return; } // request formatters ApiParameterDescription bodyParameter = parameterDescriptions.FirstOrDefault(description => description.Source == ApiParameterSource.FromBody); IEnumerable<MediaTypeFormatter> supportedRequestBodyFormatters = bodyParameter != null ? actionDescriptor.Configuration.Formatters.Where(f => f.CanReadType(bodyParameter.ParameterDescriptor.ParameterType)) : Enumerable.Empty<MediaTypeFormatter>(); // response formatters Type returnType = actionDescriptor.ReturnType; IEnumerable<MediaTypeFormatter> supportedResponseFormatters = returnType != null ? actionDescriptor.Configuration.Formatters.Where(f => f.CanWriteType(returnType)) : Enumerable.Empty<MediaTypeFormatter>(); // get HttpMethods supported by an action. Usually there is one HttpMethod per action but we allow multiple of them per action as well. IList<HttpMethod> supportedMethods = DefaultExplorer.GetHttpMethodsSupportedByAction(route, actionDescriptor); foreach (HttpMethod method in supportedMethods) { var description = new ApiDescription() { Documentation = apiDocumentation, HttpMethod = method, RelativePath = finalPath, ActionDescriptor = actionDescriptor, Route = route }; description.SetResponseDescription(CreateResponseDescription(actionDescriptor)); foreach (var mtf in supportedRequestBodyFormatters) description.SupportedRequestBodyFormatters.Add(mtf); foreach (var mtf in supportedResponseFormatters) description.SupportedResponseFormatters.Add(mtf); foreach (var par in parameterDescriptions) description.ParameterDescriptions.Add(par); apiDescriptions.Add(description); } }