I am creating a dynamic parameter rest api using spring boot and I would like to throw an exception if any field passed as parameter does not exist
This is a get call using request parameters like this one: http://localhost:8080/action?prop1=a
I have a class:
public class MyObject {
private String prop1;
}
and a getMapping:
@GetMapping(value = "/action")
public @ResponseBody List<MyObject> myAction(MyObject myObject) { ... }
If I call http://localhost:8080/action?prop1=x&prop_that_does_not_exist=z I would like to get an exception because prop_that_does_not_exist does not exist in MyObject.
Is there any annotation for it? Is there any way to achieve this behavior?
I would like to get an error in the example added but I would not like (if possible) to change the object binding to something like myAction(Map<String, String> map).
Thanks!