diff --git a/Package.swift b/Package.swift index 7adbb9b..6fdb92d 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:4.2 +// swift-tools-version:5.0 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription diff --git a/Sources/JSONAPI/Resource/Attribute+Functor.swift b/Sources/JSONAPI/Resource/Attribute+Functor.swift index e914e2e..1da6ff0 100644 --- a/Sources/JSONAPI/Resource/Attribute+Functor.swift +++ b/Sources/JSONAPI/Resource/Attribute+Functor.swift @@ -15,7 +15,7 @@ public extension TransformedAttribute { /// Generally, this is the most useful operation. The transformer gives you /// control over the decoding of the Attribute, but once the Attribute exists, /// mapping on it is most useful for creating computed Attribute properties. - public func map(_ transform: (Transformer.To) throws -> T) rethrows -> Attribute { + func map(_ transform: (Transformer.To) throws -> T) rethrows -> Attribute { return Attribute(value: try transform(value)) } } @@ -30,7 +30,7 @@ public extension Attribute { /// Generally, this is the most useful operation. The transformer gives you /// control over the decoding of the Attribute, but once the Attribute exists, /// mapping on it is most useful for creating computed Attribute properties. - public func map(_ transform: (ValueType) throws -> T) rethrows -> Attribute { + func map(_ transform: (ValueType) throws -> T) rethrows -> Attribute { return Attribute(value: try transform(value)) } } diff --git a/Sources/JSONAPI/Resource/Entity.swift b/Sources/JSONAPI/Resource/Entity.swift index 6d6da14..22f16fe 100644 --- a/Sources/JSONAPI/Resource/Entity.swift +++ b/Sources/JSONAPI/Resource/Entity.swift @@ -397,20 +397,20 @@ public extension Entity where EntityRawIdType: JSONAPI.RawIdType { /// An Entity.Pointer is a `ToOneRelationship` with no metadata or links. /// This is just a convenient way to reference an Entity so that /// other Entities' Relationships can be built up from it. - public typealias Pointer = ToOneRelationship + typealias Pointer = ToOneRelationship /// Entity.Pointers is a `ToManyRelationship` with no metadata or links. /// This is just a convenient way to reference a bunch of Entities so /// that other Entities' Relationships can be built up from them. - public typealias Pointers = ToManyRelationship + typealias Pointers = ToManyRelationship /// Get a pointer to this entity that can be used as a /// relationship to another entity. - public var pointer: Pointer { + var pointer: Pointer { return Pointer(entity: self) } - public func pointer(withMeta meta: MType, links: LType) -> ToOneRelationship { + func pointer(withMeta meta: MType, links: LType) -> ToOneRelationship { return ToOneRelationship(entity: self, meta: meta, links: links) } } @@ -419,19 +419,19 @@ public extension Entity where EntityRawIdType: JSONAPI.RawIdType { public extension Entity where EntityRawIdType == Unidentified { /// Create a new Entity from this one with a newly created /// unique Id of the given type. - public func identified(byType: RawIdType.Type) -> Entity { + func identified(byType: RawIdType.Type) -> Entity { return .init(attributes: attributes, relationships: relationships, meta: meta, links: links) } /// Create a new Entity from this one with the given Id. - public func identified(by id: RawIdType) -> Entity { + func identified(by id: RawIdType) -> Entity { return .init(id: Entity.Identifier(rawValue: id), attributes: attributes, relationships: relationships, meta: meta, links: links) } } public extension Entity where EntityRawIdType: CreatableRawIdType { /// Create a copy of this Entity with a new unique Id. - public func withNewIdentifier() -> Entity { + func withNewIdentifier() -> Entity { return Entity(attributes: attributes, relationships: relationships, meta: meta, links: links) } } @@ -485,14 +485,14 @@ public extension EntityProxy { /// Access to an Id of a `ToOneRelationship`. /// This allows you to write `entity ~> \.other` instead /// of `entity.relationships.other.id`. - public static func ~>(entity: Self, path: KeyPath>) -> OtherEntity.Identifier { + static func ~>(entity: Self, path: KeyPath>) -> OtherEntity.Identifier { return entity.relationships[keyPath: path].id } /// Access to an Id of an optional `ToOneRelationship`. /// This allows you to write `entity ~> \.other` instead /// of `entity.relationships.other?.id`. - public static func ~>(entity: Self, path: KeyPath?>) -> OtherEntity.Identifier { + static func ~>(entity: Self, path: KeyPath?>) -> OtherEntity.Identifier { // Implementation Note: This signature applies to `ToOneRelationship?` // whereas the one below applies to `ToOneRelationship?` return entity.relationships[keyPath: path]?.id @@ -501,7 +501,7 @@ public extension EntityProxy { /// Access to an Id of an optional `ToOneRelationship`. /// This allows you to write `entity ~> \.other` instead /// of `entity.relationships.other?.id`. - public static func ~>(entity: Self, path: KeyPath?>) -> OtherEntity.Identifier? { + static func ~>(entity: Self, path: KeyPath?>) -> OtherEntity.Identifier? { // Implementation Note: This signature applies to `ToOneRelationship?` // whereas the one above applies to `ToOneRelationship?` return entity.relationships[keyPath: path]?.id @@ -510,14 +510,14 @@ public extension EntityProxy { /// Access to all Ids of a `ToManyRelationship`. /// This allows you to write `entity ~> \.others` instead /// of `entity.relationships.others.ids`. - public static func ~>(entity: Self, path: KeyPath>) -> [OtherEntity.Identifier] { + static func ~>(entity: Self, path: KeyPath>) -> [OtherEntity.Identifier] { return entity.relationships[keyPath: path].ids } /// Access to all Ids of an optional `ToManyRelationship`. /// This allows you to write `entity ~> \.others` instead /// of `entity.relationships.others?.ids`. - public static func ~>(entity: Self, path: KeyPath?>) -> [OtherEntity.Identifier]? { + static func ~>(entity: Self, path: KeyPath?>) -> [OtherEntity.Identifier]? { return entity.relationships[keyPath: path]?.ids } } @@ -535,7 +535,7 @@ private enum ResourceObjectCodingKeys: String, CodingKey { } public extension Entity { - public func encode(to encoder: Encoder) throws { + func encode(to encoder: Encoder) throws { var container = encoder.container(keyedBy: ResourceObjectCodingKeys.self) try container.encode(Entity.jsonType, forKey: .type) @@ -561,7 +561,7 @@ public extension Entity { } } - public init(from decoder: Decoder) throws { + init(from decoder: Decoder) throws { let container = try decoder.container(keyedBy: ResourceObjectCodingKeys.self) diff --git a/Sources/JSONAPITestLib/EntityCheck.swift b/Sources/JSONAPITestLib/EntityCheck.swift index 2a91e31..8c516f3 100644 --- a/Sources/JSONAPITestLib/EntityCheck.swift +++ b/Sources/JSONAPITestLib/EntityCheck.swift @@ -55,7 +55,7 @@ extension TransformedAttribute: _AttributeType {} extension Attribute: _AttributeType {} public extension Entity { - public static func check(_ entity: Entity) throws { + static func check(_ entity: Entity) throws { var problems = [EntityCheckError]() let attributesMirror = Mirror(reflecting: entity.attributes)