Reputation: 567
With pragmatic RESTful API approach, url is defined as
http://<host>:<port>/<apiname>/api/v1.0/...
where v1.0 is api version. Now all the clients will stick to this url and start using this api. Now new api version is launched http://<host>:<port>/<apiname>/api/v2.0/...
with some extra features. This change will break existing clients as all of them are using old version in their url. How to change REST api version without breaking existing client in java and spring mvc ?
e.g.
suppose I have one web app where I registered DispatcherServerlet with url pattern .../api/v1.0
. Now I have few more features in API which will be available as part of another version. Do I need to make one more web app in which contains url pattern ..,/api/v2.0
. The concerns are code duplication and need to maintain two web app.
General description will work. I do not want pass api version in header.
Upvotes: 1
Views: 702
Reputation: 13682
Maintain a branch for v1, a branch for v2, give the WARs different names, and deploy them both. Or do it in software - multiple projects, each of which has one API in it, preferably referencing a shared service layer.
As an aside, if you intend to release new versions so frequently that you need multiple digits, you're probably in trouble. Just stick to v1, v2. Every time you release a new version, you're adding a significant support burden.
Upvotes: 1