OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JAVA] [SPRING] Optional values aren't optional in POJOs, only in path params
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
Description
Optional values aren't optional in POJOs, only in path params.
openapi-generator version
5.3.0
OpenAPI declaration file content or url
modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml
Generation Details
generatorName: spring
outputDir: samples/openapi3/server/petstore/springboot-nullable
inputSpec: modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml
templateDir: modules/openapi-generator/src/main/resources/JavaSpring
additionalProperties:
groupId: org.openapitools.openapi3
documentationProvider: springdoc
artifactId: springboot
snapshotVersion: "true"
hideGenerationTimestamp: "true"
openApiNullable: "true"
useOptional: "true"
Steps to reproduce
Generate POJOs
Related issues/PRs
Suggest a fix
Update pojo.mustache to enable optional fields and any updates required for nullables
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 with modules/openapi-generator/src/main/resources/JavaSpring/pojo.mustache and reproduce generation using modules/openapi-generator/src/test/resources/3_0/petstore-with-nullable-required.yaml with useOptional and openApiNullable enabled. Compare generated POJOs with the path-parameter behavior and verify that optional and nullable fields are represented as intended.
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
- Mostly clear
- Newbie friendliness
- 35/100