Abp中SwaggerUI的接口文档添加上传文件参数类型

[AttributeUsage(AttributeTargets.Parameter)]
public class SwaggerFileUploadAttribute : Attribute
{
public bool Required { get; private set; } public SwaggerFileUploadAttribute(bool Required = true)
{
this.Required = Required;
}
}
/// <summary>
/// swagger file upload parameter filter
/// </summary>
public class SwaggerFileUploadFilter : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
var parameters = apiDescription.ActionDescriptor.GetParameters();
foreach (HttpParameterDescriptor parameterDesc in parameters)
{
var fileUploadAttr = parameterDesc.GetCustomAttributes<SwaggerFileUploadAttribute>().FirstOrDefault();
if (fileUploadAttr != null)
{
operation.consumes.Add("multipart/form-data"); operation.parameters.Add(new Parameter
{
name = parameterDesc.ParameterName + "_file",
@in = "formData",
description = "file to upload",
required = fileUploadAttr.Required,
type = "file"
});
}
}
}
}
Abp中SwaggerUI的接口文档添加上传文件参数类型的更多相关文章
- Abp中SwaggerUI的接口说明文档配置
项目中集成了swashbuckle,那么通过访问http://ip:port/swagger/ui/index,可以看到提供的接口列表.接口列表默认是没有提供接口说明信息的,但是swagger内部是集 ...
- [转载]Java动态填充word文档并上传到服务器
一. 需求背景 在一些特殊应用场合,客户希望在服务器上生成文档的同时并填充数据,客户端的页面不显示打开文档,但是服务器上生成文档对服务器压力很大,目前服务器上生成文档第一种就是方式是jacob, 但是 ...
- [原创]Java动态填充word文档并上传到服务器
一. 需求背景 在一些特殊应用场合,客户希望在服务器上生成文档的同时并填充数据,客户端的页面不显示打开文档,但是服务器上生成文档对服务器压力很大,目前服务器上生成文档第一种就是方式是jacob, 但是 ...
- 使用django表单,使网页添加上传文件,并分析文件。
开发环境是: apache + python + django+ eclipse(开发环境) 欲达到目的: 在网页上,添加上传文件控件.然后读取csv文件,并分析csv文件. 操作步骤: django ...
- 返璞归真 asp.net mvc (11) - asp.net mvc 4.0 新特性之自宿主 Web API, 在 WebForm 中提供 Web API, 通过 Web API 上传文件, .net 4.5 带来的更方便的异步操作
原文:返璞归真 asp.net mvc (11) - asp.net mvc 4.0 新特性之自宿主 Web API, 在 WebForm 中提供 Web API, 通过 Web API 上传文件, ...
- Springboot中整合knife4j接口文档
在项目开发过程中,web项目的前后端分离开发,APP开发,需要由前端后端工程师共同定义接口,编写接口文档,之后大家都根据这个接口文档进行开发. 什么是knife4j 简单说knife4j就swagge ...
- spring boot:用swagger3生成接口文档,支持全局通用参数(swagger 3.0.0 / spring boot 2.3.2)
一,什么是swagger? 1, Swagger 是一个规范和完整的文档框架, 用于生成.描述.调用和可视化 RESTful 风格的 Web 服务文档 官方网站: https://swagger.i ...
- SharePoint 服务器端对象模型操作文档库(上传/授权/查看权限)
简介:上传文档到文档库,并对项目级授权,查看项目级权限方法 //在列表根目录下创建文件夹 public static string CreatFolderToSPDocLib(stri ...
- 百度大脑UNIT3.0解读之对话式文档问答——上传文档获取对话能力
在日常生活中,用户会经常碰到很多复杂的规章制度.规则条款.比如:乘坐飞机时,能不能带宠物上飞机,3岁小朋友是否需要买票等.在工作中,也会面对公司多样的规定制度和报销政策.比如:商业保险理赔需要什么材料 ...
随机推荐
- 理解go语言 协程之间的通讯
go已经越来越被重视了,特别适合大型互联网公司基础服务的编写,高效,高并发,可以同时允许多个明星出轨,多个明星结婚 都不在话下,下面介绍下GO协程通讯的过程 直接上代码 package main im ...
- WPF之坑——ICommandSource与RoutedUICommand
最近在项目中自己写了一个控件A,继承自contentcontrol,实现了icommandsource接口.(因需求特殊并没有使用buttonbase及它的派生类为基类),控件A在测试程序中运转良好, ...
- Asp.Net从相对路径获取绝对路径的方法(不需要httpcontext上下文也可)
//如果拿不到当前HttpContext上下文的话可以用该方法取得绝对路径 var filePath = HostingEnvironment.MapPath("需要获取绝对路径 的 相对路 ...
- AJPFX简评:MT5平台
MetaTrader 5全面改进的图表和扩展的功能 MetaTrader软件开发商在MT4获得全球交易商全面好评之后,又再次研发推出了更为先进的MT5交易软件. MT5的主要特征●改进的图表和即时 ...
- dpdk EAL: Error reading from file descriptor 23: Input/output error
执行test程序时输出: EAL: Error reading from file descriptor 23: Input/output error 原因: 在虚拟机添加的网卡,dpdk不支持导致的 ...
- 926. Flip String to Monotone Increasing
A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), ...
- Trie-648. Replace Words
In English, we have a concept called root, which can be followed by some other words to form another ...
- Codeforces450 B. Jzzhu and Sequences (找规律)
题目链接:https://vjudge.net/problem/CodeForces-450B Jzzhu has invented a kind of sequences, they meet th ...
- 【Azure】Publish Error of "%(TargetOSFamily.Identity)" that evaluates to "" instead of a number
在向Azure部署程序的时候,出现如下错误: A numeric comparison was attempted on "%(TargetOSFamily.Identity)" ...
- Centos6.7安装Pycharm及升级JDK
首先到pycharm官网下载pycharm压缩包 wget https://www.jetbrains.com/pycharm/download/download-thanks.html?platfo ...