Last post Oct 30, 2018 05:34 AM by Nan Yu
Oct 29, 2018 10:28 AM|akhilrajau|LINK
I am having one Web API project with version 1. For versioning i used version along with mime in Accept header. I named all controller with version number as suffix and the versioning work correctly.
Currently, If user didn't provided anything, controller selector service will select the default version 1. Otherwise select the specified version of controller. If not found, responded with 404.
Now i need to change the response of one particular action (API). So i added version 2 of same controller.
My questions are in the creation of Controller version 2;
Which one is best option for better maintenance and best practice?
Note: I am thinking that without any reason we don't want to increase the version and also it will confuse in the future. But according to my code, if a client specifies version 2 and the API not exist, it will give 404 instead of version 1.
Oct 30, 2018 02:48 AM|Nan Yu|LINK
Vesion 1 and version 2 are different , you can think that you are building new Apis
start from scratch . so if you want to support same functions(in version 1) in version 2 , you need to "include all methods from the version 1 and only change in that particular action" .
Oct 30, 2018 04:29 AM|akhilrajau|LINK
yea. So i can understand that if i add all methods, user can user version 2 for all methods and it may be easy for clients. My thinking was if i have any breaking change in the updated action of version 2, i need to create version 3 and same all actions
will be in version 3 also. Actually i am increasing version of controller for only single action.
Is this the best approach ? Thinking for general practice
Oct 30, 2018 05:34 AM|Nan Yu|LINK
Hi akhilrajau ,
That all depends on your requirement , if you don't want to add other methods , you just need to tell your customers to use that method only in version 2 . But i would copy the not changed methods to new version to avoid potential problem for example 404
not found error .