Skip to content

Commit d3f1967

Browse files
Commit via running ake Sources/users
1 parent 20507ba commit d3f1967

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

Sources/users/Client.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,6 +1907,28 @@ public struct Client: APIProtocol {
19071907
preconditionFailure("bestContentType chose an invalid content type.")
19081908
}
19091909
return .unauthorized(.init(body: body))
1910+
case 422:
1911+
let contentType = converter.extractContentTypeIfPresent(in: response.headerFields)
1912+
let body: Components.Responses.validation_failed.Body
1913+
let chosenContentType = try converter.bestContentType(
1914+
received: contentType,
1915+
options: [
1916+
"application/json"
1917+
]
1918+
)
1919+
switch chosenContentType {
1920+
case "application/json":
1921+
body = try await converter.getResponseBodyAsJSON(
1922+
Components.Schemas.validation_hyphen_error.self,
1923+
from: responseBody,
1924+
transforming: { value in
1925+
.json(value)
1926+
}
1927+
)
1928+
default:
1929+
preconditionFailure("bestContentType chose an invalid content type.")
1930+
}
1931+
return .unprocessableContent(.init(body: body))
19101932
default:
19111933
return .undocumented(
19121934
statusCode: response.status.code,

Sources/users/Types.swift

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6475,6 +6475,29 @@ public enum Operations {
64756475
}
64766476
}
64776477
}
6478+
/// Validation failed, or the endpoint has been spammed.
6479+
///
6480+
/// - Remark: Generated from `#/paths//user/following/{username}/put(users/follow)/responses/422`.
6481+
///
6482+
/// HTTP response code: `422 unprocessableContent`.
6483+
case unprocessableContent(Components.Responses.validation_failed)
6484+
/// The associated value of the enum case if `self` is `.unprocessableContent`.
6485+
///
6486+
/// - Throws: An error if `self` is not `.unprocessableContent`.
6487+
/// - SeeAlso: `.unprocessableContent`.
6488+
public var unprocessableContent: Components.Responses.validation_failed {
6489+
get throws {
6490+
switch self {
6491+
case let .unprocessableContent(response):
6492+
return response
6493+
default:
6494+
try throwUnexpectedResponseStatus(
6495+
expectedStatus: "unprocessableContent",
6496+
response: self
6497+
)
6498+
}
6499+
}
6500+
}
64786501
/// Undocumented response.
64796502
///
64806503
/// A response with a code that is not documented in the OpenAPI document.

0 commit comments

Comments
 (0)