Datatype "flexibility" on service endpoint

Hi,
Just wondering.
is there any reasonable way to allow some datatype flexibility on server side
for example
if our endpoint has parameters
function sum(a,b: integer): integer;
would it be possible to allow also parameters like in call as string like "a": "10"
or if we have id:string; would be also possibile to enter "id": 10001

justr askinng, cause looks like that integration parties have sometimes hard to read docs or convert types :neutral_face:

There are a few ways to work around, but all of them would require some extra work for you - question is mostly how much of the extra work you want to assume because your 3rd parties don't read docs. :slight_smile:

For example, you can add a middleware that checks if a string is sent in a query parameter and manually modify such parameter to an integer. That would be valid for query strings.

But I think the most "high-level" way to do so would be maybe declare your parameters as TJPrimitive:

function sum(a,b: TJPrimitive): integer;

This way it will accept any JSON value that is not an object or array.
You can then check if it's an integer, string, floating-point, null or boolean and do the proper checks/conversions. That will apply for parameters received via JSON.