OpenAPITools / OpenAPITools/openapi-generator
[JavaSpring] Bean Validation with Optional data type
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When generating code from a .yaml file using bean validation, e.g. maxLength=5, and with useOptional set true the generated code results in @Size(max=5) Optional<String> parameter instead of Optional<@Size(max=5) String> parameter.
openapi-generator version
4.1.3
OpenAPI declaration file content or url
Command line used for generation
openapi-generator generate -g spring -i api.yaml --additional-properties=useOptional=true
Steps to reproduce
Generate files by using command line command. The described problem is found in generated ThingsApi.java
Suggest a fix/enhancement
Changes in the corresponding queryParams.mustache.
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 the corresponding queryParams.mustache template and reproduce the issue using api.yaml and the documented openapi-generator command with useOptional=true. Inspect the generated ThingsApi.java; done means the validation annotation is placed inside Optional rather than on Optional itself, matching the expected generated parameter type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, openapi, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100