1

I'm trying to implement swagger on my routes with akka-http 10.0.0 and swagger-akka-http 0.8.2. It works well but query parameter with type : UUID and Long are considered as undefined.

Should I use format?

How to use it?

Here is one of my route :

  @GET @Path("/{publisher_id}/{app_id}")
    @ApiOperation(
        value = "get a app Installation stat for an app ID",
        notes = "Returns a session based on ID",
        httpMethod = "GET"
    )
    @ApiImplicitParams(Array(
        new ApiImplicitParam(name = "app_id", value = "ID of app that needs to be fetched, format com.totot.plop ", required = true, dataType = "string", paramType = "path"),
        new ApiImplicitParam(name = "publisher_id", value = "publisher id : publisher_id ", required = true, dataType = "UUID?",  paramType = "path"),
        new ApiImplicitParam(name = "date_start", value = "Timestamp start date ", required = true, dataType = "LONG???" , paramType = "query"),
        new ApiImplicitParam(name = "date_end", value = "Timestamp end date", required = true, dataType = "LONG???", paramType = "query"),
        new ApiImplicitParam(name = "access_token", value = "session token of the user ", required = true, dataType = "UUID????", paramType = "query")
    ))
    @ApiResponses(Array(
        new ApiResponse(code = 404, message = "App not found"),
        new ApiResponse(code = 400, message = "Invalid ID supplied"),
        new ApiResponse(code = 401, message = "access token invalid")
    ))
hveiga
  • 6,725
  • 7
  • 54
  • 78
thomas poidevin
  • 176
  • 2
  • 20

2 Answers2

1

For Long, use @ApiImplicitParam(... dataType="long" ...). The swagger json that gets generated for the parameter:

{
   "name" : "name",
   "in" : "query",
   "description" : "param desc",
   "required" : true/false,
   "type" : "int",
   "format" : "int64"
}

https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X has such an example param.

For params of type java.util.UUID, there is no special processing in swagger.io code for UUIDs that I know of. So I would recommend dataType="string". As a general pointer, @ApiImplicitParam dataType is documented as:

/**
 * The data type of the parameter.
 * <p>
 * This can be the class name or a primitive.
 */

The primitive values seem to be the java primitive type names, eg int, long, etc. string is also supported.

PJ Fanning
  • 953
  • 5
  • 13
1

First of all, you can specify a class as it said in the document:

The dataType can be either a primitive or a class name.

https://github.com/swagger-api/swagger-core/wiki/Annotations-1.5.X#apiimplicitparam-apiimplicitparams

By class name, it means you have to include the full class name which is "java.util.UUID", or {UUID.class} as mentioned in the document.

XoYo24
  • 41
  • 7