Image that we have some hardware and it has an API which is versioned based on its operating system version. If operating system is updated there is a chance that an API has changed (endpoints changed, deleted, url renamed, response changed, request bodies require new parameters, etc.).
You are a consumer of this API and your end goal is backwards compatibility (support any version of the hardware in your product).
How would you go about consuming such an API?
Version each endpoint with request/response separately and write a wrapper (anti-corruption layer) around each of them?
Create some sort of "API request resolver" which builds your request based on API version?
Version use cases?
Inject a way to make specific request to specific components based on API version in composition root?
Currently I version use cases and based on API version I inject different version of a use case to specific components in composition root. I also version request endpoints and responses by putting different version of specific endpoint into its own package/directory and naming it based on API version.
Versioning use cases is tedious, because one endpoint can be used in multiple use cases, so if it changes I have to make new versions of multiple use cases.
Obvious solution would be to create a wrapper around the API calls which hides the changes and do not version use cases anymore, but what if endpoint has been deleted? new parameters added, etc.? We cannot really write an abstraction around such a dynamic API.