I am creating a Rest Service using Spring boot and for documentation I am using Swagger(via SpringFox). And it is almost working fine. The issue arises when I moved all of my query parameters to a request object and used that in the method signature thus implicitly binding the values and getting spring validators fired implicitly.
This is how my method signature looks:
public List<Category> getCategory( @Valid CategoryInputRequest inputRequest) throws JsonParseException,
JsonMappingException, IOException
The CategoryInputRequest is a bean having a plain bean structure:
@ApiModel(value = "Input Description")
public class CategoryInputRequest {
@NotNull(message="SE Number is mandatory")
@Size(min=10,max=10,message="SE Number must have 10 characters")
@ApiModelProperty
private String idNumber;
@NotNull(message="Platform ID is mandatory")
@ApiModelProperty
private String platformId;
.
.
.
Where IdNumber, platformId are the query parameters and data validation and binding happens flawlessly. But Swagger assumes "CategoryInputRequest inputRequest" in the method signature to be a requestBody type of parameter and not query pameters and hence doesn't expose the individual fields to the user. Instead gives a big text area to put a JSON block in. I tried giving @APIModelProperty but it doesn't work.
Can anyone please help? I hope I was able to explain the problem.