Skip to content

Commit 1cbadcc

Browse files
Commit via running: make Sources/campaigns
1 parent c265033 commit 1cbadcc

File tree

1 file changed

+38
-159
lines changed

1 file changed

+38
-159
lines changed

Sources/campaigns/Types.swift

Lines changed: 38 additions & 159 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,169 +1295,48 @@ public enum Operations {
12951295
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody`.
12961296
@frozen public enum Body: Sendable, Hashable {
12971297
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json`.
1298-
public struct JsonPayload: Codable, Hashable, Sendable {
1299-
/// The name of the campaign
1300-
///
1301-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/name`.
1302-
public var name: Swift.String
1303-
/// A description for the campaign
1304-
///
1305-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/description`.
1306-
public var description: Swift.String
1307-
/// The logins of the users to set as the campaign managers. At this time, only a single manager can be supplied.
1308-
///
1309-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/managers`.
1310-
public var managers: [Swift.String]?
1311-
/// The slugs of the teams to set as the campaign managers.
1312-
///
1313-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/team_managers`.
1314-
public var teamManagers: [Swift.String]?
1315-
/// The end date and time of the campaign. The date must be in the future.
1316-
///
1317-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/ends_at`.
1318-
public var endsAt: Foundation.Date
1319-
/// The contact link of the campaign. Must be a URI.
1320-
///
1321-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/contact_link`.
1322-
public var contactLink: Swift.String?
1323-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/CodeScanningAlertsPayload`.
1324-
public struct CodeScanningAlertsPayloadPayload: Codable, Hashable, Sendable {
1325-
/// The repository id
1326-
///
1327-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/CodeScanningAlertsPayload/repository_id`.
1328-
public var repositoryId: Swift.Int
1329-
/// The alert numbers
1330-
///
1331-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/CodeScanningAlertsPayload/alert_numbers`.
1332-
public var alertNumbers: [Swift.Int]
1333-
/// Creates a new `CodeScanningAlertsPayloadPayload`.
1334-
///
1335-
/// - Parameters:
1336-
/// - repositoryId: The repository id
1337-
/// - alertNumbers: The alert numbers
1338-
public init(
1339-
repositoryId: Swift.Int,
1340-
alertNumbers: [Swift.Int]
1341-
) {
1342-
self.repositoryId = repositoryId
1343-
self.alertNumbers = alertNumbers
1344-
}
1345-
public enum CodingKeys: String, CodingKey {
1346-
case repositoryId = "repository_id"
1347-
case alertNumbers = "alert_numbers"
1348-
}
1349-
public init(from decoder: any Decoder) throws {
1350-
let container = try decoder.container(keyedBy: CodingKeys.self)
1351-
self.repositoryId = try container.decode(
1352-
Swift.Int.self,
1353-
forKey: .repositoryId
1354-
)
1355-
self.alertNumbers = try container.decode(
1356-
[Swift.Int].self,
1357-
forKey: .alertNumbers
1358-
)
1359-
try decoder.ensureNoAdditionalProperties(knownKeys: [
1360-
"repository_id",
1361-
"alert_numbers"
1362-
])
1363-
}
1364-
}
1365-
/// The code scanning alerts to include in this campaign
1366-
///
1367-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/code_scanning_alerts`.
1368-
public typealias CodeScanningAlertsPayload = [Operations.CampaignsCreateCampaign.Input.Body.JsonPayload.CodeScanningAlertsPayloadPayload]
1369-
/// The code scanning alerts to include in this campaign
1370-
///
1371-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/code_scanning_alerts`.
1372-
public var codeScanningAlerts: Operations.CampaignsCreateCampaign.Input.Body.JsonPayload.CodeScanningAlertsPayload
1373-
/// If true, will automatically generate issues for the campaign. The default is false.
1374-
///
1375-
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/generate_issues`.
1376-
public var generateIssues: Swift.Bool?
1377-
/// Creates a new `JsonPayload`.
1378-
///
1379-
/// - Parameters:
1380-
/// - name: The name of the campaign
1381-
/// - description: A description for the campaign
1382-
/// - managers: The logins of the users to set as the campaign managers. At this time, only a single manager can be supplied.
1383-
/// - teamManagers: The slugs of the teams to set as the campaign managers.
1384-
/// - endsAt: The end date and time of the campaign. The date must be in the future.
1385-
/// - contactLink: The contact link of the campaign. Must be a URI.
1386-
/// - codeScanningAlerts: The code scanning alerts to include in this campaign
1387-
/// - generateIssues: If true, will automatically generate issues for the campaign. The default is false.
1388-
public init(
1389-
name: Swift.String,
1390-
description: Swift.String,
1391-
managers: [Swift.String]? = nil,
1392-
teamManagers: [Swift.String]? = nil,
1393-
endsAt: Foundation.Date,
1394-
contactLink: Swift.String? = nil,
1395-
codeScanningAlerts: Operations.CampaignsCreateCampaign.Input.Body.JsonPayload.CodeScanningAlertsPayload,
1396-
generateIssues: Swift.Bool? = nil
1397-
) {
1398-
self.name = name
1399-
self.description = description
1400-
self.managers = managers
1401-
self.teamManagers = teamManagers
1402-
self.endsAt = endsAt
1403-
self.contactLink = contactLink
1404-
self.codeScanningAlerts = codeScanningAlerts
1405-
self.generateIssues = generateIssues
1298+
@frozen public enum JsonPayload: Codable, Hashable, Sendable {
1299+
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/case1`.
1300+
public struct Case1Payload: Codable, Hashable, Sendable {
1301+
/// Creates a new `Case1Payload`.
1302+
public init() {}
14061303
}
1407-
public enum CodingKeys: String, CodingKey {
1408-
case name
1409-
case description
1410-
case managers
1411-
case teamManagers = "team_managers"
1412-
case endsAt = "ends_at"
1413-
case contactLink = "contact_link"
1414-
case codeScanningAlerts = "code_scanning_alerts"
1415-
case generateIssues = "generate_issues"
1304+
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/case1`.
1305+
case case1(Operations.CampaignsCreateCampaign.Input.Body.JsonPayload.Case1Payload)
1306+
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/case2`.
1307+
public struct Case2Payload: Codable, Hashable, Sendable {
1308+
/// Creates a new `Case2Payload`.
1309+
public init() {}
14161310
}
1311+
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/json/case2`.
1312+
case case2(Operations.CampaignsCreateCampaign.Input.Body.JsonPayload.Case2Payload)
14171313
public init(from decoder: any Decoder) throws {
1418-
let container = try decoder.container(keyedBy: CodingKeys.self)
1419-
self.name = try container.decode(
1420-
Swift.String.self,
1421-
forKey: .name
1422-
)
1423-
self.description = try container.decode(
1424-
Swift.String.self,
1425-
forKey: .description
1426-
)
1427-
self.managers = try container.decodeIfPresent(
1428-
[Swift.String].self,
1429-
forKey: .managers
1430-
)
1431-
self.teamManagers = try container.decodeIfPresent(
1432-
[Swift.String].self,
1433-
forKey: .teamManagers
1434-
)
1435-
self.endsAt = try container.decode(
1436-
Foundation.Date.self,
1437-
forKey: .endsAt
1438-
)
1439-
self.contactLink = try container.decodeIfPresent(
1440-
Swift.String.self,
1441-
forKey: .contactLink
1442-
)
1443-
self.codeScanningAlerts = try container.decode(
1444-
Operations.CampaignsCreateCampaign.Input.Body.JsonPayload.CodeScanningAlertsPayload.self,
1445-
forKey: .codeScanningAlerts
1446-
)
1447-
self.generateIssues = try container.decodeIfPresent(
1448-
Swift.Bool.self,
1449-
forKey: .generateIssues
1314+
var errors: [any Error] = []
1315+
do {
1316+
self = .case1(try .init(from: decoder))
1317+
return
1318+
} catch {
1319+
errors.append(error)
1320+
}
1321+
do {
1322+
self = .case2(try .init(from: decoder))
1323+
return
1324+
} catch {
1325+
errors.append(error)
1326+
}
1327+
throw Swift.DecodingError.failedToDecodeOneOfSchema(
1328+
type: Self.self,
1329+
codingPath: decoder.codingPath,
1330+
errors: errors
14501331
)
1451-
try decoder.ensureNoAdditionalProperties(knownKeys: [
1452-
"name",
1453-
"description",
1454-
"managers",
1455-
"team_managers",
1456-
"ends_at",
1457-
"contact_link",
1458-
"code_scanning_alerts",
1459-
"generate_issues"
1460-
])
1332+
}
1333+
public func encode(to encoder: any Encoder) throws {
1334+
switch self {
1335+
case let .case1(value):
1336+
try value.encode(to: encoder)
1337+
case let .case2(value):
1338+
try value.encode(to: encoder)
1339+
}
14611340
}
14621341
}
14631342
/// - Remark: Generated from `#/paths/orgs/{org}/campaigns/POST/requestBody/content/application\/json`.

0 commit comments

Comments
 (0)