suman j
suman j

Reputation: 6960

swagger ui with collection (List) input parameter for Jax Rs resource

How to configure swaggerui to display correct parameter datatype for JAX-RS resources which have collection input parameters?

Below is a sample groovy JAX-RS resource. Its input is of type List<User>

@POST
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@ApiOperation(value = "Create(s) users", response = User, responseContainer = "List")
Response createUsers(List<User> questions) {
}

In the swagger UI, I see the List with empty type populated instead of User. It works fine for output parameters. Using ApiOperation annotation, I could specify for response type.

@ApiOperation(value = "Create(s) users", response = User, responseContainer = "List")

For input parameters, How do I see List of User model schema in the swagger UI? enter image description here

Upvotes: 3

Views: 4542

Answers (1)

Marcin M.
Marcin M.

Reputation: 56

Try using @ApiParam on List:

@POST
@Produces(APPLICATION_JSON)
@Consumes(APPLICATION_JSON)
@ApiOperation(value = "Create(s) users", response = User, responseContainer = "List")
Response createUsers(@ApiParam("description") List<User> questions) {
}

Upvotes: 4

Related Questions