Vaadin Binder Validation with Swagger OpenAPI - is it possible?

Hello there,

I am currently working on a project that involves using Vaadin binders for data validation, and I would like to seek your insights on integrating this validation with Swagger OpenAPI.

I have a few specific questions:

  1. Recommended Approach: Is there a recommended approach to expose the validation rules defined in Vaadin binders through Swagger OpenAPI?
  2. Reflection of Annotations: Can the validation annotations used in Vaadin binders be automatically reflected in the OpenAPI documentation?
  3. Best Practices: Are there any best practices or examples you could share regarding this integration?

I appreciate any guidance or resources you can provide on this matter.
Thank you for your help!

We just wanna explore this possible solution (and avoid possible errors)

Best regards,
Wen Long Sun
AON Italy
License: Vaadin Pro

The first thing that comes to mind would be to define validation rules using bean validation annotations. These are supported by Vaadin’s BeanValidationBinder and to my understanding also used by https://springdoc.org/ when generating an OpenAPI schema.

At the same time, I would be a bit cautious with the idea since UI-level validation usually different from the kind of validation you might want todo in a REST API. Some parts are certainly similar but there might be enough differences to justify using separate DTOs for each part and thus also have separate validation rules.