Swagger with Dropwizard

109 views
Skip to first unread message

Piyush Mendhiratta

unread,
Oct 9, 2017, 4:19:20 AM10/9/17
to dropwizard-user
I am trying to create swagger using the swaggerUI. My API framework uses dropwizard. Now when I am trying to use a GET resource with @Auth for authentication, swagger that is generated have a body that should have a "User". But ideally any GET request should not have a "body". ANy suggestions on how to deal with the situation. Or if anyone has used swagger with dropwizard.

@GET
@Path("/all/{userName}/")
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
value = "Journal Number",
notes = "Returns Journal Number for a company",
response = GeneralLedger.class,
authorizations = {@Authorization(value="basicAuth")})
public Response classInfoForUsername
(@Auth AuthenticatedUser user,
@PathParam("userName") String userName) {
....
}




Swagger generated is :

 "/class/all/{userName}" : {
      "get" : {
        "summary" : "Journal Number",
        "description" : "Returns Journal Number for a company",
        "operationId" : "classInfoForUsername",
        "consumes" : [ "application/json" ],
        "produces" : [ "application/json" ],
        "parameters" : [ {
          "in" : "body",
          "name" : "body",
          "required" : false,
          "schema" : {
            "$ref" : "#/definitions/AuthenticatedUser"
          }
        }, {
          "name" : "userName",
          "in" : "path",
          "required" : true,
          "type" : "string"
        } ],
        "responses" : {
          "default" : {
            "description" : "successful operation"
          }
        },
        "security" : [ {
          "basicAuth" : [ ]
        } ]
      }

Steve Kradel

unread,
Oct 10, 2017, 10:13:24 AM10/10/17
to dropwizard-user
Just add "@ApiParam(hidden=true)" to your @Auth parameter to get Swagger to understand it's not a request entity class.
Reply all
Reply to author
Forward
0 new messages