Base solution for your next web application
Open Closed

Upgrade from 8.1 to 8.2 and issue with TimeSpan. #8566


User avatar
0
drenton created

HI,

I upgraded my project from 8.1 to 8.2. After the upgrade, the swagger generates different result for Timespan.

Before it generated Nullable Timespan like below for ListDto. this.startTime = data["startTime"]; this.endTime = data["endTime"];

now it generates it like below this.startTime = data["startTime"] ? TimeSpan.fromJS(data["startTime"]) : <any>undefined; this.endTime = data["endTime"] ? TimeSpan.fromJS(data["endTime"]) : <any>undefined; and this causes an error on below code

static fromJS(data: any): TimeSpan {
    data = typeof data === 'object' ? data : {};
    let result = new TimeSpan();
    result.init(data);
    return result;
}

Above method was not created in 8.1 and both Nullable not not Nullable timespan generates the same code.

Thanks.


2 Answer(s)
  • User Avatar
    2
    drenton created

    I fixed above issue by following below link.

    https://github.com/domaindrivendev/Swashbuckle.AspNetCore#systemtextjson-stj-vs-newtonsoft

  • User Avatar
    0
    rickfrankel created

    Thank you for saving me hours of work :)