5
votes

I'm trying to use Swagger to document my REST API. Following this example, I annotate the REST Endpoints like this:

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
          ) 

And I was expecting to get "Model" like this but I get only the String "CreateItemRequest" as Data Type. Not the properties of the case class CreateItemRequest.

Greetings, Daniel

3
Did you find a solution to this? I am facing the same problem :\Sudh

3 Answers

9
votes

You should use the full namespace in the dataType attribute. For example: @ApiImplicitParam(dataType = "org.test.CreateItemRequest")

0
votes

try to annotate your models with the swagger annotations as well, like shown here:

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

your annotation ApiModel(name="CreateItemRequest") match the annotation @ApiImplicitParam(dataType = "CreateItemRequest")

Cheers, Johannes

0
votes

Try using this annotation @JsonAutoDetect and @JsonIgnoreProperties(ignoreUnknown = true) before your class and then add @JsonPropety for each properties you want to show.

Make sure that in your route definition you call your method like :

GET  url   controllers.foo.YourMethod(param: type)

More example here.

Hope this will help you.