[BUG] [Javascript] Modify parseDate in ApiClient to support epoch time in addition to ISO-8601
Created by: tray2100
Description
The APIs from the Javascript client generated seem to receive Date values in epoch millis instead of ISO-8601. However, it seems that the APIs (specifically the constructFromObject function) doesn't handle converting from epoch millis and results in 'Invalid Date'. This is happening because the long value is being converted to a string before being passed to the Date object constructor.
The solution here would be to just check if the incoming object type and if it's numeric then just pass it on to Date without wrapping it in a string first.
openapi-generator version
4.3.1
Suggest a fix
Modify this portion of the mustache file to look like this:
exports.parseDate = function(str) {
if (!isNaN(str)) {
return new Date(+str);
}
return new Date(str.replace(/T/i, ' '));
};