记一下post请求文件和对象一起传输(form表单提交)swagger显示问题


1.swagger的form表单提交文件和对象

@PostMapping(value = "/{id}/secondPage", headers = "content-type=multipart/form-data")
@ApiOperation(httpMethod = "POST", value = "字段1,字段2,字段3/文件导入(包括增加/更新)")
@ApiImplicitParams({
        @ApiImplicitParam(name = "file", value = "excel文件", required = false, paramType = "form", dataType = "__file"),
        @ApiImplicitParam(name = "channelList", value = "字段1", required = true, paramType = "form", allowMultiple = true, dataType = "string"),
        @ApiImplicitParam(name = "organList", value = "字段2", required = true, paramType = "form", allowMultiple = true, dataType = "string"),
        @ApiImplicitParam(name = "accountList", value = "字段3", required = false, paramType = "form", allowMultiple = true, dataType = "string"),
        @ApiImplicitParam(name = "organIdList", value = "字段4", required = false, paramType = "form", allowMultiple = true, dataType = "string")
})
public ResponseData createLearningPlanSecond(@ApiParam(name = "id", value = "学习计划ID", required = true) @PathVariable(required = true) String id,
                                             @ApiParam(name = "format", value = "字段1,字段2,字段3/文件导入(包括增加/更新)", required = true) @RequestParam(required = true) Integer format,
                                             @ApiParam(name = "secondDto", value = "第二页数据:字段1/字段2/字段3(选择/文件导入)") @Valid @ModelAttribute LearningPlanSecondDTO secondDto) {
    return Result.ok(learningPlanService.createLearningPlanSecond(id, secondDto, format));
}

 

2.使用swagger测试后后端会多一个双引号

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM