File tree Expand file tree Collapse file tree 1 file changed +12
-11
lines changed
modules/openapi-generator/src/main/resources/swift5 Expand file tree Collapse file tree 1 file changed +12
-11
lines changed Original file line number Diff line number Diff line change @@ -65,7 +65,18 @@ extension Date: JSONEncodable {
6565 func encodeToJSON() -> Any {
6666 return CodableHelper.dateFormatter.string(from: self)
6767 }
68- }{ {/useVapor} }{ {#generateModelAdditionalProperties} }
68+ }
69+
70+ extension JSONEncodable where Self: Encodable {
71+ func encodeToJSON() -> Any {
72+ let encoder = CodableHelper.jsonEncoder
73+ guard let data = try? encoder.encode(self) else {
74+ fatalError(" Could not encode to json: \( self)" )
75+ }
76+ return data.encodeToJSON()
77+ }
78+ }
79+ { {/useVapor} }{ {#generateModelAdditionalProperties} }
6980
7081extension String: CodingKey {
7182
@@ -206,13 +217,3 @@ extension Set: RequestDecodable where Element: Content {
206217extension Set: Content where Element: Content { }
207218
208219extension AnyCodable: Content { } { {/useVapor} }
209-
210- extension JSONEncodable where Self: Encodable {
211- func encodeToJSON() -> Any {
212- let encoder = CodableHelper.jsonEncoder
213- guard let data = try? encoder.encode(self) else {
214- fatalError(" Could not encode to json: \( self)" )
215- }
216- return data.encodeToJSON()
217- }
218- }
You can’t perform that action at this time.
0 commit comments