diff --git a/Pachyderm/Model/Application.swift b/Pachyderm/Model/Application.swift index fa640135..4a762e05 100644 --- a/Pachyderm/Model/Application.swift +++ b/Pachyderm/Model/Application.swift @@ -12,6 +12,19 @@ public class Application: Decodable { public let name: String public let website: URL? + public required init(from decoder: Decoder) throws { + let container = try decoder.container(keyedBy: CodingKeys.self) + + self.name = try container.decode(String.self, forKey: .name) + + if let websiteStr = try container.decodeIfPresent(String.self, forKey: .website), + let url = URL(string: websiteStr) { + self.website = url + } else { + self.website = nil + } + } + private enum CodingKeys: String, CodingKey { case name case website