Use typed Swift JSON-RPC envelopes#299
Merged
Merged
Conversation
This was referenced Jun 18, 2026
Merged
Contributor
Author
This stack of pull requests is managed by Graphite. Learn more about stacking. |
11 tasks
Comment on lines
+36
to
+37
| case double(Double) | ||
|
|
Contributor
There was a problem hiding this comment.
JSONRPC id seems like it should be string / number / null - and not contain fractions, should double be replaced with a case null
Contributor
There was a problem hiding this comment.
Possible new shape
enum JSONRPCID: Codable, Equatable, ExpressibleByStringLiteral, ExpressibleByIntegerLiteral {
case string(String)
case int(Int64)
case null
init(stringLiteral value: String) {
self = .string(value)
}
init(integerLiteral value: Int64) {
self = .int(value)
}
var stringValue: String? {
guard case let .string(value) = self else {
return nil
}
return value
}
init(from decoder: Decoder) throws {
let container = try decoder.singleValueContainer()
if container.decodeNil() {
self = .null
} else if let value = try? container.decode(String.self) {
self = .string(value)
} else if let value = try? container.decode(Int64.self) {
self = .int(value)
} else {
throw DecodingError.typeMismatch(
JSONRPCID.self,
DecodingError.Context(
codingPath: decoder.codingPath,
debugDescription: "JSON-RPC id must be a string, integer, or null"
)
)
}
}
func encode(to encoder: Encoder) throws {
var container = encoder.singleValueContainer()
switch self {
case let .string value:
try container.encode(value)
case let .int value:
try container.encode(value)
case .null:
try container.encodeNil()
}
}
}b042647 to
940fa40
Compare
kieran-osgood-shopify
approved these changes
Jun 18, 2026
Contributor
Author
940fa40 to
b99d3d3
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

What changes are you making?
Replaces ad-hoc
JSONSerializationusage throughout the Swift protocol layer with typedCodablemodels, and introduces a properJSONRPCIDenum to correctly handle string, integer, and floating-point JSON-RPC request IDs.Previously, the JSON-RPC
idfield was decoded asString?, meaning numeric IDs (e.g."id": 7) were silently dropped. This caused issues where responses to requests with numeric IDs could not be correctly correlated. The newJSONRPCIDenum handlesString,Int64, andNullvariants, and is used consistently acrossUCPMessage,DelegationEntry,JSONRPCResponse,JSONRPCErrorResponse, and the encode/decode helpers.The monolithic
JSONRPCRequest/JSONRPCParamstypes have been replaced with:JSONRPCEnvelope— a lightweight type for readingmethodandidbefore committing to a full decodeJSONRPCRequest<Params>— a generic typed request for each specific params shape (JSONRPCReadyParams,JSONRPCCheckoutParams,JSONRPCErrorParams,JSONRPCWindowOpenParams)The
requestParamsData(for:from:)function now dispatches on method name to decode and re-encode only the known fields for a given request type, which means unknown params are stripped before being forwarded to handlers.How to test
swift testfromprotocol/languages/swift/decodesReadyRequestWithNumericID— confirms.readyis produced whenidis an integerencodesReadyResponseWithNumericID— confirms the encoded response preserves a numericidmethodNotFoundResponsePreservesNumericRequestID— confirms error responses echo back numeric IDswindowOpenRequestDropsUnknownParamsBeforeDispatch— confirms unknown params are not forwardedBefore you merge
Important
platforms/swift/README.mdand/orplatforms/android/README.md)Releasing a new Swift version?
ShopifyCheckoutKit.podspecplatforms/swift/Sources/ShopifyCheckoutKit/ShopifyCheckoutKit.swiftplatforms/swift/CHANGELOG.mdplatforms/swift/README.md(major version only)Releasing a new Android version?
versionNameinplatforms/android/lib/build.gradleplatforms/android/CHANGELOG.mdplatforms/android/README.mdTip
See the Contributing documentation for the full release process per platform.