Closed Tucos closed 3 years ago
Interesting, I didn't knew that. The playground doesn't use bean validations ;-)
Thanks for the sample and test :-)
Now that it passes the test, I noticed that the @Introspected javadoc mentions a workaround :-)
The annotation can provide a list of classes that should be introspected:
@Introspected(classes=MyBean.class)
public class MyConfiguration {}
Hi,
Small note: this issue is not important to me; I can stick with spring or add the hibernate validator for the current project.
Micronaut requires an
Introspected
annotation on POJOs that need validation (ref micronaut docs). Currently this annotation is missing from POJOs generated by openapi-processor-micronaut.I've created a small project that demonstrates the problematic behavior. It's a bare micronaut project with openapi-processor added. The API has a single endpoint that requires a body with a single required property. The one and only testcase
EndpointControllerTest
calls the endpoint with that parameter missing.This test fails with the following error:
Cannot validate com.example.api.model.EndpointBody. No bean introspection present. Please add @Introspected to the class and ensure Micronaut annotation processing is enabled
. After adding the annotation to the generatedEndpointBody
the test succeeds. Adding the hibernate validator to the project dependencies will also make it succeed.I've added an example integration test in this commit: Tucos/openapi-processor-micronaut@ee1616beac290a902cef179759bf52a7589647d9.