1

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.

Bhushan
  • 567
  • 2
  • 5
  • 14
  • 1
    Possible duplicate of [Versioning REST API](http://stackoverflow.com/questions/10742594/versioning-rest-api) – Pradeep Simha Mar 02 '16 at 07:08
  • thanks for good link ! , very close to this one. But I am looking for answer how we can handle with spring like some modification in url patterns. There is bit debate between header and url version. – Bhushan Mar 02 '16 at 07:25
  • You have two APIs with different URLs. What exactly do you want? What do you mean by _"change REST api version"_? – a better oliver Mar 02 '16 at 12:28
  • updated quetion. can we do any hack with DispatcherServelets URL so it will start supporting both urls ? – Bhushan Mar 03 '16 at 06:53

1 Answers1

1

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.

Eric Stein
  • 13,209
  • 3
  • 37
  • 52
  • maintaining two web app its trouble. can we do any hack with DispatcherServelet URL so it will start supporting both urls ? – Bhushan Mar 03 '16 at 06:55