import Foundation /// One row of `milestone list`, with progress counts. nonisolated struct Milestone: Decodable, Sendable, Hashable, Identifiable { let title: String let description: String? let due: String? let state: String /// True for a milestone the repository sees through its org /// (v1.19.0). The repository cannot close or reopen it; `org /// milestone` does. Absent on the wire for a repository row and on /// older servers. let org: Bool let open: Int let closed: Int var id: String { title } private enum CodingKeys: String, CodingKey { case title, description, due, state, org, open, closed } init(from decoder: Decoder) throws { let c = try decoder.container(keyedBy: CodingKeys.self) title = try c.decode(String.self, forKey: .title) description = try c.decodeIfPresent(String.self, forKey: .description) due = try c.decodeIfPresent(String.self, forKey: .due) state = try c.decode(String.self, forKey: .state) org = try c.decodeIfPresent(Bool.self, forKey: .org) ?? false open = try c.decode(Int.self, forKey: .open) closed = try c.decode(Int.self, forKey: .closed) } }