mirror of
https://github.com/encounter/JSONAPI.git
synced 2026-03-30 11:18:38 -07:00
swap out broken nil checks (not harming anything, but not working as evidenced by not getting hit by any test cases)
This commit is contained in:
@@ -71,10 +71,12 @@ extension SingleResourceBody {
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.singleValueContainer()
|
||||
|
||||
if (value as Any?) == nil {
|
||||
try container.encodeNil()
|
||||
return
|
||||
}
|
||||
let anyNil: Any? = nil
|
||||
let nilValue = anyNil as? Entity
|
||||
guard value != nilValue else {
|
||||
try container.encodeNil()
|
||||
return
|
||||
}
|
||||
|
||||
try container.encode(value)
|
||||
}
|
||||
|
||||
@@ -190,10 +190,6 @@ extension ToOneRelationship: Codable where Identifiable.Identifier: OptionalId {
|
||||
public func encode(to encoder: Encoder) throws {
|
||||
var container = encoder.container(keyedBy: ResourceLinkageCodingKeys.self)
|
||||
|
||||
if (id as Any?) == nil {
|
||||
try container.encodeNil(forKey: .data)
|
||||
}
|
||||
|
||||
if MetaType.self != NoMetadata.self {
|
||||
try container.encode(meta, forKey: .meta)
|
||||
}
|
||||
|
||||
@@ -100,6 +100,9 @@ class ResourceBodyTests: XCTestCase {
|
||||
XCTAssertEqual(combined.values.count, 3)
|
||||
XCTAssertEqual(combined.values, body1.values + body2.values)
|
||||
}
|
||||
}
|
||||
|
||||
extension ResourceBodyTests {
|
||||
|
||||
enum ArticleType: ResourceObjectDescription {
|
||||
public static var jsonType: String { return "articles" }
|
||||
|
||||
Reference in New Issue
Block a user