Rodrigo Wippel
Rodrigo Wippel

Reputation: 21

Swagger POST request with BODY not working

My POST request is not showing the BODY field.

My swagger docs

enter image description here

Swagger docs petstore

enter image description here

And my method is so

 @ApiOperation(nickname = "insert",
              value = "Desc",
              httpMethod = "POST")
public Result insert()

I do forgot something?

Thanks!

Upvotes: 0

Views: 4349

Answers (1)

kenske
kenske

Reputation: 2354

I'm assuming you're using the swagger-play integration for play framework 2.5. You shouldn't need to specify the http method, it should be able to figure it out from your routes file.

As for the body field, swagger will do one of these:

  • Generate the fields based off the method parameters (using @ApiParam)
  • Generate the fields using implicit parameters (@ApiImplicitParams)

By the looks of your insert() method (it doesn't have any explicit parameters), you probably need to use the second annotation. Don't forget to use the appropriate paramType (probably body).

Upvotes: 1

Related Questions