Skip to content

Conversation

@Mattias-Sehlstedt
Copy link
Contributor

Pull Request

Thank you for contributing to swagger-core!

Please fill out the following information to help us review your PR efficiently.


Description

This is a step towards exposing an easier way of extending how BeanValidatorAnnotations can be introspected and added to the generated schema. It is a sometimes reoccurring request to add different annotations, and sometimes custom ones too. The current main way of extending it is to override two large methods (see links in third paragraph).

I would find beneficial if there was an isolated method that was responsible for applying bean validations, so that clients could then only overload that. The end result being something similar to how springdoc offers this type of customization functionality.

Currently the annotation -> contraint logic is defined in two locations, depending on whether validation groups are in effect or not. An illustration of this can be seen in the PR that introduces additional validations.

Fixes:

Centralizes the definitions of how a bean validation annotation should affect a schema's constraints into a single location/class. Currently it is defined in two locations, where it is also coupled to the logic that determines whether the constrains should be added or not to the schema (depending on validation groups).

This PR decouples them and places the definitions in a separate component (ValidationAnnotationsUtils) and lets the logic for application then invoke that and ask for the definitions if necessary.

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • ♻️ Refactor (non-breaking change)
  • 🧪 Tests
  • 📝 Documentation
  • 🧹 Chore (build or tooling)

Checklist

  • I have added/updated tests as needed
  • I have added/updated documentation where applicable
  • The PR title is descriptive
  • The code builds and passes tests locally
  • I have linked related issues (if any)

Screenshots / Additional Context

@Mattias-Sehlstedt Mattias-Sehlstedt force-pushed the annotation-validator-utils branch from d66dd4c to 1435d2c Compare January 30, 2026 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant