OpenAPITools / OpenAPITools/openapi-generator
[BUG] [JavaSpring] apiDelegate.mustache template is missing useBeanValidation imports
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?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
apiDelegate.mustache is not including useBeanValidation flag, because of that when using validation tags on queryParams compilations fails because bean validation imports are not included
{{#useBeanValidation}}
import javax.validation.constraints.*;
import javax.validation.Valid;
{{/useBeanValidation}}
openapi-generator version
v6.0.0 and current master
OpenAPI declaration file content or url
Generation Details
<generatorName>spring</generatorName>
<library>spring-boot</library>
<useBeanValidation>true</useBeanValidation>
<delegatePattern>true</delegatePattern>
Steps to reproduce
Compile a swagger 2.0 spec with validation types in any queryparam
Related issues/PRs
N/A
Suggest a fix
Add useBeanValidation snippet used in https://github.com/OpenAPITools/openapi-generator/blob/master/modules/openapi-generator/src/main/resources/JavaSpring/apiController.mustache#L38
{{#useBeanValidation}}
import javax.validation.constraints.*;
import javax.validation.Valid;
{{/useBeanValidation}}
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/apiDelegate.mustache and compare its imports with apiController.mustache, especially when useBeanValidation is true. Reproduce with the spring generator, spring-boot library, delegatePattern, and a validation type on a query parameter. Done means the generated delegate compiles with the required bean validation imports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100