BotSharp/BotSharp.WebHost/SwaggerFileUploadOperation.cs

28 lines
884 B
C#
Raw Normal View History

2020-09-07 10:17:58 +00:00
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.Swagger;
using Swashbuckle.AspNetCore.SwaggerGen;
using System;
using System.Collections.Generic;
2018-08-27 14:14:20 +00:00
using System.Linq;
using System.Text;
namespace BotSharp.WebHost
{
2020-09-08 07:23:07 +00:00
public class SwaggerFileUploadOperation : IOperationFilter
{
2018-08-27 14:14:20 +00:00
2020-09-08 07:23:07 +00:00
public void Apply(OpenApiOperation operation, OperationFilterContext context)
{
if(context.MethodInfo.Name == "Import")
{
if(operation.RequestBody.Content.FirstOrDefault().Value?.Schema?.Properties.ContainsKey("uploadedFile") == true)
{
var p = operation.RequestBody.Content.FirstOrDefault();
p.Value.Schema.Properties["uploadedFile"].Description = "Upload Zip File meta.json is the extra data for customized function.";
}
}
2020-09-07 10:17:58 +00:00
2020-09-08 07:23:07 +00:00
}
}
}