Skip to content

Commit d3457ae

Browse files
authored
Merge pull request #124 from mattpolzin/modernize
remove support for non-SwiftPM package managers. require Swift 6.0+.
2 parents 31b6653 + 1e6b531 commit d3457ae

28 files changed

+112
-224
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,12 @@ jobs:
1313
fail-fast: false
1414
matrix:
1515
image:
16-
- swift:5.2-focal
17-
- swift:5.2-centos8
18-
- swift:5.3-focal
19-
- swift:5.3-centos8
20-
- swift:5.4-focal
21-
- swift:5.4-centos8
22-
- swift:5.5-focal
23-
- swift:5.5-centos8
24-
- swift:5.6-focal
25-
# - swift:5.7-focal
26-
# - swift:5.8-focal
27-
# - swift:5.9-focal
28-
# - swift:5.10-focal
16+
- swift:6.0
17+
- swift:6.1
2918
container: ${{ matrix.image }}
3019
steps:
3120
- name: Checkout code
32-
uses: actions/checkout@v3
21+
uses: actions/checkout@v5
3322
- name: Run tests
3423
run: swift test --enable-test-discovery
3524
osx:
@@ -39,6 +28,6 @@ jobs:
3928
uses: maxim-lobanov/setup-xcode@v1
4029
with: { 'xcode-version': 'latest' }
4130
- name: Checkout code
42-
uses: actions/checkout@v3
31+
uses: actions/checkout@v5
4332
- name: Run tests
4433
run: swift test --enable-test-discovery

JSONAPI.podspec

Lines changed: 0 additions & 141 deletions
This file was deleted.

Package.resolved

Lines changed: 12 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// swift-tools-version:5.2
1+
// swift-tools-version:6.0
22

33
import PackageDescription
44

55
let package = Package(
66
name: "JSONAPI",
77
platforms: [
8-
.macOS(.v10_10),
9-
.iOS(.v10)
8+
.macOS(.v10_15),
9+
.iOS(.v13)
1010
],
1111
products: [
1212
.library(
@@ -17,7 +17,7 @@ let package = Package(
1717
targets: ["JSONAPITesting"])
1818
],
1919
dependencies: [
20-
.package(url: "https://github.com/mattpolzin/Poly.git", .upToNextMajor(from: "2.8.0")),
20+
.package(url: "https://github.com/mattpolzin/Poly.git", .upToNextMajor(from: "3.0.0")),
2121
],
2222
targets: [
2323
.target(
@@ -33,5 +33,5 @@ let package = Package(
3333
name: "JSONAPITestingTests",
3434
dependencies: ["JSONAPI", "JSONAPITesting"])
3535
],
36-
swiftLanguageVersions: [.v5]
36+
swiftLanguageModes: [.v5, .v6]
3737
)

README.md

Lines changed: 4 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# JSONAPI
2-
[![MIT license](http://img.shields.io/badge/license-MIT-lightgrey.svg)](http://opensource.org/licenses/MIT) [![Swift 5.2+](http://img.shields.io/badge/Swift-5.2+-blue.svg)](https://swift.org) [![Tests](https://github.com/mattpolzin/JSONAPI/actions/workflows/tests.yml/badge.svg)](https://github.com/mattpolzin/JSONAPI/actions/workflows/tests.yml)
2+
[![MIT license](http://img.shields.io/badge/license-MIT-lightgrey.svg)](http://opensource.org/licenses/MIT) [![Swift 6.0+](http://img.shields.io/badge/Swift-6.0+-blue.svg)](https://swift.org) [![Tests](https://github.com/mattpolzin/JSONAPI/actions/workflows/tests.yml/badge.svg)](https://github.com/mattpolzin/JSONAPI/actions/workflows/tests.yml)
33

44
A Swift package for encoding to- and decoding from **JSON API** compliant requests and responses.
55

@@ -58,35 +58,15 @@ If you find something wrong with this library and it isn't already mentioned und
5858

5959
## Dev Environment
6060
### Prerequisites
61-
1. Swift 5.2+
62-
2. Swift Package Manager, Xcode 11+, or Cocoapods
61+
1. Swift 6.0+
62+
2. Swift Package Manager
6363

6464
### Swift Package Manager
6565
Just include the following in your package's dependencies and add `JSONAPI` to the dependencies for any of your targets.
6666
```swift
67-
.package(url: "https://github.com/mattpolzin/JSONAPI.git", from: "5.1.0")
67+
.package(url: "https://github.com/mattpolzin/JSONAPI.git", from: "6.0.0")
6868
```
6969

70-
### Xcode project
71-
With Xcode 11+, you can open the folder containing this repository. There is no need for an Xcode project, but you can generate one with `swift package generate-xcodeproj`.
72-
73-
### CocoaPods
74-
To use this framework in your project via Cocoapods, add the following dependencies to your Podfile.
75-
```ruby
76-
pod 'Poly', :git => 'https://github.com/mattpolzin/Poly.git'
77-
pod 'MP-JSONAPI', :git => 'https://github.com/mattpolzin/JSONAPI.git'
78-
```
79-
80-
### Carthage
81-
This library does not support the Carthage package manager. This is intentional to avoid an additional dependency on Xcode and the Xcode's project files as their format changes throughout versions (in addition to the complexity of maintaining different shared schemes for each supported operating system).
82-
83-
The difference between supporting and not supporting Carthage is the difference between maintaining an Xcode project with at least one shared build scheme; I encourage those that need Carthage support to fork this repository and add support to their fork by committing an Xcode project (you can generate one as described in the [Xcode project](#xcode-project) section above). Once an Xcode project is generated, you need to mark at least one scheme as [shared](https://github.com/Carthage/Carthage#share-your-xcode-schemes).
84-
85-
### Running the Playground
86-
To run the included Playground files, create an Xcode project using Swift Package Manager, then create an Xcode Workspace in the root of the repository and add both the generated Xcode project and the playground to the Workspace.
87-
88-
Note that Playground support for importing non-system Frameworks is still a bit touchy as of Swift 4.2. Sometimes building, cleaning and building, or commenting out and then uncommenting import statements (especially in the` Entities.swift` Playground Source file) can get things working for me when I am getting an error about `JSONAPI` not being found.
89-
9070
## Deeper Dive
9171
- [Project Status](./documentation/project-status.md)
9272
- [Server & Client Example](./documentation/examples/client-server-example.md)

Sources/JSONAPI/Document/APIDescription.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public struct APIDescription<Meta: JSONAPI.Meta>: APIDescriptionType {
2121
}
2222
}
2323

24+
extension APIDescription: Sendable where Meta: Sendable {}
25+
2426
/// Can be used as `APIDescriptionType` for Documents that do not
2527
/// have any API Description (a.k.a. "JSON:API Object").
2628
public struct NoAPIDescription: APIDescriptionType, CustomStringConvertible {
@@ -33,6 +35,8 @@ public struct NoAPIDescription: APIDescriptionType, CustomStringConvertible {
3335
public var description: String { return "No JSON:API Object" }
3436
}
3537

38+
extension NoAPIDescription: Sendable {}
39+
3640
extension APIDescription {
3741
private enum CodingKeys: String, CodingKey {
3842
case version

Sources/JSONAPI/Document/Document.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,10 @@ public struct Document<PrimaryResourceBody: JSONAPI.EncodableResourceBody, MetaT
186186
}
187187
}
188188

189+
extension Document: Sendable where
190+
APIDescription: Sendable,
191+
Body: Sendable {}
192+
189193
extension Document {
190194
public enum Body: DocumentBody, Equatable {
191195
case errors([Error], meta: MetaType?, links: LinksType?)
@@ -260,6 +264,17 @@ extension Document {
260264
}
261265
}
262266

267+
extension Document.Body: Sendable where
268+
MetaType: Sendable,
269+
LinksType: Sendable,
270+
Data: Sendable {}
271+
272+
extension Document.Body.Data: Sendable where
273+
PrimaryResourceBody: Sendable,
274+
IncludeType: Sendable,
275+
MetaType: Sendable,
276+
LinksType: Sendable {}
277+
263278
extension Document.Body.Data where PrimaryResourceBody: ResourceBodyAppendable {
264279
public func merging<OtherDescription, OtherError>(_ other: Document<PrimaryResourceBody, MetaType, LinksType, IncludeType, OtherDescription, OtherError>.Body.Data,
265280
combiningMetaWith metaMerge: (MetaType, MetaType) -> MetaType,

Sources/JSONAPI/Document/Includes.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ public struct Includes<I: Include>: Encodable, Equatable {
4545
}
4646
}
4747

48+
extension Includes: Sendable where I: Sendable {}
49+
4850
extension Includes: Decodable where I: Decodable {
4951
public init(from decoder: Decoder) throws {
5052
var container = try decoder.unkeyedContainer()

Sources/JSONAPI/Document/ResourceBody.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@ public struct SingleResourceBody<PrimaryResource: JSONAPI.OptionalEncodablePrima
6565
}
6666
}
6767

68+
extension SingleResourceBody: Sendable where PrimaryResource: Sendable {}
69+
6870
public protocol ManyResourceBodyProtocol: EncodableResourceBody {
6971
var values: [PrimaryResource] { get }
7072

@@ -84,6 +86,8 @@ public struct ManyResourceBody<PrimaryResource: JSONAPI.EncodablePrimaryResource
8486
}
8587
}
8688

89+
extension ManyResourceBody: Sendable where PrimaryResource: Sendable {}
90+
8791
/// Use NoResourceBody to indicate you expect a JSON API document to not
8892
/// contain a "data" top-level key.
8993
public struct NoResourceBody: CodableResourceBody {
@@ -92,6 +96,8 @@ public struct NoResourceBody: CodableResourceBody {
9296
public static var none: NoResourceBody { return NoResourceBody() }
9397
}
9498

99+
extension NoResourceBody: Sendable {}
100+
95101
// MARK: Codable
96102
extension SingleResourceBody {
97103
public func encode(to encoder: Encoder) throws {

Sources/JSONAPI/Error/BasicJSONAPIError.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public struct BasicJSONAPIErrorPayload<IdType: Codable & Equatable>: Codable, Eq
3939
self.source = source
4040
}
4141

42-
public struct Source: Codable, Equatable {
42+
public struct Source: Codable, Equatable, Sendable {
4343
/// a JSON Pointer [RFC6901] to the associated entity in the request document [e.g. "/data" for a primary data object, or "/data/attributes/title" for a specific attribute].
4444
public let pointer: String?
4545
/// which URI query parameter caused the error
@@ -70,6 +70,8 @@ public struct BasicJSONAPIErrorPayload<IdType: Codable & Equatable>: Codable, Eq
7070
}
7171
}
7272

73+
extension BasicJSONAPIErrorPayload: Sendable where IdType: Sendable {}
74+
7375
/// `BasicJSONAPIError` optionally decodes many possible fields
7476
/// specified by the JSON:API 1.0 Spec. It gives no type-guarantees of what
7577
/// will be non-nil, but could provide good diagnostic information when
@@ -100,4 +102,4 @@ public struct BasicJSONAPIErrorPayload<IdType: Codable & Equatable>: Codable, Eq
100102
/// with non-nil values in a flattened way. There will be no `source` key
101103
/// but there will be `pointer` and `parameter` keys (if those values
102104
/// are non-nil).
103-
public typealias BasicJSONAPIError<IdType: Codable & Equatable> = GenericJSONAPIError<BasicJSONAPIErrorPayload<IdType>>
105+
public typealias BasicJSONAPIError<IdType: Codable & Equatable & Sendable> = GenericJSONAPIError<BasicJSONAPIErrorPayload<IdType>>

0 commit comments

Comments
 (0)