diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java index 4271339ce3c8ff..43b6427f271f6c 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/main/java/io/quarkus/resteasy/reactive/server/deployment/QuarkusServerEndpointIndexer.java @@ -10,6 +10,7 @@ import java.util.function.Predicate; import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.PathSegment; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.ClassInfo; @@ -26,6 +27,7 @@ import org.jboss.resteasy.reactive.server.core.parameters.converters.NoopParameterConverter; import org.jboss.resteasy.reactive.server.core.parameters.converters.ParameterConverter; import org.jboss.resteasy.reactive.server.core.parameters.converters.ParameterConverterSupplier; +import org.jboss.resteasy.reactive.server.core.parameters.converters.PathSegmentParamConverter; import org.jboss.resteasy.reactive.server.core.parameters.converters.RuntimeResolvedConverter; import org.jboss.resteasy.reactive.server.processor.ServerEndpointIndexer; import org.jboss.resteasy.reactive.server.processor.ServerIndexedParameter; @@ -133,6 +135,8 @@ protected ParameterConverterSupplier extractConverter(String elementType, IndexV if (delegate == null) throw new RuntimeException("Failed to find converter for " + elementType); return delegate; + } else if (elementType.equals(PathSegment.class.getName())) { + return new PathSegmentParamConverter.Supplier(); } MethodDescriptor fromString = null; diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/HelloResource.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/HelloResource.java index c172e743f13dfd..d8945d236d4372 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/HelloResource.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/HelloResource.java @@ -1,7 +1,11 @@ package io.quarkus.resteasy.reactive.server.test.path; +import java.util.List; + import javax.ws.rs.GET; import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.core.PathSegment; /** * Per spec: @@ -25,4 +29,10 @@ public String hello() { public String nested() { return "world hello"; } + + @GET + @Path("{keyword:.*}") + public String searchByKeywords(@PathParam("keyword") List keywords) { + return keywords.toString(); + } } diff --git a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/RestPathTestCase.java b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/RestPathTestCase.java index 96acfeb0d4fccc..1823281d654731 100644 --- a/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/RestPathTestCase.java +++ b/extensions/resteasy-reactive/quarkus-resteasy-reactive/deployment/src/test/java/io/quarkus/resteasy/reactive/server/test/path/RestPathTestCase.java @@ -25,4 +25,11 @@ public void testRestPath() { RestAssured.when().get("/app/foo/hello").then().statusCode(200).body(Matchers.is("hello")); RestAssured.when().get("/app/foo/hello/nested").then().statusCode(200).body(Matchers.is("world hello")); } + + @Test + public void testListOfPathParams() { + RestAssured.basePath = "/"; + RestAssured.when().get("/app/foo/hello/bar/baz/boo/bob").then().statusCode(200) + .body(Matchers.is("[bar, baz, boo, bob]")); + } } diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/PathParamExtractor.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/PathParamExtractor.java index 3a018f4651cc54..60d592571dba98 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/PathParamExtractor.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/parameters/PathParamExtractor.java @@ -1,5 +1,6 @@ package org.jboss.resteasy.reactive.server.core.parameters; +import java.util.List; import org.jboss.resteasy.reactive.common.util.Encode; import org.jboss.resteasy.reactive.server.core.ResteasyReactiveRequestContext; @@ -7,18 +8,24 @@ public class PathParamExtractor implements ParameterExtractor { private final int index; private final boolean encoded; + private final boolean single; - public PathParamExtractor(int index, boolean encoded) { + public PathParamExtractor(int index, boolean encoded, boolean single) { this.index = index; this.encoded = encoded; + this.single = single; } @Override public Object extractParameter(ResteasyReactiveRequestContext context) { String pathParam = context.getPathParam(index); if (encoded) { - return Encode.encodeQueryParam(pathParam); + pathParam = Encode.encodeQueryParam(pathParam); + } + if (single) { + return pathParam; + } else { + return List.of(pathParam.split("/")); } - return pathParam; } } diff --git a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java index 14d865cbc5563f..e2c1cbe2dfe4fa 100644 --- a/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java +++ b/independent-projects/resteasy-reactive/server/runtime/src/main/java/org/jboss/resteasy/reactive/server/core/startup/RuntimeResourceDeployment.java @@ -536,7 +536,7 @@ public ParameterExtractor parameterExtractor(Map pathParameterI extractor = new NullParamExtractor(); } } else { - extractor = new PathParamExtractor(index, encoded); + extractor = new PathParamExtractor(index, encoded, single); } return extractor; case CONTEXT: