|
| 1 | +// This file was generated from JSON Schema using quicktype, do not modify it directly. |
| 2 | +// To parse the JSON, add this file to your project and do: |
| 3 | +// |
| 4 | +// let project = try? newJSONDecoder().decode(Project.self, from: jsonData) |
| 5 | + |
| 6 | +import Foundation |
| 7 | + |
| 8 | +// MARK: - Project |
| 9 | +struct Project: Codable { |
| 10 | + let removedTargets: [JSONAny] |
| 11 | + let lineCoverageDelta: LineCoverageDelta |
| 12 | + let addedTargets: [JSONAny] |
| 13 | + let targetDeltas: [TargetDelta] |
| 14 | +} |
| 15 | + |
| 16 | +// MARK: - LineCoverageDelta |
| 17 | +struct LineCoverageDelta: Codable { |
| 18 | + let executableLinesDelta: Int |
| 19 | + let lineCoverageDelta: Double |
| 20 | + let coveredLinesDelta: Int |
| 21 | +} |
| 22 | + |
| 23 | +// MARK: - TargetDelta |
| 24 | +struct TargetDelta: Codable { |
| 25 | + let addedFiles: [JSONAny] |
| 26 | + let lineCoverageDelta: LineCoverageDelta |
| 27 | + let name: String |
| 28 | + let removedFiles: [JSONAny] |
| 29 | + let fileDeltas: [FileDelta] |
| 30 | +} |
| 31 | + |
| 32 | +// MARK: - FileDelta |
| 33 | +struct FileDelta: Codable { |
| 34 | + let removedFunctions: [RemovedFunction] |
| 35 | + let lineCoverageDelta: LineCoverageDelta |
| 36 | + let documentLocation: String |
| 37 | + let addedFunctions: [AddedFunction] |
| 38 | + let functionDeltas: [JSONAny] |
| 39 | +} |
| 40 | + |
| 41 | +// MARK: - AddedFunction |
| 42 | +struct AddedFunction: Codable { |
| 43 | + let coveredLines: Int |
| 44 | + let lineCoverage: Double |
| 45 | + let lineNumber, executionCount: Int |
| 46 | + let name: String |
| 47 | + let executableLines: Int |
| 48 | +} |
| 49 | + |
| 50 | +// MARK: - RemovedFunction |
| 51 | +struct RemovedFunction: Codable { |
| 52 | + let name: String |
| 53 | +} |
| 54 | + |
| 55 | +// MARK: - Encode/decode helpers |
| 56 | + |
| 57 | +class JSONNull: Codable, Hashable { |
| 58 | + |
| 59 | + public static func == (lhs: JSONNull, rhs: JSONNull) -> Bool { |
| 60 | + return true |
| 61 | + } |
| 62 | + |
| 63 | + public var hashValue: Int { |
| 64 | + return 0 |
| 65 | + } |
| 66 | + |
| 67 | + public func hash(into hasher: inout Hasher) { |
| 68 | + // No-op |
| 69 | + } |
| 70 | + |
| 71 | + public init() {} |
| 72 | + |
| 73 | + public required init(from decoder: Decoder) throws { |
| 74 | + let container = try decoder.singleValueContainer() |
| 75 | + if !container.decodeNil() { |
| 76 | + throw DecodingError.typeMismatch(JSONNull.self, DecodingError.Context(codingPath: decoder.codingPath, debugDescription: "Wrong type for JSONNull")) |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + public func encode(to encoder: Encoder) throws { |
| 81 | + var container = encoder.singleValueContainer() |
| 82 | + try container.encodeNil() |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +class JSONCodingKey: CodingKey { |
| 87 | + let key: String |
| 88 | + |
| 89 | + required init?(intValue: Int) { |
| 90 | + return nil |
| 91 | + } |
| 92 | + |
| 93 | + required init?(stringValue: String) { |
| 94 | + key = stringValue |
| 95 | + } |
| 96 | + |
| 97 | + var intValue: Int? { |
| 98 | + return nil |
| 99 | + } |
| 100 | + |
| 101 | + var stringValue: String { |
| 102 | + return key |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +class JSONAny: Codable { |
| 107 | + |
| 108 | + let value: Any |
| 109 | + |
| 110 | + static func decodingError(forCodingPath codingPath: [CodingKey]) -> DecodingError { |
| 111 | + let context = DecodingError.Context(codingPath: codingPath, debugDescription: "Cannot decode JSONAny") |
| 112 | + return DecodingError.typeMismatch(JSONAny.self, context) |
| 113 | + } |
| 114 | + |
| 115 | + static func encodingError(forValue value: Any, codingPath: [CodingKey]) -> EncodingError { |
| 116 | + let context = EncodingError.Context(codingPath: codingPath, debugDescription: "Cannot encode JSONAny") |
| 117 | + return EncodingError.invalidValue(value, context) |
| 118 | + } |
| 119 | + |
| 120 | + static func decode(from container: SingleValueDecodingContainer) throws -> Any { |
| 121 | + if let value = try? container.decode(Bool.self) { |
| 122 | + return value |
| 123 | + } |
| 124 | + if let value = try? container.decode(Int64.self) { |
| 125 | + return value |
| 126 | + } |
| 127 | + if let value = try? container.decode(Double.self) { |
| 128 | + return value |
| 129 | + } |
| 130 | + if let value = try? container.decode(String.self) { |
| 131 | + return value |
| 132 | + } |
| 133 | + if container.decodeNil() { |
| 134 | + return JSONNull() |
| 135 | + } |
| 136 | + throw decodingError(forCodingPath: container.codingPath) |
| 137 | + } |
| 138 | + |
| 139 | + static func decode(from container: inout UnkeyedDecodingContainer) throws -> Any { |
| 140 | + if let value = try? container.decode(Bool.self) { |
| 141 | + return value |
| 142 | + } |
| 143 | + if let value = try? container.decode(Int64.self) { |
| 144 | + return value |
| 145 | + } |
| 146 | + if let value = try? container.decode(Double.self) { |
| 147 | + return value |
| 148 | + } |
| 149 | + if let value = try? container.decode(String.self) { |
| 150 | + return value |
| 151 | + } |
| 152 | + if let value = try? container.decodeNil() { |
| 153 | + if value { |
| 154 | + return JSONNull() |
| 155 | + } |
| 156 | + } |
| 157 | + if var container = try? container.nestedUnkeyedContainer() { |
| 158 | + return try decodeArray(from: &container) |
| 159 | + } |
| 160 | + if var container = try? container.nestedContainer(keyedBy: JSONCodingKey.self) { |
| 161 | + return try decodeDictionary(from: &container) |
| 162 | + } |
| 163 | + throw decodingError(forCodingPath: container.codingPath) |
| 164 | + } |
| 165 | + |
| 166 | + static func decode(from container: inout KeyedDecodingContainer<JSONCodingKey>, forKey key: JSONCodingKey) throws -> Any { |
| 167 | + if let value = try? container.decode(Bool.self, forKey: key) { |
| 168 | + return value |
| 169 | + } |
| 170 | + if let value = try? container.decode(Int64.self, forKey: key) { |
| 171 | + return value |
| 172 | + } |
| 173 | + if let value = try? container.decode(Double.self, forKey: key) { |
| 174 | + return value |
| 175 | + } |
| 176 | + if let value = try? container.decode(String.self, forKey: key) { |
| 177 | + return value |
| 178 | + } |
| 179 | + if let value = try? container.decodeNil(forKey: key) { |
| 180 | + if value { |
| 181 | + return JSONNull() |
| 182 | + } |
| 183 | + } |
| 184 | + if var container = try? container.nestedUnkeyedContainer(forKey: key) { |
| 185 | + return try decodeArray(from: &container) |
| 186 | + } |
| 187 | + if var container = try? container.nestedContainer(keyedBy: JSONCodingKey.self, forKey: key) { |
| 188 | + return try decodeDictionary(from: &container) |
| 189 | + } |
| 190 | + throw decodingError(forCodingPath: container.codingPath) |
| 191 | + } |
| 192 | + |
| 193 | + static func decodeArray(from container: inout UnkeyedDecodingContainer) throws -> [Any] { |
| 194 | + var arr: [Any] = [] |
| 195 | + while !container.isAtEnd { |
| 196 | + let value = try decode(from: &container) |
| 197 | + arr.append(value) |
| 198 | + } |
| 199 | + return arr |
| 200 | + } |
| 201 | + |
| 202 | + static func decodeDictionary(from container: inout KeyedDecodingContainer<JSONCodingKey>) throws -> [String: Any] { |
| 203 | + var dict = [String: Any]() |
| 204 | + for key in container.allKeys { |
| 205 | + let value = try decode(from: &container, forKey: key) |
| 206 | + dict[key.stringValue] = value |
| 207 | + } |
| 208 | + return dict |
| 209 | + } |
| 210 | + |
| 211 | + static func encode(to container: inout UnkeyedEncodingContainer, array: [Any]) throws { |
| 212 | + for value in array { |
| 213 | + if let value = value as? Bool { |
| 214 | + try container.encode(value) |
| 215 | + } else if let value = value as? Int64 { |
| 216 | + try container.encode(value) |
| 217 | + } else if let value = value as? Double { |
| 218 | + try container.encode(value) |
| 219 | + } else if let value = value as? String { |
| 220 | + try container.encode(value) |
| 221 | + } else if value is JSONNull { |
| 222 | + try container.encodeNil() |
| 223 | + } else if let value = value as? [Any] { |
| 224 | + var container = container.nestedUnkeyedContainer() |
| 225 | + try encode(to: &container, array: value) |
| 226 | + } else if let value = value as? [String: Any] { |
| 227 | + var container = container.nestedContainer(keyedBy: JSONCodingKey.self) |
| 228 | + try encode(to: &container, dictionary: value) |
| 229 | + } else { |
| 230 | + throw encodingError(forValue: value, codingPath: container.codingPath) |
| 231 | + } |
| 232 | + } |
| 233 | + } |
| 234 | + |
| 235 | + static func encode(to container: inout KeyedEncodingContainer<JSONCodingKey>, dictionary: [String: Any]) throws { |
| 236 | + for (key, value) in dictionary { |
| 237 | + let key = JSONCodingKey(stringValue: key)! |
| 238 | + if let value = value as? Bool { |
| 239 | + try container.encode(value, forKey: key) |
| 240 | + } else if let value = value as? Int64 { |
| 241 | + try container.encode(value, forKey: key) |
| 242 | + } else if let value = value as? Double { |
| 243 | + try container.encode(value, forKey: key) |
| 244 | + } else if let value = value as? String { |
| 245 | + try container.encode(value, forKey: key) |
| 246 | + } else if value is JSONNull { |
| 247 | + try container.encodeNil(forKey: key) |
| 248 | + } else if let value = value as? [Any] { |
| 249 | + var container = container.nestedUnkeyedContainer(forKey: key) |
| 250 | + try encode(to: &container, array: value) |
| 251 | + } else if let value = value as? [String: Any] { |
| 252 | + var container = container.nestedContainer(keyedBy: JSONCodingKey.self, forKey: key) |
| 253 | + try encode(to: &container, dictionary: value) |
| 254 | + } else { |
| 255 | + throw encodingError(forValue: value, codingPath: container.codingPath) |
| 256 | + } |
| 257 | + } |
| 258 | + } |
| 259 | + |
| 260 | + static func encode(to container: inout SingleValueEncodingContainer, value: Any) throws { |
| 261 | + if let value = value as? Bool { |
| 262 | + try container.encode(value) |
| 263 | + } else if let value = value as? Int64 { |
| 264 | + try container.encode(value) |
| 265 | + } else if let value = value as? Double { |
| 266 | + try container.encode(value) |
| 267 | + } else if let value = value as? String { |
| 268 | + try container.encode(value) |
| 269 | + } else if value is JSONNull { |
| 270 | + try container.encodeNil() |
| 271 | + } else { |
| 272 | + throw encodingError(forValue: value, codingPath: container.codingPath) |
| 273 | + } |
| 274 | + } |
| 275 | + |
| 276 | + public required init(from decoder: Decoder) throws { |
| 277 | + if var arrayContainer = try? decoder.unkeyedContainer() { |
| 278 | + self.value = try JSONAny.decodeArray(from: &arrayContainer) |
| 279 | + } else if var container = try? decoder.container(keyedBy: JSONCodingKey.self) { |
| 280 | + self.value = try JSONAny.decodeDictionary(from: &container) |
| 281 | + } else { |
| 282 | + let container = try decoder.singleValueContainer() |
| 283 | + self.value = try JSONAny.decode(from: container) |
| 284 | + } |
| 285 | + } |
| 286 | + |
| 287 | + public func encode(to encoder: Encoder) throws { |
| 288 | + if let arr = self.value as? [Any] { |
| 289 | + var container = encoder.unkeyedContainer() |
| 290 | + try JSONAny.encode(to: &container, array: arr) |
| 291 | + } else if let dict = self.value as? [String: Any] { |
| 292 | + var container = encoder.container(keyedBy: JSONCodingKey.self) |
| 293 | + try JSONAny.encode(to: &container, dictionary: dict) |
| 294 | + } else { |
| 295 | + var container = encoder.singleValueContainer() |
| 296 | + try JSONAny.encode(to: &container, value: self.value) |
| 297 | + } |
| 298 | + } |
| 299 | +} |
0 commit comments