Skip to content

Commit aec39fc

Browse files
committed
trying to determine when a primary resource error should be plural or not.
1 parent 9e8c288 commit aec39fc

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Sources/JSONAPI/Document/DocumentDecodingError.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public enum DocumentDecodingError: Swift.Error, Equatable {
3333
self = .primaryResourceMissing
3434
case .valueNotFound(let type, let context) where Location(context) == .data && type == UnkeyedDecodingContainer.self:
3535
self = .primaryResourcesMissing
36-
case .typeMismatch(let type, let context) where Location(context) == .data && type == UnkeyedDecodingContainer.self && context.debugDescription.hasSuffix("but found null instead."):
36+
case .typeMismatch(let type, let context) where Location(context) == .data && type is _ArrayType.Type && context.debugDescription.hasSuffix("but found null instead."):
3737
self = .primaryResourcesMissing
3838
case .typeMismatch(_, let context) where Location(context) == .data && context.debugDescription.hasSuffix("but found null instead."):
3939
self = .primaryResourceMissing
@@ -75,3 +75,6 @@ extension DocumentDecodingError: CustomStringConvertible {
7575
}
7676
}
7777
}
78+
79+
private protocol _ArrayType {}
80+
extension Array: _ArrayType {}

Tests/JSONAPITests/Document/DocumentDecodingErrorTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ final class DocumentDecodingErrorTests: XCTestCase {
5353
) { error in
5454
guard let docError = error as? DocumentDecodingError,
5555
case .primaryResourcesMissing = docError else {
56-
XCTFail("Expected primary resource missing error. Got \(error)")
56+
XCTFail("Expected primary resources missing error. Got \(error)")
5757
return
5858
}
5959

0 commit comments

Comments
 (0)