cancel
Showing results for 
Search instead for 
Did you mean: 

How to Java annotate multiple form parameters of same name?

Highlighted
Occasional 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?

 

 

 

1 REPLY 1
Community Hero

Re: How to Java annotate multiple form parameters of same name?

A Java question. You may want to check relevant forum.


Regards,
Rao.
New Here?
Join us and watch the welcome video: