Skip to content

[BUG] [JAVA] [JAXRS-SPEC] jarxrs-spec generators adds @Valid annotation to standard java types / enums #14432

Closed
@anatoliy-balakirev

Description

@anatoliy-balakirev

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

When using openapi-generator-maven-plugin with jaxrs-spec generator and enabled bean validation, the plugin generates @Valid annotation for all properties. @Valid annotation is only needed for objects, where the cascading validation is required. For standard Java types and enums it is useless. Moreover, when those annotations are there for those types - Hibernate Validator's performance degrades significantly (see: https://hibernate.atlassian.net/browse/HV-1928 and https://hibernate.atlassian.net/browse/HV-1933). I've checked other available generators and it looks like spring generates those annotations properly.

openapi-generator version

6.2.1. This is not a regression.

OpenAPI declaration file content or url

https://github.com/anatoliy-balakirev/openapi_generator_jaxrs_spec_validation_issue/blob/main/src/main/resources/models.yaml

Generation Details

See here:
https://github.com/anatoliy-balakirev/openapi_generator_jaxrs_spec_validation_issue/blob/main/pom.xml#L39-L62
And here:
https://github.com/anatoliy-balakirev/openapi_generator_jaxrs_spec_validation_issue/blob/main/pom.xml#L74-L86

Steps to reproduce
Related issues/PRs
Suggest a fix

Use beanValidation.mustache and pojo.mustache from the spring generator in the jaxrs-spec one.

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