.xlsx文件上传,swagger codegn不会为Multipartfile生成@RequestParam
我必须上传存储在 .xlsx
文件中的交易。我正在尝试使用 swagger codegen 生成 api。我浏览了有关该问题的每个 stackoverflow 线程,但没有找到解决方案。
我确实有一个合同:
/accounts/import/transactions:
post:
tags:
- Account Transaction
operationId: uploadTransactions
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
200:
description: 'Upload successful'
400:
...
swagger 依赖项:
<springfox-swagger-ui>3.0.0</springfox-swagger-ui>
<springfox-swagger2>3.0.0</springfox-swagger2>
<swagger-codegen-maven-plugin>3.0.21</swagger-codegen-maven-plugin>
我获得的 API 缺少 @RequestParam("file") MultiPartFile 文件
。知道我做错了什么吗?这和 Swagger 版本有什么关系吗?
@RequestMapping(value = "/accounts/import/transactions",
produces = { "application/json" },
consumes = { "multipart/form-data" },
method = RequestMethod.POST)
default ResponseEntity<Void> uploadTransactions() {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default AccountsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
I have to upload transactions stored in .xlsx
file. I'm trying to generate api using swagger codegen. I have browsed through every stackoverflow thread regarding the problem, but found no solution.
I do have a contract:
/accounts/import/transactions:
post:
tags:
- Account Transaction
operationId: uploadTransactions
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
responses:
200:
description: 'Upload successful'
400:
...
swagger dependencies:
<springfox-swagger-ui>3.0.0</springfox-swagger-ui>
<springfox-swagger2>3.0.0</springfox-swagger2>
<swagger-codegen-maven-plugin>3.0.21</swagger-codegen-maven-plugin>
The API I get is missing @RequestParam("file") MultiPartFile file
. Any idea what I'm doing wrong? Does this have anything to do with Swagger versions?
@RequestMapping(value = "/accounts/import/transactions",
produces = { "application/json" },
consumes = { "multipart/form-data" },
method = RequestMethod.POST)
default ResponseEntity<Void> uploadTransactions() {
if(getObjectMapper().isPresent() && getAcceptHeader().isPresent()) {
} else {
log.warn("ObjectMapper or HttpServletRequest not configured in default AccountsApi interface so no example is generated");
}
return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论