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

Injected classes in jax-rs resource results in unexpected body parameter #1176

Closed
foxylion opened this issue Jun 17, 2015 · 2 comments
Closed
Assignees
Labels
Milestone

Comments

@foxylion
Copy link

Hi,
I hit a problem which seems to be, accordingly to ron of the IRC channel, a bug.

Given is a resource class as following, which is using dependency injection (in my case with guice):

@Path("/my-account")
@Produces(MediaType.APPLICATION_JSON)
@Api(tags = { "Users" })
public class MyAccountResource {

    private final MyAccountResourceImpl delegate;

    @javax.inject.Inject
    public MyAccountResource(MyAccountResourceImpl delegate) {
        this.delegate = delegate;
    }

    @GET
    @ApiOperation(value = "User details of the authenticated user", notes = "Redirects to the actual user resource", code = 303)
    public Response getMyAccountDetail() {
        return delegate.getMyAccountDetail();
    }
}

A snippet of the generated json exposes a body parameter for the get request with scheme MyAccountResourceImpl which is not expected.

    "/my-account" : {
      "get" : {
        "tags" : [ "Users" ],
        "summary" : "User details of the authenticated user",
        "description" : "Redirects to the actual user resource",
        "operationId" : "getMyAccountDetail",
        "produces" : [ "application/json" ],
        "parameters" : [ {
          "in" : "body",
          "name" : "body",
          "required" : false,
          "schema" : {
            "$ref" : "#/definitions/MyAccountResourceImpl"
          }
        } ],
        "responses" : {
          "default" : {
            "description" : "successful operation"
          }
        }
      }
    },

Good news for everyone who is using guice as the dependency injection framework - just use the @com.google.inject.Inject annotation instead of @javax.inject.Inject as a workaround.

@webron webron added this to the v1.5.1 milestone Jun 17, 2015
@iushankin
Copy link
Contributor

Will be fixed in #1191

@webron
Copy link
Contributor

webron commented Jul 15, 2015

Fixed in develop_2.0.

@webron webron closed this as completed Jul 15, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants