Versioning through the URI path

The major and minor version changes can be a part of the URI, for example, to represent v1 or v2 of the API the URI can be http://localhost:9090/v1/investors or http://localhost:9090/v2/investors, respectively.

The code implementation of the URI path versioning within our investor service examples is shown in the following code snippet:

@GetMapping({"/v1/investors","/v1.1/investors","/v2/investors"})
public List<Investor> fetchAllInvestors()
{
return investorService.fetchAllInvestors();
}

The output of this code is as follows:

The preceding screenshot shows the Postman execution of the URI path-versioning example.

URI path changes according to the version violates the RESTful principles of URI and its resource representation (two different URIs represent the same resources—the only difference is v1, v2, and so on, in our example). However, URI path versioning is a popular way of managing API versions due to its simple implementation.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.252.140