Few fixes and improvements to the library, plus Github Actions setup (#31)
CI / Build and test (push) Canceled after 0s
Documentation / Build documentation (push) Canceled after 0s
Documentation / Deploy to GitHub Pages (push) Canceled after 0s
CI / Build and test (push) Canceled after 0s
Documentation / Build documentation (push) Canceled after 0s
Documentation / Deploy to GitHub Pages (push) Canceled after 0s
This PR contains the work done to fix a cancellation-mapping bug in `AmiiboLiveClient`, bring the client under offline test coverage, add the conformances SwiftUI and persistence need, and moves CI and documentation publishing to GitHub Actions. All public API changes are additive.
### Fix
- `AmiiboLiveClient` reported an early task cancellation as `.unknown("CancellationError()")`. The OpenAPI runtime wraps every error in `ClientError`, so the `CancellationError` check never matched; it now also checks the wrapped error and throws `.cancelled`.
### Tests
- `ThrowingTransport` and `StubTransport` test doubles let the live client run offline. New tests cover error mapping, HTTP status → error mapping, `oneOf` object-vs-list decoding, `"amiibo": null`, sorting, filter → query encoding, `Platform`/`Release` mapping, and the date transcoder.
- Models gained `package` memberwise initializers so tests can build real fixtures without `@testable`. These are not public API.
- The test target now depends on `OpenAPIRuntime` and `HTTPTypes` (both already in the dependency graph).
### API
- Models are `Codable` and `Identifiable` (`Amiibo.id` is its `identifier`; the key/name models use `key`).
- Filters are `Hashable`.
### Documentation
- Doc comments trimmed library-wide; one repeated `- Throws:` sentence appeared 24 times. `Library.md` and the README tightened to match.
### CI and docs publishing
- `ci.yml`: build and offline tests on PRs and pushes to `main`.
- `live-tests.yml`: weekly and on-demand run against the live API.
- `docs.yml`: builds DocC on PRs, deploys to GitHub Pages on `main`. Pinned to Xcode 26 because swift-docc-plugin 1.5.0 fails to launch its tools under Xcode 27.
- The generated `docs/` folder (327 files) is removed from the repository and ignored.
Reviewed-on: #31
Co-authored-by: Javier Cicchelli <javier@rock-n-code.com>
This commit was merged in pull request #31.
This commit is contained in:
1 parent
44bfaca553
commit
13b9c74a38
361 files changed
+1395
-863
No files matched your search
@@ -15,7 +15,7 @@
|
||||
import Foundation
|
||||
|
||||
/// A model that represents an amiibo.
|
||||
public struct Amiibo: Sendable, Hashable {
|
||||
public struct Amiibo: Sendable, Hashable, Codable, Identifiable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -36,7 +36,7 @@ public struct Amiibo: Sendable, Hashable {
|
||||
|
||||
/// The related games of this amiibo, grouped by platform.
|
||||
///
|
||||
/// This value is `nil` unless the request sets ``AmiiboFilter/showGames`` or ``AmiiboFilter/showUsage``, or when the amiibo has no related games.
|
||||
/// `nil` unless the request sets ``AmiiboFilter/showGames`` or ``AmiiboFilter/showUsage``, or when there are no related games.
|
||||
public let platform: Platform?
|
||||
|
||||
/// The release dates of this amiibo across different regions.
|
||||
@@ -52,7 +52,32 @@ public struct Amiibo: Sendable, Hashable {
|
||||
public let type: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
|
||||
/// Initializes this model.
|
||||
package init(
|
||||
head: String,
|
||||
tail: String,
|
||||
name: String,
|
||||
type: String,
|
||||
series: String,
|
||||
gameCharacter: String,
|
||||
gameSeries: String,
|
||||
image: String,
|
||||
release: Release = .init(),
|
||||
platform: Platform? = nil
|
||||
) {
|
||||
self.gameCharacter = gameCharacter
|
||||
self.gameSeries = gameSeries
|
||||
self.head = head
|
||||
self.image = image
|
||||
self.name = name
|
||||
self.platform = platform
|
||||
self.release = release
|
||||
self.series = series
|
||||
self.tail = tail
|
||||
self.type = type
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.Amiibo) {
|
||||
@@ -74,7 +99,12 @@ public struct Amiibo: Sendable, Hashable {
|
||||
}
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
|
||||
/// The ``identifier`` of this amiibo.
|
||||
public var id: String {
|
||||
identifier
|
||||
}
|
||||
|
||||
/// The full 16-character hexadecimal identifier, composed of the ``head`` and ``tail``.
|
||||
public var identifier: String {
|
||||
head + tail
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a game related to an amiibo.
|
||||
public struct Game: Sendable, Hashable {
|
||||
public struct Game: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -29,6 +29,17 @@ extension Amiibo {
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model.
|
||||
package init(
|
||||
identifiers: [String],
|
||||
name: String,
|
||||
usages: [Usage]? = nil
|
||||
) {
|
||||
self.identifiers = identifiers
|
||||
self.name = name
|
||||
self.usages = usages
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.AmiiboGame) {
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
// ===----------------------------------------------------------------------===
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents a collection of `Switch`, `Switch 2`, `3DS`, and `Wii U` games related to an amiibo.
|
||||
public struct Platform: Sendable, Hashable {
|
||||
/// A model that groups the games related to an amiibo by platform.
|
||||
public struct Platform: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -31,8 +31,21 @@ extension Amiibo {
|
||||
public let wiiU: [Game]
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
|
||||
/// Initializes this model.
|
||||
package init(
|
||||
`switch`: [Game] = [],
|
||||
switch2: [Game] = [],
|
||||
threeDS: [Game] = [],
|
||||
wiiU: [Game] = []
|
||||
) {
|
||||
self.switch = `switch`
|
||||
self.switch2 = switch2
|
||||
self.threeDS = threeDS
|
||||
self.wiiU = wiiU
|
||||
}
|
||||
|
||||
/// Initializes this model from the given payloads.
|
||||
///
|
||||
/// > important: In case no data is provided, then an instance of this model is not created.
|
||||
///
|
||||
|
||||
@@ -18,7 +18,7 @@ extension Amiibo {
|
||||
/// A model that represents the regional release dates of an amiibo.
|
||||
///
|
||||
/// The service provides these dates as date-only values, which are decoded as midnight UTC.
|
||||
public struct Release: Sendable, Hashable {
|
||||
public struct Release: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
@@ -36,6 +36,19 @@ extension Amiibo {
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model.
|
||||
package init(
|
||||
america: Date? = nil,
|
||||
australia: Date? = nil,
|
||||
europe: Date? = nil,
|
||||
japan: Date? = nil
|
||||
) {
|
||||
self.america = america
|
||||
self.australia = australia
|
||||
self.europe = europe
|
||||
self.japan = japan
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.AmiiboRelease) {
|
||||
|
||||
@@ -14,18 +14,24 @@
|
||||
|
||||
extension Amiibo {
|
||||
/// A model that represents the usage of an amiibo within a certain game.
|
||||
public struct Usage: Sendable, Hashable {
|
||||
public struct Usage: Sendable, Hashable, Codable {
|
||||
|
||||
// MARK: Properties
|
||||
|
||||
/// A description of how the amiibo is used within the game.
|
||||
public let explanation: String
|
||||
|
||||
/// A flag that indicates whether the amiibo can save game data.
|
||||
/// Whether the amiibo can save game data.
|
||||
public let isWriteable: Bool
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model.
|
||||
package init(explanation: String, isWriteable: Bool) {
|
||||
self.explanation = explanation
|
||||
self.isWriteable = isWriteable
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: Components.Schemas.AmiiboUsage) {
|
||||
|
||||
@@ -24,12 +24,25 @@ public struct AmiiboSeries: KeyNameModel {
|
||||
public let name: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
|
||||
/// Initializes this model.
|
||||
package init(key: String, name: String) {
|
||||
self.key = key
|
||||
self.name = name
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: some KeyNamePayload) {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this amiibo series.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,12 +24,25 @@ public struct AmiiboType: KeyNameModel {
|
||||
public let name: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
|
||||
/// Initializes this model.
|
||||
package init(key: String, name: String) {
|
||||
self.key = key
|
||||
self.name = name
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: some KeyNamePayload) {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this amiibo type.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
@@ -25,11 +25,24 @@ public struct GameCharacter: KeyNameModel {
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
/// Initializes this model.
|
||||
package init(key: String, name: String) {
|
||||
self.key = key
|
||||
self.name = name
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: some KeyNamePayload) {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this game character.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
@@ -24,12 +24,25 @@ public struct GameSeries: KeyNameModel {
|
||||
public let name: String
|
||||
|
||||
// MARK: Initializers
|
||||
|
||||
|
||||
/// Initializes this model.
|
||||
package init(key: String, name: String) {
|
||||
self.key = key
|
||||
self.name = name
|
||||
}
|
||||
|
||||
/// Initializes this model from a given payload.
|
||||
/// - Parameter payload: A payload that contains the values for the model.
|
||||
init(_ payload: some KeyNamePayload) {
|
||||
self.key = payload.key
|
||||
self.name = payload.name
|
||||
}
|
||||
|
||||
|
||||
// MARK: Computed
|
||||
|
||||
/// The ``key`` of this game series.
|
||||
public var id: String {
|
||||
key
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user