kushal bajaj
kushal bajaj

Reputation: 73

A way\design to develop multiple version of java spring rest api

Need a way\design to develop multiple version of java spring rest api for example: exampleAPiV1,exampleAPiV2,exampleAPiV3

all 3 api version's should be live at the same time. Also if there is need for bug fix\enhancement in a particular version, the changes do not impact other version with Zero or minimum code duplication.

Upvotes: 0

Views: 264

Answers (1)

user6514731
user6514731

Reputation:

For API versioning there are 3 ways:

  1. expose API version in the URL example:

    http://api.example.com/v1/examples

    http://api.example.com/v2/examples

  2. Using Accept Header, Accept: application/json+v1

  3. Using custom header, X-Api-Version: 1

Regarding to the code, you may use the routes/headers in order to execute the corresponding functionality.

I mean in certain point of your application(middle-wares) or before actions you can get the version value from the URL or from the header and based on the value you call the functionality.

Upvotes: 1

Related Questions