Swagger ui with collection input (List) for Jax Rs resource

How can I configure swaggerui to display the correct parameter data type for JAX-RS resources that have collection input parameters?

Below is an example of a groovy JAX-RS resource. Its input is of typeList<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 a list with an empty type filled in instead User

. It works great for output parameters. Using annotation ApiOperation

, I could indicate the type of response.

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

      

For props, how can I see the schema of the user list model in the swagger UI? enter image description here

+3


source to share


1 answer


Try using @ApiParam on the list:



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

      

+4


source







All Articles