Compare commits

...

1 Commits

Author SHA1 Message Date
Mathew Polzin 1a15ab6f9d Fix return type of success document after adding includes 2019-10-27 16:21:41 -07:00
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -509,7 +509,7 @@ extension Document.SuccessDocument: Decodable, JSONAPIDocument
extension Document.SuccessDocument where IncludeType == NoIncludes {
/// Create a new Document with the given includes.
public func including<I: JSONAPI.Include>(_ includes: Includes<I>) -> Document<PrimaryResourceBody, MetaType, LinksType, I, APIDescription, Error> {
public func including<I: JSONAPI.Include>(_ includes: Includes<I>) -> Document<PrimaryResourceBody, MetaType, LinksType, I, APIDescription, Error>.SuccessDocument {
// Note that if IncludeType is NoIncludes, then we allow anything
// to be included, but if IncludeType already specifies a type
// of thing to be expected then we lock that down.
@@ -531,7 +531,7 @@ extension Document.SuccessDocument where IncludeType == NoIncludes {
extension Document.SuccessDocument where IncludeType: _Poly1 {
/// Create a new Document adding the given includes. This does not
/// remove existing includes; it is additive.
public func including(_ includes: Includes<IncludeType>) -> Document {
public func including(_ includes: Includes<IncludeType>) -> Document.SuccessDocument {
// Note that if IncludeType is NoIncludes, then we allow anything
// to be included, but if IncludeType already specifies a type
// of thing to be expected then we lock that down.
@@ -720,6 +720,7 @@ extension DocumentTests {
let documentWithIncludes = document.including(Includes<Include1<Author>>(values: [.init(author)]))
XCTAssert(type(of: documentWithIncludes) == Document<NoResourceBody, NoMetadata, NoLinks, Include1<Author>, NoAPIDescription, UnknownJSONAPIError>.SuccessDocument.self)
XCTAssertEqual(document.body.errors, documentWithIncludes.body.errors)
XCTAssertEqual(document.body.meta, documentWithIncludes.body.meta)
XCTAssertEqual(document.body.links, documentWithIncludes.body.links)