fix(mac): add Sendable conformance to generated Swift protocol structs (#195)
* fix(mac): add Sendable conformance to generated Swift protocol structs * fix(mac): make generated protocol types Sendable * chore(mac): drop redundant Sendable extensions * docs(changelog): thank @andranik-sahakyan for Sendable fix * chore(swiftformat): exclude generated protocol models --------- Co-authored-by: Peter Steinberger <steipete@gmail.com>
This commit is contained in:
committed by
GitHub
parent
1657c5e3d2
commit
d9a9f6db7d
@@ -27,7 +27,7 @@ const outPath = path.join(
|
||||
"GatewayModels.swift",
|
||||
);
|
||||
|
||||
const header = `// Generated by scripts/protocol-gen-swift.ts — do not edit by hand\nimport Foundation\n\npublic let GATEWAY_PROTOCOL_VERSION = ${PROTOCOL_VERSION}\n\npublic enum ErrorCode: String, Codable {\n${Object.values(ErrorCodes)
|
||||
const header = `// Generated by scripts/protocol-gen-swift.ts — do not edit by hand\nimport Foundation\n\npublic let GATEWAY_PROTOCOL_VERSION = ${PROTOCOL_VERSION}\n\npublic enum ErrorCode: String, Codable, Sendable {\n${Object.values(ErrorCodes)
|
||||
.map((c) => ` case ${camelCase(c)} = "${c}"`)
|
||||
.join("\n")}\n}\n`;
|
||||
|
||||
@@ -106,7 +106,7 @@ function emitStruct(name: string, schema: JsonSchema): string {
|
||||
const props = schema.properties ?? {};
|
||||
const required = new Set(schema.required ?? []);
|
||||
const lines: string[] = [];
|
||||
lines.push(`public struct ${name}: Codable {`);
|
||||
lines.push(`public struct ${name}: Codable, Sendable {`);
|
||||
if (Object.keys(props).length === 0) {
|
||||
lines.push("}\n");
|
||||
return lines.join("\n");
|
||||
@@ -188,7 +188,7 @@ function emitGatewayFrame(): string {
|
||||
`;
|
||||
|
||||
return [
|
||||
"public enum GatewayFrame: Codable {",
|
||||
"public enum GatewayFrame: Codable, Sendable {",
|
||||
...caseLines,
|
||||
" case unknown(type: String, raw: [String: AnyCodable])",
|
||||
initLines,
|
||||
|
||||
Reference in New Issue
Block a user