swagger-api / swagger-api/swagger-codegen

useBeanValidation set to false does not work. Annotations javax.validation.* are still produced

Open
#8,000 8 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

I am trying to turn off bean validation, so not @Validated would be used on generated model.
I can't. When I set false it is completely ignored.

Swagger-codegen version

2.3.1

Swagger declaration file content or url
Command line used for generation
io.swagger swagger-codegen-maven-plugin 2.3.1 generate-java-server generate ${basedir}/src/main/resources/api/pisp-api-swagger.yaml spring ${swagger.debug} Gen <title>${project.parent.name}</title> /src/main/java generated.rest.api generated.rest.model generated.rest spring-boot java8 true true false true false true true false false false true ${swagger.debug} ${swagger.debug} ${swagger.debug}
Steps to reproduce

Use the plugin configuration above and have the code generated.
It will still contain @Validated annotations, plus more javax.validation.*

Related issues/PRs

I haven't found any.

Suggest a fix/enhancement

Please advise, or fix it.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with the swagger-codegen Maven plugin configuration and generated Spring server models. Trace how the useBeanValidation option is handled and how @Validated and javax.validation annotations are selected. Done means setting useBeanValidation to false prevents those validation annotations from appearing in generated output.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring-boot
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.