diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/DataItem.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/DataItem.java new file mode 100644 index 00000000000000..83c660300629ff --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/DataItem.java @@ -0,0 +1,14 @@ +package io.quarkus.resteasy.reactive.jackson.deployment.test; + +public class DataItem { + + private T content; + + public T getContent() { + return content; + } + + public void setContent(T content) { + this.content = content; + } +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/Item.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/Item.java new file mode 100644 index 00000000000000..1d43c516a98938 --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/Item.java @@ -0,0 +1,23 @@ +package io.quarkus.resteasy.reactive.jackson.deployment.test; + +public class Item { + + private String name; + private String email; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java index 9df7219b1292a6..0a03af52e09a4a 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonResource.java @@ -235,6 +235,12 @@ public Multi getMulti0() { return Multi.createFrom().empty(); } + @POST + @Path("/genericInput") + public String genericInputTest(DataItem item) { + return item.getContent().getName(); + } + public static class UnquotedFieldsPersonBiFunction implements BiFunction { public static final AtomicInteger count = new AtomicInteger(); diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java index 493650f4034f98..83bc00d3b309fd 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jackson/deployment/src/test/java/io/quarkus/resteasy/reactive/jackson/deployment/test/SimpleJsonTest.java @@ -1,6 +1,7 @@ package io.quarkus.resteasy.reactive.jackson.deployment.test; import static org.hamcrest.Matchers.containsString; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; @@ -26,6 +27,7 @@ public class SimpleJsonTest { public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class) .addClasses(Person.class, SimpleJsonResource.class, User.class, Views.class, SuperClass.class, + DataItem.class, Item.class, NoopReaderInterceptor.class); } }); @@ -293,4 +295,17 @@ public void testCustomSerialization() { // a new instance should have been created assertEquals(3, SimpleJsonResource.UnquotedFieldsPersonBiFunction.count.intValue()); } + + @Test + public void testGenericInput() { + RestAssured + .with() + .body("{\"content\": {\"name\":\"foo\", \"email\":\"bar\"}}") + .contentType("application/json; charset=utf-8") + .post("/simple/genericInput") + .then() + .statusCode(200) + .contentType("text/plain") + .body(is("foo")); + } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/DataItem.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/DataItem.java new file mode 100644 index 00000000000000..80710dff681d6f --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/DataItem.java @@ -0,0 +1,14 @@ +package io.quarkus.resteasy.reactive.jsonb.deployment.test; + +public class DataItem { + + private T content; + + public T getContent() { + return content; + } + + public void setContent(T content) { + this.content = content; + } +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/Item.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/Item.java new file mode 100644 index 00000000000000..6e7db280ba19f2 --- /dev/null +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/Item.java @@ -0,0 +1,23 @@ +package io.quarkus.resteasy.reactive.jsonb.deployment.test; + +public class Item { + + private String name; + private String email; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } +} diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonResource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonResource.java index 63b61561e6bd84..991dfa0548b737 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonResource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonResource.java @@ -167,4 +167,10 @@ public Multi getMulti2() { public Multi getMulti0() { return Multi.createFrom().empty(); } + + @POST + @Path("/genericInput") + public String genericInputTest(DataItem item) { + return item.getContent().getName(); + } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonTest.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonTest.java index 2a2bfc677e0520..9337212cb9509f 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonTest.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive-jsonb/deployment/src/test/java/io/quarkus/resteasy/reactive/jsonb/deployment/test/SimpleJsonTest.java @@ -1,5 +1,6 @@ package io.quarkus.resteasy.reactive.jsonb.deployment.test; +import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.notNullValue; import static org.hamcrest.Matchers.nullValue; @@ -22,7 +23,7 @@ public class SimpleJsonTest { @Override public JavaArchive get() { return ShrinkWrap.create(JavaArchive.class) - .addClasses(Person.class, SimpleJsonResource.class, SuperClass.class); + .addClasses(Person.class, SimpleJsonResource.class, SuperClass.class, DataItem.class, Item.class); } }); @@ -200,4 +201,17 @@ public void testJsonMulti() { .contentType("application/json") .body(Matchers.equalTo("[]")); } + + @Test + public void testGenericInput() { + RestAssured + .with() + .body("{\"content\": {\"name\":\"foo\", \"email\":\"bar\"}}") + .contentType("application/json; charset=utf-8") + .post("/simple/genericInput") + .then() + .statusCode(200) + .contentType("text/plain") + .body(is("foo")); + } } diff --git a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java index 2552f813d50bd5..d6b0cf16204cc9 100644 --- a/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java +++ b/independent-projects/resteasy-reactive/common/processor/src/main/java/org/jboss/resteasy/reactive/common/processor/EndpointIndexer.java @@ -945,6 +945,9 @@ && isContextType(paramType.asClassType())) { builder.setOptional(true); } else if (convertible) { throw new RuntimeException("Invalid parameter type '" + pt + "' used on method " + errorLocation); + } else { + elementType = toClassName(pt.arguments().get(0), currentClassInfo, actualEndpointInfo, index); + typeHandled = true; } } else if ((paramType.name().equals(PATH_SEGMENT)) && (type == ParameterType.PATH)) { elementType = paramType.name().toString();