Github user apocolipse commented on the issue: https://github.com/apache/thrift/pull/1084 @ChristopherRogers @fumoboy007 I implemented union support with enums, here's an example of generated code: ``` union TestUnion { 1: i32 data, 2: string message, 3: bool success } ``` ```swift public enum TestUnion { case data(val: Int32) case message(val: String) case success(val: Bool) } public func ==(lhs: TestUnion, rhs: TestUnion) -> Bool { return { switch (lhs, rhs) { case (.data(let lval), .data(let rval)): return lval == rval case (.message(let lval), .message(let rval)): return lval == rval case (.success(let lval), .success(let rval)): return lval == rval default: return false } }() } extension TestUnion : CustomStringConvertible { public var description : String { var desc = "TestUnion." switch self { case .data(let val): desc += "data(val: \(val))" case .message(let val): desc += "message(val: \(val))" case .success(let val): desc += "success(val: \(val))" } return desc } } extension TestUnion : Hashable { public var hashValue : Int { let prime = 31 var result = 1 switch self { case .data(let val): result = prime &* val.hashValue case .message(let val): result = prime &* val.hashValue case .success(let val): result = prime &* val.hashValue } return result } } extension TestUnion : TStruct { public static var fieldIds: [String: Int32] { return ["data": 1, "message": 2, "success": 3, ] } public static var structName: String { return "TestUnion" } public static func read(from proto: TProtocol) throws -> TestUnion { _ = try proto.readStructBegin() var ret: TestUnion? fields: while true { let (_, fieldType, fieldID) = try proto.readFieldBegin() switch (fieldID, fieldType) { case (_, .stop): break fields case (1, .i32): ret = TestUnion.data(val: try Int32.read(from: proto)) case (2, .string): ret = TestUnion.message(val: try String.read(from: proto)) case (3, .bool): ret = TestUnion.success(val: try Bool.read(from: proto)) case let (_, unknownType): try proto.skip(type: unknownType) } try proto.readFieldEnd() } if let ret = ret { return ret } throw TProtocolError(error: .unknown, message: "Missing required value for type: TestUnion") } } ```
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---