For a test I am working on at the moment, I am using the DEX library to automatically generate an AIMMS library for a webservice based on the OpenAPI json spec.
Unfortunately, in one of the models I have a property with the following definition:
"value": {
"anyOf": :
{
"type": "number"
},
{
"type": "string"
}
],
"title": "Value"
}
I am not responsible for the webservice, so did not know that something was changed (the anyOf). It took me a long time to figure out why after the api call was done there was no data anymore. I did not get any errors or warnings and I unfortunately forgot to check the CallErrorCode parameter.
Finally, I was able to find what went wrong by modifying the generated callback procedure and replace the line
CallErrorCode := dex::ProtectedReadFromFile(ResponseFile('responsebody'), responsefileMapping('responsebody')) ;
with a block/onerror do piece where I manually call the dex::ReadFromFile procedure allowing me to catch the error. In my case, the error finally made it clear to me what went wrong: Could not convert “somestringvalue” to numerical value.
Instead of having a ProtectedReadFromFile that catches all errors and reduces them to a binary state error/no-error it might be interesting to have a list of the messages of all errors/warnings that were caught in the process allowing a developer to pinpoint a bit quicker what went wrong.
Furthermore, wondering if you have a potential solution for dealing with these multi-type values in DEX. I am pretty sure the best solution might be telling the people creating the webservice not to mix types… But the standard does allow for it, so in theory I could run into this more often. For now I have solved it by modifying the generated code for this webservice to read everything into a string parameter and try to convert each string into a numerical value and have another binary parameter indicating whether a numerical value was found (i.e. whether the VAL function did not raise an error)