Skip to content

Commit 63ef503

Browse files
Commit via running ake Sources/pulls
1 parent 728c101 commit 63ef503

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed

Sources/pulls/Client.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -798,6 +798,28 @@ public struct Client: APIProtocol {
798798
preconditionFailure("bestContentType chose an invalid content type.")
799799
}
800800
return .notFound(.init(body: body))
801+
case 406:
802+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
803+
let body: Components.Responses.unacceptable.Body
804+
let chosenContentType = try converter.bestContentType(
805+
received: contentType,
806+
options: [
807+
"application/json"
808+
]
809+
)
810+
switch chosenContentType {
811+
case "application/json":
812+
body = try await converter.getResponseBodyAsJSON(
813+
Components.Schemas.basic_hyphen_error.self,
814+
from: responseBody,
815+
transforming: { value in
816+
.json(value)
817+
}
818+
)
819+
default:
820+
preconditionFailure("bestContentType chose an invalid content type.")
821+
}
822+
return .notAcceptable(.init(body: body))
801823
case 500:
802824
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
803825
let body: Components.Responses.internal_error.Body

Sources/pulls/Types.swift

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6923,6 +6923,34 @@ public enum Components {
69236923
self.body = body
69246924
}
69256925
}
6926+
public struct unacceptable: Sendable, Hashable {
6927+
/// - Remark: Generated from `#/components/responses/unacceptable/content`.
6928+
@frozen public enum Body: Sendable, Hashable {
6929+
/// - Remark: Generated from `#/components/responses/unacceptable/content/application\/json`.
6930+
case json(Components.Schemas.basic_hyphen_error)
6931+
/// The associated value of the enum case if `self` is `.json`.
6932+
///
6933+
/// - Throws: An error if `self` is not `.json`.
6934+
/// - SeeAlso: `.json`.
6935+
public var json: Components.Schemas.basic_hyphen_error {
6936+
get throws {
6937+
switch self {
6938+
case let .json(body):
6939+
return body
6940+
}
6941+
}
6942+
}
6943+
}
6944+
/// Received HTTP response body
6945+
public var body: Components.Responses.unacceptable.Body
6946+
/// Creates a new `unacceptable`.
6947+
///
6948+
/// - Parameters:
6949+
/// - body: Received HTTP response body
6950+
public init(body: Components.Responses.unacceptable.Body) {
6951+
self.body = body
6952+
}
6953+
}
69266954
}
69276955
/// Types generated from the `#/components/headers` section of the OpenAPI document.
69286956
public enum Headers {
@@ -8452,6 +8480,29 @@ public enum Operations {
84528480
}
84538481
}
84548482
}
8483+
/// Unacceptable
8484+
///
8485+
/// - Remark: Generated from `#/paths//repos/{owner}/{repo}/pulls/{pull_number}/get(pulls/get)/responses/406`.
8486+
///
8487+
/// HTTP response code: `406 notAcceptable`.
8488+
case notAcceptable(Components.Responses.unacceptable)
8489+
/// The associated value of the enum case if `self` is `.notAcceptable`.
8490+
///
8491+
/// - Throws: An error if `self` is not `.notAcceptable`.
8492+
/// - SeeAlso: `.notAcceptable`.
8493+
public var notAcceptable: Components.Responses.unacceptable {
8494+
get throws {
8495+
switch self {
8496+
case let .notAcceptable(response):
8497+
return response
8498+
default:
8499+
try throwUnexpectedResponseStatus(
8500+
expectedStatus: "notAcceptable",
8501+
response: self
8502+
)
8503+
}
8504+
}
8505+
}
84558506
/// Internal Error
84568507
///
84578508
/// - Remark: Generated from `#/paths//repos/{owner}/{repo}/pulls/{pull_number}/get(pulls/get)/responses/500`.

0 commit comments

Comments
 (0)