I am using Springboot 2.7.9 and I need to invoke a Request as below
localhost:8081/api/projects?page=2&size=3&sortBy=projectName&sortDirection=desc&sortBy=startDate&sortDirection=asc
My PageSort entity is as below
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class PageSort {
private String sortBy;
@SortValueConstraint
private String sortDirection;
}
How can I accept sortBy=projectName&sortDirection=desc&sortBy=startDate&sortDirection=asc as a List collection in my rest controller
@GetMapping
public ResponseEntity<ApiResponseDTO> getProjects(
@Valid ProjectPage projectPage,
@Valid List<PageSort> sortList){
return null;
}
When I accept a single sort object (@Valid PageSort sortList) this perfectly works but when I introduce the list it doesn't work. I think it has to do something with the collections
Any ideas on this please??