You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on !1022 I saw that the compiler currently issues a warning about the ISO8601DateFormatter used when decoding the TokenResponse, as the ISO8601DateFormatter does not conform to Sendable.
staticfunc parse(fromData:Data)throws->Self{letdecoder=Config.jsonDecoder()
decoder.keyDecodingStrategy =.convertFromSnakeCase
letdateFormatter=ISO8601DateFormatter()
dateFormatter.formatOptions =[.withInternetDateTime]
dateFormatter.timeZone =TimeZone(secondsFromGMT:0)
decoder.dateDecodingStrategy =.custom { decoder inletcontainer=try decoder.singleValueContainer()letdateString=try container.decode(String.self)return dateFormatter.date(from: dateString)??Date()}varresponse=try decoder.decode(TokenResponse.self, from: fromData)
response.issuedAt = response.issuedAt ??Date()guard response.token !=nil || response.accessToken !=nilelse{throwDecodingError.keyNotFound(CodingKeys.token,.init(codingPath:[], debugDescription:"Missing token or access_token. One must be present."))}return response
}
Since this is an error in Swift 6, it should probably be addressed. Before doing the easy thing moving the instantiation and configuration of the ISO8601DateFormatter into the closure I wanted to understand what the reason was to choose a custom decoder over the standard .iso8601 date decoding strategy?
The text was updated successfully, but these errors were encountered:
Before doing the easy thing moving the instantiation and configuration of the ISO8601DateFormatter into the closure I wanted to understand what the reason was to choose a custom decoder over the standard .iso8601 date decoding strategy?
While working on !1022 I saw that the compiler currently issues a warning about the
ISO8601DateFormatter
used when decoding theTokenResponse
, as theISO8601DateFormatter
does not conform toSendable
.Since this is an error in Swift 6, it should probably be addressed. Before doing the easy thing moving the instantiation and configuration of the
ISO8601DateFormatter
into the closure I wanted to understand what the reason was to choose a custom decoder over the standard.iso8601
date decoding strategy?The text was updated successfully, but these errors were encountered: