diff --git a/Sources/JSONAPI/Document/Document.swift b/Sources/JSONAPI/Document/Document.swift index 2cbf4e7..5c8160b 100644 --- a/Sources/JSONAPI/Document/Document.swift +++ b/Sources/JSONAPI/Document/Document.swift @@ -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(_ includes: Includes) -> Document { + public func including(_ includes: Includes) -> 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. @@ -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) -> Document { + public func including(_ includes: Includes) -> 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. diff --git a/Tests/JSONAPITests/Document/DocumentTests.swift b/Tests/JSONAPITests/Document/DocumentTests.swift index 48ed1c8..bbf36e9 100644 --- a/Tests/JSONAPITests/Document/DocumentTests.swift +++ b/Tests/JSONAPITests/Document/DocumentTests.swift @@ -720,6 +720,7 @@ extension DocumentTests { let documentWithIncludes = document.including(Includes>(values: [.init(author)])) + XCTAssert(type(of: documentWithIncludes) == Document, 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)