Hello, I already posted this question on stackoverflow, but nobody answered it there (https://stackoverflow.com/questions/53189770/can-not-upload-file-when-using-a-swagger-generated-spring-server). So I hope that someone on the dedicated servers will be able to help me.
I want to implement a file readout function on my REST Service. Since I do not know how to use spring myself, I use swagger to generate the server code for me. Normally this works perfectly fine, but when I try to upload files I get the following error: { "timestamp": "2018-11-07T12:27:43.119Z", "status": 400, "error": "Bad Request", "exception": "org.springframework.web.multipart.support.MissingServletRequestPartException", "message": "Required request part 'file' is not present", "path": "/requirements/import" } My yaml uses the following lines for the import function: /requirements/import: post: consumes: - multipart/form-data description: Returns all requirements contained in the submitted reqIf file. parameters: - name: reqIfFile in: formData type: file description: The reqIf file that contains the requirements. responses: 200: description: An array of requirements. schema: type: array items: $ref: 'requirement' The generated interface (with some added exceptions): @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2018-04-05T07:19:00.887Z") @Api(value = "requirements", description = "the requirements API") public interface RequirementsApi { @ApiOperation(value = "", nickname = "requirementsImportPost", notes = "Returns all requirements contained in the submitted reqIf file.", response = Requirement.class, responseContainer = "List", tags = {}) @ApiResponses(value = { @ApiResponse(code = 200, message = "An array of requirements.", response = Requirement.class, responseContainer = "List") }) @CrossOrigin(origins = "*") @RequestMapping(value = "/requirements/import", produces = { "application/json" }, consumes = { "multipart/form-data" }, method = RequestMethod.POST) ResponseEntity<List<Requirement>> requirementsImportPost( @ApiParam(value = "file detail") @Valid @RequestPart("file") MultipartFile reqIfFile) throws IOException, ContinuumException; } The code that actually does the readout: @javax.annotation.Generated(value = "io.swagger.codegen.languages.SpringCodegen", date = "2018-04-05T07:19:00.887Z") @Controller public class RequirementsApiController implements RequirementsApi { @Override public ResponseEntity<List<Requirement>> requirementsImportPost( @ApiParam(value = "file detail") @Valid @RequestPart("file") final MultipartFile reqIfFile) throws IOException, ContinuumException { InputStream fileStream = new BufferedInputStream(reqIfFile. getInputStream()); List<Requirement> list = ReadReqIF.readReqIfFile(fileStream); return new ResponseEntity<List<Requirement>>(list, HttpStatus.OK); } } Can someone tell me where a possible error is? -- You received this message because you are subscribed to the Google Groups "Swagger" group. To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggersocket+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.