File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
modules/swagger-codegen/src/main/resources/swift Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -109,13 +109,19 @@ class Decoders {
109
109
}
110
110
// Decoder for NSDate
111
111
Decoders.addDecoder(clazz: NSDate.self) { (source: AnyObject) -> NSDate in
112
- let sourceString = source as! String
113
- for formatter in formatters {
114
- if let date = formatter.dateFromString(sourceString) {
115
- return date
112
+ if let sourceString = source as? String {
113
+ for formatter in formatters {
114
+ if let date = formatter.dateFromString(sourceString) {
115
+ return date
116
+ }
116
117
}
118
+
117
119
}
118
- fatalError("formatter failed to parse \(sourceString)")
120
+ if let sourceInt = source as? Int {
121
+ // treat as a java date
122
+ return NSDate(timeIntervalSince1970: Double(sourceInt / 1000) )
123
+ }
124
+ fatalError("formatter failed to parse \(source)")
119
125
} { {#models} }{ {#model} }
120
126
121
127
// Decoder for [{ {{classname} }}]
You can’t perform that action at this time.
0 commit comments