Date format error with SummaryActivity and Swagger generated code - best practices?

37 views
Skip to first unread message

Tollman Owens

unread,
Jul 20, 2018, 12:16:30 AM7/20/18
to Strava API
Hi,

I was getting this error

Optional(Swift.DecodingError.dataCorrupted(Swift.DecodingError.Context(codingPath: [_JSONKey(stringValue: "Index 0", intValue: 0), "start_date"], debugDescription: "Date string does not match format expected by formatter.", underlyingError: nil)))

When

ActivitiesAPI.getLoggedInAthleteActivities { activities, error in
    debugPrint(activities as Any)
    debugPrint(error as Any)
}

I saw the option to change the format in Configuration.swift. The error still was still happening. I ended up changing it in CodableHelper.swift

to

formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssX"

Which works.

Is this the best place to do so, feels like I shouldn't be modifying the generated code?

Thanks,
T/O 
Reply all
Reply to author
Forward
0 new messages