diff --git a/JSONAPI.playground/Sources/Entities.swift b/JSONAPI.playground/Sources/Entities.swift index c340862..58345c9 100644 --- a/JSONAPI.playground/Sources/Entities.swift +++ b/JSONAPI.playground/Sources/Entities.swift @@ -63,7 +63,7 @@ public enum PersonDescription: EntityDescription { public typealias Person = ExampleEntity public extension Entity where Description == PersonDescription, MetaType == NoMetadata, LinksType == NoLinks, EntityRawIdType == String { - public init(id: Person.Id? = nil,name: [String], favoriteColor: String, friends: [Person], dogs: [Dog], home: House) throws { + init(id: Person.Id? = nil,name: [String], favoriteColor: String, friends: [Person], dogs: [Dog], home: House) throws { self = Person(id: id ?? Person.Id(), attributes: .init(name: .init(value: name), favoriteColor: .init(value: favoriteColor)), relationships: .init(friends: .init(entities: friends), dogs: .init(entities: dogs), home: .init(entity: home)), meta: .none, links: .none) } } @@ -120,11 +120,11 @@ public enum AlternativeDogDescription: EntityDescription { public typealias AlternativeDog = ExampleEntity public extension Entity where Description == DogDescription, MetaType == NoMetadata, LinksType == NoLinks, EntityRawIdType == String { - public init(name: String, owner: Person?) throws { + init(name: String, owner: Person?) throws { self = Dog(attributes: .init(name: .init(value: name)), relationships: DogDescription.Relationships(owner: .init(entity: owner)), meta: .none, links: .none) } - public init(name: String, owner: Person.Id) throws { + init(name: String, owner: Person.Id) throws { self = Dog(attributes: .init(name: .init(value: name)), relationships: .init(owner: .init(id: owner)), meta: .none, links: .none) } } 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 49f332d..f596612 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 } } @@ -527,14 +527,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 Identifier>) -> Identifier { + static func ~>(entity: Self, path: KeyPath Identifier>) -> Identifier { return entity.relationships[keyPath: path](entity) } /// 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 [Identifier]>) -> [Identifier] { + static func ~>(entity: Self, path: KeyPath [Identifier]>) -> [Identifier] { return entity.relationships[keyPath: path](entity) } } @@ -552,7 +552,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) @@ -578,7 +578,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/JSONAPITesting/EntityCheck.swift b/Sources/JSONAPITesting/EntityCheck.swift index 1b7bd1f..abac22b 100644 --- a/Sources/JSONAPITesting/EntityCheck.swift +++ b/Sources/JSONAPITesting/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) diff --git a/Tests/JSONAPITests/Poly/PolyProxyTests.swift b/Tests/JSONAPITests/Poly/PolyProxyTests.swift index 5c6cd87..01dcfb6 100644 --- a/Tests/JSONAPITests/Poly/PolyProxyTests.swift +++ b/Tests/JSONAPITests/Poly/PolyProxyTests.swift @@ -65,7 +65,7 @@ public class PolyProxyTests: XCTestCase { // MARK: - Test types public extension PolyProxyTests { - public enum UserDescription1: EntityDescription { + enum UserDescription1: EntityDescription { public static var jsonType: String { return "users" } public struct Attributes: JSONAPI.Attributes { @@ -76,7 +76,7 @@ public extension PolyProxyTests { public typealias Relationships = NoRelationships } - public enum UserDescription2: EntityDescription { + enum UserDescription2: EntityDescription { public static var jsonType: String { return "users" } public struct Attributes: JSONAPI.Attributes {