mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-10 15:22:44 +00:00
[swift5] Refactor encodeToJSON (#10961)
* Add protocol extension method
* execute sample script
* Add Packing.cmake
* Revert "Add Packing.cmake"
This reverts commit cb52547fe3.
* Remove empty lines
* Revert FILES
* Add Packing.cmake
This commit is contained in:
@@ -9,33 +9,15 @@ import Foundation
|
||||
import AnyCodable
|
||||
#endif
|
||||
|
||||
extension Bool: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self }
|
||||
}
|
||||
|
||||
extension Float: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self }
|
||||
}
|
||||
|
||||
extension Int: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self }
|
||||
}
|
||||
|
||||
extension Int32: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return NSNumber(value: self as Int32) }
|
||||
}
|
||||
|
||||
extension Int64: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return NSNumber(value: self as Int64) }
|
||||
}
|
||||
|
||||
extension Double: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self }
|
||||
}
|
||||
|
||||
extension String: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self }
|
||||
}
|
||||
extension Bool: JSONEncodable {}
|
||||
extension Float: JSONEncodable {}
|
||||
extension Int: JSONEncodable {}
|
||||
extension Int32: JSONEncodable {}
|
||||
extension Int64: JSONEncodable {}
|
||||
extension Double: JSONEncodable {}
|
||||
extension String: JSONEncodable {}
|
||||
extension URL: JSONEncodable {}
|
||||
extension UUID: JSONEncodable {}
|
||||
|
||||
extension RawRepresentable where RawValue: JSONEncodable {
|
||||
func encodeToJSON() -> Any { return self.rawValue }
|
||||
@@ -83,18 +65,6 @@ extension Date: JSONEncodable {
|
||||
}
|
||||
}
|
||||
|
||||
extension URL: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self
|
||||
}
|
||||
}
|
||||
|
||||
extension UUID: JSONEncodable {
|
||||
func encodeToJSON() -> Any {
|
||||
return self.uuidString
|
||||
}
|
||||
}
|
||||
|
||||
extension String: CodingKey {
|
||||
|
||||
public var stringValue: String {
|
||||
|
||||
@@ -10,6 +10,10 @@ protocol JSONEncodable {
|
||||
func encodeToJSON() -> Any
|
||||
}
|
||||
|
||||
extension JSONEncodable {
|
||||
func encodeToJSON() -> Any { self }
|
||||
}
|
||||
|
||||
public enum ErrorResponse: Error {
|
||||
case error(Int, Data?, URLResponse?, Error)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user