Issue
Assuming there is a REST Controller with an endpoint that accepts a single object in the body:
@PostMapping("/ExampleObjects")
void mapping(@RequestBody ExampleObject object){ ....
If one would want to add the ability to accept an array under the same endpoint like this:
@PostMapping("/ExampleObjects")
void mapping(@RequestBody ExampleObject[] objects){ ....
Is there a way to implement the new functionality with the given design and without breaking existing users?
Solution
That should help you.
application.properties:
spring.jackson.deserialization.accept-single-value-as-array=true
controller:
@PostMapping("/ExampleObjects")
void mapping(@RequestBody List<ExampleObject> objects){ ....
Answered By - frombrest