[SWIFT4] CodableHelper's encode() does not use dateFormatter property
Created by: manhhavu
Description
The current Swift4's CodeableHelper's encode() method does not into account the class' property dateFormatter. The consequence is that we are unable to customize the encoding format for date.
openapi-generator version
3.2.3
Suggest a fix/enhancement
Take into account the property dateFormatter, which is already the case for decode() method. For example:
if let df = self.dateformatter {
encoder.dateEncodingStrategy = .formatted(df)
} else {
encoder.dataEncodingStrategy = .base64
let formatter = DateFormatter()
formatter.calendar = Calendar(identifier: .iso8601)
formatter.locale = Locale(identifier: "en_US_POSIX")
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSXXXXX"
encoder.dateEncodingStrategy = .formatted(formatter)
}
I'm happy to create a PR if you'd like