Swashbuckle Client Meta Informations
Hi there, I am working on an API to trans fair my own message types called "actions" to different computers who will authenticate to my API with the same certificate. For example, I have a queue of actions. {id990 - id999} PC 1 want to get the newest action(id999) PC 2 is a bit slower and still need action(id990) How could I get the information of PC 1 and PC 2, to identify them, so that I can handle who have already got the action and who not ? Is there a best Practice? Can I identify PC 1 and PC 2 in any way? Hostname, IP Address, Cookies or similar? Kind Regards BenCan't import/upload .XLSX/.XLS files in Swagger (ASP NET Core)
Hello guys, it's my first post here and I'm glad to be part of this community. So, I've an ASP NET Core Web API that uses Swagger, and one of the methods must import an IFormFile as an Excel (.xlsx or .xls). I've already added the corresponding MIME Types on my FileUploadOperation.cs but when I hit the Swagger button do execute the action after choose a .xlsx file, the field becomes red and I can't import the file. The code above is my FileUploadOperation.cs: public class FileUploadOperation : IOperationFilter { private const string formDataMimeType = "multipart/form-data"; private const string formDataMimeType2 = "application/vnd.ms-excel"; private const string formDataMimeType3 = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; private static readonly string[] formFilePropertyNames = typeof(IFormFile).GetTypeInfo().DeclaredProperties.Select(p => p.Name).ToArray(); public void Apply(Operation operation, OperationFilterContext context) { var parameters = operation.Parameters; if (parameters == null || parameters.Count == 0) return; var formFileParameterNames = new List<string>(); var formFileSubParameterNames = new List<string>(); foreach (var actionParameter in context.ApiDescription.ActionDescriptor.Parameters) { var properties = actionParameter.ParameterType.GetProperties() .Where(p => p.PropertyType == typeof(IFormFile)) .Select(p => p.Name) .ToArray(); if (properties.Length != 0) { formFileParameterNames.AddRange(properties); formFileSubParameterNames.AddRange(properties); continue; } if (actionParameter.ParameterType != typeof(IFormFile)) continue; formFileParameterNames.Add(actionParameter.Name); } if (!formFileParameterNames.Any()) return; var consumes = operation.Consumes; consumes.Clear(); consumes.Add(formDataMimeType); if (operation.OperationId.Equals("PostProcessBatch")) { consumes.Add(formDataMimeType2); consumes.Add(formDataMimeType3); } foreach (var parameter in parameters.ToArray()) { if (!(parameter is NonBodyParameter) || parameter.In != "formData") continue; if (formFileSubParameterNames.Any(p => parameter.Name.StartsWith(p + ".")) || formFilePropertyNames.Contains(parameter.Name)) parameters.Remove(parameter); } foreach (var formFileParameter in formFileParameterNames) { parameters.Add(new NonBodyParameter() { Name = formFileParameter, Type = "file", In = "formData" }); } } } Can anyone help me with the solution?1.1KViews0likes0Comments