openapi-generator icon indicating copy to clipboard operation
openapi-generator copied to clipboard

[BUG][JAVA][SPRING] warning HV000271 appears in the logs after upgrade to 7.28.0

Open LeosBitto opened this issue 4 days ago • 2 comments

Bug Report Checklist

  • [x] Have you provided a full/minimal spec to reproduce the issue?
  • [x] Have you validated the input using an OpenAPI validator?
  • [x] Have you tested with the latest master to confirm the issue still exists?
  • [x] Have you searched for related issues/PRs?
  • [x] What's the actual output vs expected output?
  • [ ] [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When processing any REST API response the following warning is logged after upgrading to 7.28.0: HV000271: Using @Valid on a container (org.springframework.http.ResponseEntity) is deprecated. You should apply the annotation on the type argument(s).

openapi-generator version

7.28.0 (caused by the combination of #25215 and the recent versions of Hibernate Validator)

OpenAPI declaration file content or url

irrelevant - all lead to the same (mis)behaviour

Generation Details

Generate the interface by openapi-generator-maven-plugin with generatorName=spring, library=spring-boot, interfaceOnly=true, useResponseEntity=true, useBeanValidation=true.

Steps to reproduce

Create a RestController which implements the generated interface and then all requests end up with the warning logged by Hibernate Validator.

Related issues/PRs

Bug #23614 has solved a similar issue for validation of the requests. This bug is about validation of the responses.

Suggest a fix

Generate ResponseEntity<@Valid ...> instead of @Valid ResponseEntity<...> but only for the users who explicitly enable it, becaue otherwise the backward compatibility would be broken (users without implementation of ValueExtractor<ResponseEntity<@ExtractedValue ?>> would get errors).

LeosBitto avatar Nov 28 '26 17:11 LeosBitto

Hi! I'd like to work on this issue as my first contribution to OpenAPI Generator.

I've reviewed the reported behavior and the suggested fix. I understand that the goal is to support placing @Valid on the ResponseEntity type argument while preserving the existing behavior for backward compatibility.

I'm planning to investigate the Spring generator templates and the related configuration options and tests.

Would it be possible to assign this issue to me? Also, please let me know if there are any specific implementation preferences or considerations I should be aware of before proceeding.

Thanks!

Saeedhany avatar Nov 28 '26 23:11 Saeedhany

Hi! I'd like to work on this issue as my first contribution to OpenAPI Generator.

I have already proposed an implementation in #25860 - feel free to review it and put your comments there.

LeosBitto avatar Nov 29 '26 09:11 LeosBitto