private void AddMetadatas(string httpMethod, bool pathParameter = false) { if (!Settings.EnableMetadatas) { return; } var routeActionMetadata = new RouteActionMetadata { HttpMethod = httpMethod, RelativePath = Template, ReturnType = httpMethod == HttpMethods.Get ? typeof(T) : null, InputType = httpMethod != HttpMethods.Get ? typeof(T) : null }; if (httpMethod == HttpMethods.Get) { routeActionMetadata.ReturnType = typeof(T); if (pathParameter) { routeActionMetadata.InputType = typeof(string); routeActionMetadata.InputLocation = InputLocation.Path; } } else if (httpMethod == HttpMethods.Post) { routeActionMetadata.InputType = typeof(T); } else if (httpMethod == HttpMethods.Put) { routeActionMetadata.InputType = typeof(T); } else if (httpMethod == HttpMethods.Delete) { routeActionMetadata.InputType = typeof(string); routeActionMetadata.InputLocation = InputLocation.Path; } Metadatas.RouteActionMetadatas.Add(routeActionMetadata); }
private Operation CreateOperation(IEnumerable <RouteActionMetadata> metadatas, string httpMethod) { RouteActionMetadata metadata = metadatas.FirstOrDefault(m => m.HttpMethod == httpMethod); if (metadata == null) { return(null); } string operationId = metadata.RelativePath.Capitalize(); var operation = new Operation { OperationId = operationId, Tags = new List <string> { operationId }, Responses = metadata.ReturnType != null?SuccessResponses(metadata.ReturnType) : SuccessResponses(), Produces = metadata.ContentTypes, Parameters = GetParameter(metadata.InputType, metadata.InputLocation) }; return(operation); }