Skip to content

Problem with subresource detection when using dependency injection in Jersey 2 #394

@joscarsson

Description

@joscarsson

This works fine:

@Path("/{objectId: [a-fA-F0-9]{32}}")
@ApiOperation(value = "subresource", response = SomeSubResource.class)
public SomeSubResource continueInSubResource() {
  return new SomeSubResource();
}

The problem occurs when using Jersey dependency injection for creating the resources. The code is then changed to this:

@Path("/{objectId: [a-fA-F0-9]{32}}")
@ApiOperation(value = "subresource", response = SomeSubResource.class)
public Class<SomeSubResource> continueInSubResource() {
  return SomeSubResource.class;
}

That is, we only tell Jersey which type of class we want, and Jersey dependency injection instantiates the correct class (passing in the dependencies to the constructor automatically). However, this seems to confuse swagger, which does not detect this subresource at all.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions