Handling Multiple Protocol Versions with Schema Decoding and Transformation

Hello, I'm having some troubles identifying the best way to handle this scenario:

I have N versions of a protocol to support. Each version of the protocol has the same datatypes, each with a different "Schema" defined, so there are slight difference between datatypes between versions.

I have a single endpoint where I check which version is the caller using and receive such datatypes. I want to "decode" such datatypes with the correct schema version and apply some function mapping / transformation so that from that point forward I have a single datatype, maybe one which can represent the same datatype for every version, but still want to fail if someone send me a datatype in the form of a version which is different from the version using when calling my endpoint.

What's the best way to handle this? Should I make a single schema for some datatype, which is "version dependent"? Should I encode the mapping between version inside a single schema? Should I just make a switch and then map the resulting decoded datatype with some normal function mapping?
Was this page helpful?