-
Notifications
You must be signed in to change notification settings - Fork 6k
Description
Description
The swift swagger codegen is generating code that uses a date formatter "yyyy-MM-dd" when encoding to JSON, for a field which is of type date-time in the server yaml file.
Swagger-codegen version
latest, done from a website: https://locus.sh/docs/index.html
Swagger declaration file content or url
Command line used for generation
Steps to reproduce
generate a swift swagger client from https://locus.sh/docs/index.html
Trigget time needs to have the time as well as date, but the time is truncated
Related issues
Yes, #1616
Suggest a Fix
Change the date formatter from "yyyy-MM-dd" to "yyyy-MM-dd HH:mm:ss" or something more appropriate so that the time information is not truncated.
Currently, the relevant generated swift code is:
private let dateFormatter: NSDateFormatter = {
let dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "yyyy-MM-dd"
return dateFormatter
}()
extension NSDate: JSONEncodable {
func encodeToJSON() -> AnyObject {
return dateFormatter.stringFromDate(self)
}
}