还有比这更好的解决方案吗(OpenApi send MultipartFile request with JSON get 'application / octet-stream' error not supported)?
@PostMapping(path = "", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@Operation(summary = "XX", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Das zu erstellende Ticket", content = @Content(schema = @Schema(implementation = TicketDTO.class))))
TicketDTO createTicket(@RequestPart() @Parameter(required = true) TicketDTO ticket,
@Parameter(description = "Files to be uploaded", content = @Content(mediaType = MediaType.MULTIPART_FORM_DATA_VALUE)) @RequestPart(value = "files", required = false) MultipartFile[] files)
throws MessagingException;
这对我不起作用。我在Swagger UI中看不到上传文件的选项。
1条答案
按热度按时间jgwigjjp1#
您不需要在@Operation中设置requestBody。
范例