Spring Boot, Spring MVC JSON RequestBody: Unknown property ignored

You can reconfigure your Jackson (assuming you are using it) ObjectMapper to fail on unknown properties.

ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);

In this case your unknown property will throw JsonMappingException and you can introduce custom exception handler to return in this case Response 400.


Put this into application.properties:

spring.jackson.deserialization.FAIL_ON_UNKNOWN_PROPERTIES=true

Here are the relevant docs: Customize the Jackson ObjectMapper