swagger-api / swagger-api/swagger-codegen

Spring Code Gen - @Validated missing in Generated API Code

Open
#10,402 1 comment 3 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'm using Swagger codegen maven plugin to generate the API and Model class. The generated API class don't have @Validated annotation, but it has imported that class.
Because of that, spring is not validating the request validation like @min(), @max() etc.

Swagger-codegen version

io.swagger.codegen.v3:swagger-codegen-maven-plugin:3.0.20

Steps to reproduce

https://editor.swagger.io/

Generate CodeGen Spring Server project, @Validated is missing in the API classes.

Related issues/PRs
Suggest a fix/enhancement

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 in https://editor.swagger.io/ with the Spring Server generator and compare the generated API class with its imported @Validated annotation. Trace the Swagger Codegen Maven plugin version 3.0.20 generation path, then verify that generated API classes include @Validated and that request constraints such as @Min and @Max are enforced.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, spring
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.