如何从文件上传API的Swagger UI中删除/隐藏主体参数

问题描述

我是使用jersey框架进行UI开发的新手。我正在寻找解决以下问题的方法

问题:无法从Swagger UI中删除/隐藏主体参数。有关详细信息,请参阅随附的swagger-ui屏幕。

enter image description here

请找到我的Java源代码

@POST @Path("/createSchedule") 
@Consumes(MediaType.MULTIPART_FORM_DATA) 
@Produces({ MediaType.APPLICATION_JSON }) 
@ApiOperation(httpMethod = HttpMethod.POST,value = "Create a new export schedule(s)") @ApiImplicitParams({ @ApiImplicitParam(name = "file",value = "Upload the template (.xlsx) to create schedule(s).",required = true,dataType = "file",paramType = "formData") }) 
public Response createSchedule(@FormDataParam(value="file") InputStream inputStream,@FormDataParam(value="file") FormDataContentdisposition fileMetaData) throws ScheduleException {
********* Code to process the uploaded file. **********
}

我使用了Jersey 2.29.1(jersey-container-servlet)和Swagger 1.5.0(swagger-jaxrs)API。还要让我知道如何只允许特定的文件扩展名(例如.xlsx)从swagger ui上传

提前谢谢!干杯!

解决方法

我通过以下代码更改来解决此问题:

  1. 已将swagger Maven依赖项从“ swagger-jaxrs ”更改为“ swagger-jersey2-jaxrs
  2. 包括带有资源方法参数的“ @ApiParam”招摇批注,例如“ @ApiParam(hidden = true) @FormDataParam(value =“ file”)FormDataContentDisposition fileMetaData”。

请参考已解决的swagger ui屏幕问题: enter image description here