I am new to backend REST API development. I am creating the CRUD APIs for books using spring boot.
I have a model class lets say ‘user’. It will have many fields, like id, name, email, status, created_at, etc.
I have multiple APIs for the user related action like login, register, update, delete, and so on.
How do I ensure that the user sends the correct amount of data for the particular API. For eg: id, status is not required for registration. Status should not be updated during update api call.
And also while sending the user information, i should not send the password to the user. How do i ensure i do that.
One solution i get is using DTOs in spring boot. Then, I will have to create different DTO for different API, which will be a lot.
Another is doing manually, which is also not feasible.
Nitish is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.