I think the cleanest way is to support every version that is needed to support, work. This means that each version has its own branch in your VCS and is focused on servicing customers who use this particular version. The code is clean and focused on one version. If you need to work with common components / databases, etc., I think that you should implement this level further in your architecture, and not in the REST API level. This level of version control should be the first behind the REST API.
If this does not really work, I would probably design it so that the latest API is the only API that works against your real backend. Other versions simply invoke other versions using a regular HTTP request ... older versions are REST clients of the new APIs. It is not very fast, but the design is very clean and it is easy to understand where the version code is going. If you have many clients that work against older versions of the API, this may lead to a too slow solution, and you need to find more efficient ways to execute it, but then we will almost return to the first solution.
source share