Skip to content

[Bug] [Spring] Invalid @Valid for List body parameter #24752

Description

@keesvandaalen

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator?
  • 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

A warning is logged for an endpoint that takes a list of items as the request body:

HV000271: Using @Valid on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s).

The endpoint works fine but may not do so in the future.

openapi-generator version

7.24.0

OpenAPI declaration file content or url

https://github.com/keesvandaalen/openapi-generator-demo/blob/main/api.yaml

Generation Details

https://github.com/keesvandaalen/openapi-generator-demo/blob/b38efb8270229f2f760dc4dae505e53d7420d1fa/pom.xml#L56

Steps to reproduce
  • Checkout https://github.com/keesvandaalen/openapi-generator-demo/tree/main
  • Run mvn spring-boot:run
  • Call the endpoint: curl -X POST -H 'Content-Type: application/json' -d '[1,2,3]' http://localhost:8080/api/v1/demo
  • Inspect the logs to see this warning: HV000271: Using @Valid on a container (java.util.List) is deprecated. You should apply the annotation on the type argument(s). Affected element: ApiApi#apiV1DemoPost(List)
Related issues/PRs

None

Suggest a fix

Uncomment templateDirectory and do the steps to reproduce again.
Now there is no warning.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions