Skip to content

Commit bc88870

Browse files
committed
[Chore] Decode Resource without id
1 parent d3666e6 commit bc88870

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Sources/JSONAPIMapper/Models/Resource.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public struct Resource: JSONAPICodable {
2222

2323
public init(from decoder: Decoder) throws {
2424
let container = try decoder.container(keyedBy: CodingKeys.self)
25-
id = try container.decode(String.self, forKey: .id)
25+
id = (try? container.decode(String.self, forKey: .id)) ?? UUID().uuidString
2626
type = try container.decode(String.self, forKey: .type)
2727
attributes = try container.decodeIfPresent(JSON.self, forKey: .attributes)
2828
relationships = try container.decodeIfPresent([String: Relationship].self, forKey: .relationships)

0 commit comments

Comments
 (0)