swagger-api / swagger-api/swagger-codegen
[JavaSpring] multipart/form-data defined with required part is optional in the generated Java Spring Code
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 defined as required, then the generated server-side interface defines the given part as optional (required = false).
Swagger-codegen version
3.0.18
Swagger declaration file content or url
openapi: 3.0.0
info:
title: "testbug"
version: "0.1"
paths:
/testbug/:
post:
requestBody:
content:
multipart/form-data:
schema:
properties:
myPart:
type: object
required:
- myPart
responses:
"200":
description: OK
Command line used for generation
java -jar swagger-codegen-cli-3.0.18.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
N/A
Suggest a fix/enhancement
Root cause not known.
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 supplied swagger-codegen-cli 3.0.18 command with the YAML example and inspect output/src/main/java/io/swagger/api/TestbugApi.java. Trace how the multipart/form-data schema's required list is handled before the Spring interface is generated. Done means the generated part reflects the OpenAPI requirement with required=true.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100