带有Play框架的ImplicitParam中的Swagger数据类型模型

dan*_*l m 5 scala playframework swagger swagger-ui swagger-play2

我正在尝试使用Swagger来记录我的REST API.在这个例子之后,我像这样注释REST端点:

case class CreateItemRequest(title: String, body: String)

@ApiOperation(value = "Create a new item", httpMethod = "POST", response = classOf[Item])
@ApiImplicitParams(Array(new ApiImplicitParam(dataType = "CreateItemRequest", paramType = "body", name = "body", required = true, allowMultiple = false, value = "The item object to create")))
def create(
          @ApiParam(value = "Hash of the user", required = true)
          @QueryParam("userhash") userhash: String
          ) 
Run Code Online (Sandbox Code Playgroud)

我期待得到"模特"之类的 这个但我只获得字符串"CreateItemRequest"作为数据类型.不是案例类CreateItemRequest的属性.

问候,丹尼尔

Ben*_*ger 9

您应该在dataType属性中使用完整命名空间.例如: @ApiImplicitParam(dataType = "org.test.CreateItemRequest")


小智 0

尝试使用 swagger 注释来注释您的模型,如下所示:

https://github.com/swagger-api/swagger-core/blob/master/samples/scala-play2/app/models/Pet.scala

您的注释 ApiModel(name="CreateItemRequest") 与注释 @ApiImplicitParam(dataType = "CreateItemRequest") 匹配

干杯,约翰内斯