Skip to content

Commit

Permalink
Normalize CDIWrappers to an interface that they implement for Validator
Browse files Browse the repository at this point in the history
  • Loading branch information
marko-bekhta committed Aug 20, 2024
1 parent 7bbbfe2 commit 2d5a243
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
*/
public class ArcProxyBeanMetaDataClassNormalizer implements BeanMetaDataClassNormalizer {

private static final String CDI_WRAPPER_SUFFIX = "$$CDIWrapper";

@SuppressWarnings("unchecked")
@Override
public <T> Class<? super T> normalize(Class<T> beanClass) {
Class<? super T> targetClass = beanClass;
Expand All @@ -24,6 +27,14 @@ public <T> Class<? super T> normalize(Class<T> beanClass) {
while (ClientProxy.class.isAssignableFrom(targetClass)) {
targetClass = targetClass.getSuperclass();
}
if (beanClass.isSynthetic() && beanClass.getSimpleName().endsWith(CDI_WRAPPER_SUFFIX)) {
String nameToFind = beanClass.getName().substring(0, beanClass.getName().length() - (CDI_WRAPPER_SUFFIX.length()));
for (Class<?> anInterface : targetClass.getInterfaces()) {
if (nameToFind.equals(anInterface.getName())) {
return (Class<? super T>) anInterface;
}
}
}
return targetClass;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-jaxb</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-validator</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package io.quarkus.it.hibernate.validator;

import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.groups.ConvertGroup;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Response;

import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

@RegisterRestClient
@Path("/test")
public interface TestInterfaceRestClient {
@POST
@Consumes({ "application/json" })
Response doSomething(@Valid @ConvertGroup(to = Error.class) @NotNull String myParameter);
}

0 comments on commit 2d5a243

Please sign in to comment.