3

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

1 Answer 1

4

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) {
}
Sign up to request clarification or add additional context in comments.

1 Comment

Exactly what I needed. Thnx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.