Forum Discussion

ajayveluru's avatar
ajayveluru
New Contributor
4 years ago

Multiple Multipart Part File upload using Swagger 2 / OpenAPI 3

We have Spring Boot Rest Controller which accepts data and array of multipart files. We are using swagger 2.9.2.  Postman works fine. But when swagger.json from api-docs url is placed in editor.swagger.io, it is giving a lot of "Structural errors".

 

Rest Controller

@PostMapping (consumes = {MediaType.MULTIPART_FORM_DATA_VALUE},
produces = {MediaType.APPLICATION_JSON_VALUE})
@ApiOperation(value = "Report REST Service",
notes = "This sends an email notification based on the criteria added",
response = RestReportVO.class)
@ApiResponses(value = { @ApiResponse(code = 200, message = RestServiceConstants.MSG_200),
@ApiResponse(code = 400, message = RestServiceConstants.MSG_400, response = RestVO.class),
@ApiResponse(code = 500, message = RestServiceConstants.MSG_500, response = RestVO.class) })
public ResponseEntity<?> eReport(@RequestParam(value = "login_id", required = true) String loginId,,
@RequestParam(value = "uploaded_files", required = false) MultipartFile[] upFiles)

Structural Errors

Structural error at paths./error_report.post.parameters.0should NOT have additional properties additionalProperty: schema
Structural error at paths./error_report.post.parameters.0should have required property 'type' missingProperty: type
Structural error at paths./error_report.post.parameters.7.items.typeshould be equal to one of the allowed values allowedValues: string, number, integer, boolean, array
 
Excerpts from Swagger.json
consumes:
- multipart/form-data
produces:
- application/json
parameters:
- in: formData
name: login_id
description: login_id
required: true
schema:
type: string
- name: uploaded_files
in: formData
description: uploaded_files
required: false
type: array
items:
type: file
collectionFormat: multi