diff --git a/JSONAPI.playground/Pages/PATCHing.xcplaygroundpage/Contents.swift b/JSONAPI.playground/Pages/PATCHing.xcplaygroundpage/Contents.swift index ded305e..f916054 100644 --- a/JSONAPI.playground/Pages/PATCHing.xcplaygroundpage/Contents.swift +++ b/JSONAPI.playground/Pages/PATCHing.xcplaygroundpage/Contents.swift @@ -108,7 +108,7 @@ print("Received dog with owner: \(dog3 ~> \.owner)") // give the dog an owner let changedDog3 = dog3.replacingRelationships { _ in - return .init(owner: .init(id: ID(rawValue: "1"))) + return .init(owner: .init(id: Id(rawValue: "1"))) } // create a document to be used as a request body for a PATCH request diff --git a/Sources/JSONAPI/Resource/Resource Object/ResourceObject.swift b/Sources/JSONAPI/Resource/Resource Object/ResourceObject.swift index b068ebd..88ae539 100644 --- a/Sources/JSONAPI/Resource/Resource Object/ResourceObject.swift +++ b/Sources/JSONAPI/Resource/Resource Object/ResourceObject.swift @@ -73,8 +73,6 @@ public protocol ResourceObjectProxy: Equatable, JSONTyped { associatedtype Description: ResourceObjectProxyDescription associatedtype EntityRawIdType: JSONAPI.MaybeRawId - typealias ID = JSONAPI.Id - typealias Attributes = Description.Attributes typealias Relationships = Description.Relationships @@ -82,7 +80,7 @@ public protocol ResourceObjectProxy: Equatable, JSONTyped { /// the entity is being created clientside and the /// server is being asked to create a unique Id. Otherwise, /// this should be of a type conforming to `IdType`. - var id: ID { get } + var id: JSONAPI.Id { get } /// The JSON API compliant attributes of this `Entity`. var attributes: Attributes { get } @@ -91,6 +89,10 @@ public protocol ResourceObjectProxy: Equatable, JSONTyped { var relationships: Relationships { get } } +extension ResourceObjectProxy { + public typealias ID = JSONAPI.Id +} + extension ResourceObjectProxy { /// The JSON API compliant "type" of this `ResourceObject`. public static var jsonType: String { return Description.jsonType } @@ -121,7 +123,6 @@ public protocol IdentifiableResourceObjectType: ResourceObjectType, Relatable wh /// See https://jsonapi.org/format/#document-resource-objects public struct ResourceObject: ResourceObjectType { - public typealias ID = JSONAPI.Id public typealias Meta = MetaType public typealias Links = LinksType