I want to implement 2 Endpoints in my REST API:
@PostMapping("/example")
public ObjectResponse postObject(@RequestBody Example example){... //Add new Example to DB}
@PutMapping("/example")
public ObjectResponse postObject(@RequestBody Example example){...//Update existing Example}
My Example could look like this:
public class Example{
@Id
@Hidden
private String id;
private String somethingCool;
}
I want to hide the ID, so that the User who uses Post doesnt send me an request with an ID. I want to let it generate by my mongoDB.
On the other useCase, during a Put an ID must be send in order to identify the Object that should be updated. But the ID Field on my Swagger 3.0 is here hidden as well.
How can I hide it on my Post but show it on my Put?
Thanks alot!