1

When I have @Auth and a body(object) in a POST API in Dropwizard getting the following error while running Tests:

Caused by: org.glassfish.jersey.server.model.ModelValidationException: Validation of the application resource model has failed during application initialization.

Here is my API code: `

@POST
@Path("api/v2/test/{id}/status")
@Timed
@ApiOperation(value = "Post your status",
        response = Response.class)
public Response postStatus(@Context HttpServletRequest requestContext,
                           @Context UriInfo requestUri,
                           PostStatusReq postStatusReq,
                           @Auth TestAAAuthenticator equip,
                           @PathParam("id") Long id

) {
    log.warn("postStatus: "+ postStatusReq);
    return Response.ok("OK").build();
}

I have these in my Parent class file:


final OAuthCredentialAuthFilter<User> oAuthCredentialAuthFilter = new OAuthCredentialAuthFilter.Builder<User>()
        .setAuthenticator(authenticator)
        .setAuthorizer(new AAAuthorizer())
        .setPrefix("Bearer")
        .buildAuthFilter();
environment.jersey().register(new AuthDynamicFeature(oAuthCredentialAuthFilter));

environment.jersey().register(new AuthValueFactoryProvider.Binder<>(User.class));

` Using Versions: Maven: 3.6.1 Java: 17 Dropwizard: 2.0.28

Tried looking up in stackoverflow and github for similar problem: https://github.com/dropwizard/dropwizard/issues/783 https://github.com/dropwizard/dropwizard/issues/1329

But I already have these in my code.

Btwn I'm using @Pathparam from javax.ws.rs Note: If I remove @Auth TestAAAuthenticator equip or PostStatusReq postStatusReq from the API request everything works fine. But I need both in API. Any help will be much appreciated. Thank you!

Raj
  • 11
  • 1

0 Answers0