There are several ways in which we can version our application. Some of them are:
- By URL
- By params
- By headers
- By produces or Accept header
There’s really no standard way to do it. In fact, there’s an argument on which is better between by URL or by params. Personally, I use the URL approach as it’s useful when bookmarking.
In my previous company, we keep backward compatibility of the API to 3 major releases and that spell disaster without the proper planning and migration of data and models. In our example, we have a complete name save as a string, but in version 2 we created a Name model that contains firstName and lastName.
To demonstrate some examples.
[open DealerVersionController class]
Now let’s start testing them. Open the file:
src/test/resources/TerawarehouseCatalog.postman_collection in Postman and play with the tests inside the versioning folder.