Closed gschlueter-jaconi closed 2 years ago
This code structure is somewhat common if MVC controllers are generated based on OpenAPI specs via the OpenAPI generator plugins. It is therefore not easy to workaround this problem (by avoiding interfaces or putting annotations at a different method).
This should be supported with upcoming Spring Framework 6 and Spring Boot 3 where most development effort is done these days. Validation support is still WIP, I will make sure the interface level @Validated
is supported.
When putting a
@Validated
annotation on an interface and implementing that interface (with at least one method) in a Spring MVC REST controller, no mapping for the controller is created and a 404 is returned.A simple example looks like this:
and the implementation:
An example project can be found here: https://github.com/jaconi-io/native-validated-controller.
Running
./gradlew test
succeeds while./gradlew nativeTest
fails for 2 of the 4 tests. When building the native image and running it, mappings for 2 of the 4 controllers will be created.