我正在尝试使用akka-http 10.0.0和swagger-akka-http 0.8.2在我的路由上实现swagger。它工作得很好,但是类型为UUID和Long的查询参数被认为是未定义的。
我应该使用格式吗?
怎么用?
这是我的一条路线:
@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")
))发布于 2017-01-04 17:11:47
长久以来,请使用@ApiImplicitParam(... dataType="long" ...)。为参数生成的swagger json:
{
"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就有这样一个例子参数。
据我所知,对于java.util.UUID类型的参数,在swagger.io代码中没有针对UUID的特殊处理。所以我推荐dataType="string“。作为通用指针,@ApiImplicitParam dataType的文档记录为:
/**
* The data type of the parameter.
* <p>
* This can be the class name or a primitive.
*/原始值似乎是java原语类型的名称,例如int、long等,也支持string。
发布于 2017-01-04 20:44:41
首先,您可以按照文档中的说明指定一个类:
dataType可以是基元名称或类名。
对于类名,这意味着您必须包含文档中提到的完整类名"java.util.UUID“或{UUID.class}。
https://stackoverflow.com/questions/41444147
复制相似问题