OpenAPITools / OpenAPITools/openapi-generator

spring generator validation annotations doesn't work

Open
#10,475 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
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

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 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.