OpenAPITools / OpenAPITools/openapi-generator
spring generator validation annotations doesn't work
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
I am trying to generate spring code based on open-api spec version 3.0.1. When I run that project I noticed that sprin boot doesn't respect validation and it works like without validation.
openapi-generator version
5.2.1
OpenAPI declaration file content or url
https://gist.github.com/rajdippatel/1fa05a79f15bbcdd0b64c805973d9d13
Generation Details
openapi-generator-cli generate -g spring -i specs.yaml -o out/spring/openapi
Steps to reproduce
- Generate spring code based on specs.yaml and above config
- Once spring will be generated run code
- You will see /auth/login will be executed even if required attributes are present
Related issues/PRs
-
None
-
Suggest a fix
-
Enable performBeanValidation or useBeanValidation. But if I enable it I can see it injects "hibernate-validation" package and it fails to build project.
-
If I add hibernate-validation in pom dependency, project compiles but still validation doesn't work
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 specs.yaml and the generated Spring project produced by the documented openapi-generator-cli command. Inspect the generated /auth/login behavior, validation annotations, and the hibernate-validation dependency setup; done means the generated project builds and rejects requests missing required attributes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100