swagger-api / swagger-api/swagger-codegen
[JavaSpring] @MultiParam generated for multipart/form-data part with complex data instead of @MultiPart
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
When the OpenAPI 3.0 YAML definition contains a multipart/form-data with a part referencing a complex schema, then the generated server-side interface defines a @MultiParam for the given part instead of a @MultiPart.
Swagger-codegen version
3.0.16
Swagger declaration file content or url
openapi: 3.0.0
info:
version: "0.1"
paths:
/testbug/:
post:
requestBody:
content:
multipart/form-data:
schema:
type: object
properties:
firstPart:
$ref: "#/components/schemas/MyInput"
secondPart:
type: string
format: binary
responses:
"200":
description: OK
components:
schemas:
MyInput:
type: object
properties:
myInputField:
type: string
Command line used for generation
java -jar swagger-codegen-cli-3.0.16.jar generate -l spring -o output -i swagger.yaml
Steps to reproduce
Run above command on above OpenAPI 3.0 YAML content and check generated file output/src/main/java/io/swagger/api/TestbugApi.java
Related issues/PRs
None.
Suggest a fix/enhancement
Root cause seems bug in resource handlebars/JavaSpring/formParams.mustache in swagger-codegen-generators-1.0.16.jar.
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
Run the reported swagger-codegen CLI command with the supplied OpenAPI YAML and inspect output/src/main/java/io/swagger/api/TestbugApi.java. Then read resource handlebars/JavaSpring/formParams.mustache to trace how the complex multipart part is rendered. Done means the generated interface uses @MultiPart for firstPart instead of @MultiParam.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100