Skip to content

Commit 7e8df50

Browse files
committed
Empty resource
1 parent d40a5a0 commit 7e8df50

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Sources/JSONMapper/JSONAPIDecoder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ extension JSONAPIDecoder {
129129
private func getResource(from includedDictionary: ResourceDictionary,
130130
for identifier: ResourceIdentifier) throws -> Resource {
131131
guard let resource = includedDictionary[identifier] else {
132-
throw Errors.JSONAPIDecodingError.resourceNotFound(identifier: identifier)
132+
return Resource(id: identifier.id, type: identifier.type)
133133
}
134134
return resource
135135
}

Sources/JSONMapper/Models/Resource.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,13 @@ public struct Resource: JSONAPICodable {
2929
links = try container.decodeIfPresent(Links.self, forKey: .links)
3030
meta = try container.decodeIfPresent(JSON.self, forKey: .meta)
3131
}
32+
33+
init(id: String, type: String) {
34+
self.id = id
35+
self.type = type
36+
self.attributes = nil
37+
self.relationships = nil
38+
self.links = nil
39+
self.meta = nil
40+
}
3241
}

0 commit comments

Comments
 (0)