Skip to content

Commit 6742faf

Browse files
Commit via running: make Sources/code-scanning
1 parent 555dd77 commit 6742faf

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

Sources/code-scanning/Client.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3100,6 +3100,28 @@ public struct Client: APIProtocol {
31003100
preconditionFailure("bestContentType chose an invalid content type.")
31013101
}
31023102
return .conflict(.init(body: body))
3103+
case 422:
3104+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
3105+
let body: Components.Responses.CodeScanningInvalidState.Body
3106+
let chosenContentType = try converter.bestContentType(
3107+
received: contentType,
3108+
options: [
3109+
"application/json"
3110+
]
3111+
)
3112+
switch chosenContentType {
3113+
case "application/json":
3114+
body = try await converter.getResponseBodyAsJSON(
3115+
Components.Schemas.BasicError.self,
3116+
from: responseBody,
3117+
transforming: { value in
3118+
.json(value)
3119+
}
3120+
)
3121+
default:
3122+
preconditionFailure("bestContentType chose an invalid content type.")
3123+
}
3124+
return .unprocessableContent(.init(body: body))
31033125
case 503:
31043126
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
31053127
let body: Components.Responses.ServiceUnavailable.Body

Sources/code-scanning/Types.swift

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3979,6 +3979,34 @@ public enum Components {
39793979
self.body = body
39803980
}
39813981
}
3982+
public struct CodeScanningInvalidState: Sendable, Hashable {
3983+
/// - Remark: Generated from `#/components/responses/code_scanning_invalid_state/content`.
3984+
@frozen public enum Body: Sendable, Hashable {
3985+
/// - Remark: Generated from `#/components/responses/code_scanning_invalid_state/content/application\/json`.
3986+
case json(Components.Schemas.BasicError)
3987+
/// The associated value of the enum case if `self` is `.json`.
3988+
///
3989+
/// - Throws: An error if `self` is not `.json`.
3990+
/// - SeeAlso: `.json`.
3991+
public var json: Components.Schemas.BasicError {
3992+
get throws {
3993+
switch self {
3994+
case let .json(body):
3995+
return body
3996+
}
3997+
}
3998+
}
3999+
}
4000+
/// Received HTTP response body
4001+
public var body: Components.Responses.CodeScanningInvalidState.Body
4002+
/// Creates a new `CodeScanningInvalidState`.
4003+
///
4004+
/// - Parameters:
4005+
/// - body: Received HTTP response body
4006+
public init(body: Components.Responses.CodeScanningInvalidState.Body) {
4007+
self.body = body
4008+
}
4009+
}
39824010
}
39834011
/// Types generated from the `#/components/headers` section of the OpenAPI document.
39844012
public enum Headers {
@@ -9066,6 +9094,29 @@ public enum Operations {
90669094
}
90679095
}
90689096
}
9097+
/// Response if the configuration change cannot be made because the repository is not in the required state
9098+
///
9099+
/// - Remark: Generated from `#/paths//repos/{owner}/{repo}/code-scanning/default-setup/patch(code-scanning/update-default-setup)/responses/422`.
9100+
///
9101+
/// HTTP response code: `422 unprocessableContent`.
9102+
case unprocessableContent(Components.Responses.CodeScanningInvalidState)
9103+
/// The associated value of the enum case if `self` is `.unprocessableContent`.
9104+
///
9105+
/// - Throws: An error if `self` is not `.unprocessableContent`.
9106+
/// - SeeAlso: `.unprocessableContent`.
9107+
public var unprocessableContent: Components.Responses.CodeScanningInvalidState {
9108+
get throws {
9109+
switch self {
9110+
case let .unprocessableContent(response):
9111+
return response
9112+
default:
9113+
try throwUnexpectedResponseStatus(
9114+
expectedStatus: "unprocessableContent",
9115+
response: self
9116+
)
9117+
}
9118+
}
9119+
}
90699120
/// Service unavailable
90709121
///
90719122
/// - Remark: Generated from `#/paths//repos/{owner}/{repo}/code-scanning/default-setup/patch(code-scanning/update-default-setup)/responses/503`.

0 commit comments

Comments
 (0)