Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix handling of parameters for generic subresource locator methods #2075

Merged
merged 1 commit into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ protected boolean isSubResourceLocator(MethodInfo method) {
switch (method.returnType().kind()) {
case CLASS:
case PARAMETERIZED_TYPE:
case TYPE_VARIABLE:
return scannerContext.annotations().hasAnnotation(method, JaxRsConstants.PATH) &&
method.annotations()
.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

Expand Down Expand Up @@ -112,4 +113,39 @@ public SubresourceB getB1() {
test("resource.subresource-tag-placement-priority.json",
RootResource.class, SubresourceA.class, SubresourceB.class, ProducesText.class, RootA2Tag.class);
}

static class GenericInterfaceSubresourceTypes {
interface ScopedResource<R> {
@Path("park/{ident}")
public R park(@PathParam("ident") final String parkIdent);
}

@Path("/")
interface Resource extends ScopedResource<SubResource> {
}

static class ResourceImpl implements Resource {
@Override
public SubResource park(String parkIdent) {
return new SubResource();
}

}

static class SubResource {
@GET
@Path("/")
String yes() {
return "";
}
}
}

@Test
void testGenericInterfaceSubresource() throws IOException, JSONException {
test("resource.subresource-generic-type-variable.json", GenericInterfaceSubresourceTypes.ScopedResource.class,
GenericInterfaceSubresourceTypes.Resource.class,
GenericInterfaceSubresourceTypes.ResourceImpl.class,
GenericInterfaceSubresourceTypes.SubResource.class);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"openapi" : "3.1.0",
"paths" : {
"/park/{ident}" : {
"parameters" : [ {
"name" : "ident",
"in" : "path",
"required" : true,
"schema" : {
"type" : "string"
}
} ],
"get" : {
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"*/*" : {
"schema" : {
"type" : "string"
}
}
}
}
}
}
}
}
}