I have a resource that accepts POST requests with JSON body of array type, for example:
[
{ "foo": "bar" },
{ "foo": "baz" },
...
]
To document non-collection type using Swagger annotations I can do:
@ApiImplicitParams(Array(
new ApiImplicitParam(paramType = "body", dataType = "my.Request", required = true)
))
How to do the same for array body type, e.g. Seq[my.Request]
?
It can be done by introducing a surrogate trait that extends Java's standard library list:
trait ArrayBody extends java.util.List[ArrayElementType]
And then in the endpoint annotations:
@ApiImplicitParams(Array(
new ApiImplicitParam(paramType = "body", dataType = "foo.bar.ArrayBody", required = true)
))