swagger-api / swagger-api/swagger-codegen
Generage code for upload file is wrong
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Swagger-codegen version
3.0.36
Description
I have a api as follow:
/v1/mch-mgr/merchants/{merchantId}/products/{productId}/head:
If i write detail info with the api in the same file, it is work success
/v1/mch-mgr/merchants/{merchantId}/products/{productId}/head:
post:
operationId: updateHead
tags:
- MchMgrProduct
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
security:
- BearerAuth: [ ]
responses:
200:
description: "success"
Tthe generate code is right:
@Override
public ResponseEntity<Void> updateHead(MultipartFile file) {
return MchMgrProductApi.super.updateHead(file);
}
If i write detail info with the api in different files, it is wrong:
/v1/mch-mgr/merchants/{merchantId}/products/{productId}/head:
$ref: ./resources/mch-mgr/product/product-head.yaml
product-head.yaml file:
post:
operationId: updateHead
tags:
- MchMgrProduct
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
file:
type: string
format: binary
security:
- BearerAuth: [ ]
responses:
200:
description: "success"
Tthe generate code is wrong:
@Override
public ResponseEntity<Void> updateHead(String file) {
return MchMgrProductApi.super.updateHead(file);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the difference in Swagger-codegen 3.0.36 between the inline endpoint and the external product-head.yaml reference. Trace Java generation for the multipart/form-data file property and compare the generated updateHead signatures. Done means both definitions generate MultipartFile rather than String.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi
- Domain
- backend-api-design, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100