I am trying to combine multiple request parameters in a Map.
I could do it, but we want to restrict keys to some names, hence we defined an enum.
But the spring boot doesn't validate the Map. It just accepts, even if we send any key instead of the ones defined in the emum.
Ex:
@GetMapping("/name2")
public void getList(@RequestParam Map<FilterEnum,String> map,
@RequestParam(name = "Id", required = false) String Id) {...}
public enum FilterEnum {
lifecyclestaus,
name;
}
Request URL:
http://localhost:8090/employee/name2?bar=ks
Two issues:
- Ideally it should throw an error with the above request, as bar is not part of enum.
- Also the id request param should not be part of Map.
Thanks in advance.