我正在使用带有 Maven 插件 openapi-generator-maven-plugin (5.3.0) 的 Openapi V3 使用 multipart/form-data 上传多个文件。但是,生成的接口代码是不完整的 - 在默认方法之一中缺少 List 声明(一种方法将输入参数声明为List<MultipartFile> file
,另一种方法将其声明为MultipartFile file
):
default ResponseEntity<UploadDocumentsResponse> _uploadDocuments(@Valid @RequestPart(value = "file", required = false) List<MultipartFile> file) {
return uploadDocuments(authorization, file);
}
// Override this method
default ResponseEntity<UploadDocumentsResponse> uploadDocuments(MultipartFile file) {
...
}
这是规格:
/api/uploadDocuments:
post:
tags:
- documents
summary: Upload documents
description: Upload documents
operationId: uploadDocuments
requestBody:
required: true
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: array
items:
type: string
format: binary