Skip to content

Commit

Permalink
Fix handling of parameters for generic subresource locator methods
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Edgar <[email protected]>
  • Loading branch information
MikeEdgar committed Nov 20, 2024
1 parent f97730f commit ff23002
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 0 deletions.
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"
}
}
}
}
}
}
}
}
}

0 comments on commit ff23002

Please sign in to comment.