4
I’m looking at ways to view the Uris from a REST Spring API because if they launch a new application, the REST API will meet the new application and support the old application requests for a certain period of time. But I am in doubt of how the database, system entities and Uris in general looks like whenever a version is added to a URI.
Example:
No version, a request to fetch all users:
http://host:8080/api/usuarios
Versioned:
http://host:8080/v1/usuarios
http://host:8080/v2/usuarios
http://host:8080/v1/produtos
I was thinking of making a User entity and when defining the attributes I note them as not mandatory and the entity is always the most current 'version'. For the v2 version of the URI I create a User v2dto so that it mainly serves the User entity making the validations with the necessary Annotations. For the v1 version of the URI, let’s say that user does not have the attribute 'dataNascimento' and thus he receives a User v1dto that does not have the attribute dataNascimento and when converting the DTO to Entity the attribute Entity.dataNascimento is null because it is not required.
What I want to know is if this is a correct way to use, because in the database the attributes are not mandatory and the validation of the mandatory is in DTO ? I also want to know if all Uris of all features need to be changed to the latest version or if in the case of 'products' it can stay in V1 until one day it is necessary to change only it ?