What if the api interface changes the returned data structure after modification?

the situation goes like this:
after I modified a functional interface, the data structure returned has changed
, and then the interface before
is still online with
. It is impossible for me to modify the original interface directly. Otherwise, there will be a problem with the previous function
then I can only create a new API for the modified function
but if there are too many interfaces, will it result in a large number of abandoned interfaces and how to better distinguish between pre-upgrade and post-upgrade interfaces in the production environment
?

Mar.20,2021

with the help of externally transmitted parameters? Add a parameter, such as version number, etc., whether this can be solved. If there is no this parameter, it is proved to be the previous logic. If this parameter is added, whether it can be implemented by using different logic according to the version number. However, this is also the case here. We also write a new interface to implement--


.
but if there is too much of this, will it result in a large number of abandoned interfaces in the production environment at the same time

first of all, there are actually three things here, one is called compatible with the previous version, one is called adding a function, and the other is called the obsolete version.

  1. if you want to be compatible, it is not called obsolete interface , of course, this does not meet the needs of the subject.
  2. A new function is actually added here (although it may be very similar to the original function), just add it directly.
  3. and if you want to discard, you can block the old version of the code (usually after a few iterations, there is enough warning that you want to discard this interface, which is usually not very useful)

there is no way to do this. Mainly write the documentation, each system version of the documentation clearly written about the support and abandonment of the interface.


can be distinguished by a version number, such as V1 and V2, so that it will not be difficult to name, and it is more in line with your current situation

.
Menu