Reputation: 723
I use play-swagger
+ swagger-ui
in my project, however I have request with json
body like this:
{"country":{"title": "Germany"}}'
When I annotate my method with:
ApiImplicitParam(name = "country[title]", value = "Country's title", required = true, dataType = "String", paramType = "body")
it doesn't work in swagger UI, how can I tell that my title
name in country
namespace ?
Upvotes: 0
Views: 1106
Reputation: 1723
The best approach would be to define a CountryRequest
class (also with annotations) that acts as the model of the request object. Then you would reference this class when defining your ApiImplicitParam
. For example,
@ApiModel(value = "CountryRequest")
case class CountryRequest(
@(ApiModelProperty @field)(dataType = "String", readOnly = false, required = true) title: String,
)
Incidentally, you probably want to define this parameter as a body parameter, so it should look something like this:
@ApiImplicitParams(Array(
@ApiImplicitParam(name = "body", value = "Country", required = true, dataType = "com.example.CountryRequest", paramType = "body")
))
def postCountry = ...
Upvotes: 1