tsaik
6 years agoOccasional Visitor
How to Java annotate multiple form parameters of same name?
I have an API operation with one argument of type List<ItemType> where ItemType is an Enum. Following is the code snippet:
@Path("evp/placeOrder")
@POST
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
@Produces(MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(responseCode = "200", description = "Successful")
})
@Parameter(style = ParameterStyle.FORM, explode = Explode.TRUE)
public Order placeOrder(@FormParam("item") List<ItemType> item) {
return new Order(item);
}ItemType.java
public enum ItemType {
Cookies,
Cake,
Drink
}
When a request contains multiple items, I expect the serialization to look something like:
"item=Cookies&item=Cake"
However, the Swagger UI is generating the following serialization:
"item=Cookies%2CCake"
I have tried declaring the 'explode' property in my @Parameter annotation but it has no effect. What am I missing?