@@ -15,204 +15,3 @@ import Foundation
15
15
import HTTPTypes
16
16
17
17
// MARK: - Functionality to be removed in the future
18
-
19
- extension ClientError {
20
- /// Creates a new error.
21
- /// - Parameters:
22
- /// - operationID: The OpenAPI operation identifier.
23
- /// - operationInput: The operation-specific Input value.
24
- /// - request: The HTTP request created during the operation.
25
- /// - requestBody: The HTTP request body created during the operation.
26
- /// - baseURL: The base URL for HTTP requests.
27
- /// - response: The HTTP response received during the operation.
28
- /// - responseBody: The HTTP response body received during the operation.
29
- /// - underlyingError: The underlying error that caused the operation
30
- /// to fail.
31
- @available (
32
- * ,
33
- deprecated,
34
- renamed:
35
- " ClientError.init(operationID:operationInput:request:requestBody:baseURL:response:responseBody:causeDescription:underlyingError:) " ,
36
- message: " Use the initializer with a causeDescription parameter. "
37
- ) public init (
38
- operationID: String ,
39
- operationInput: any Sendable ,
40
- request: HTTPRequest ? = nil ,
41
- requestBody: HTTPBody ? = nil ,
42
- baseURL: URL ? = nil ,
43
- response: HTTPResponse ? = nil ,
44
- responseBody: HTTPBody ? = nil ,
45
- underlyingError: any Error
46
- ) {
47
- self . init (
48
- operationID: operationID,
49
- operationInput: operationInput,
50
- request: request,
51
- requestBody: requestBody,
52
- baseURL: baseURL,
53
- response: response,
54
- responseBody: responseBody,
55
- causeDescription: " Legacy error without a causeDescription. " ,
56
- underlyingError: underlyingError
57
- )
58
- }
59
- }
60
-
61
- extension ServerError {
62
- /// Creates a new error.
63
- /// - Parameters:
64
- /// - operationID: The OpenAPI operation identifier.
65
- /// - request: The HTTP request provided to the server.
66
- /// - requestBody: The HTTP request body provided to the server.
67
- /// - requestMetadata: The request metadata extracted by the server.
68
- /// - operationInput: An operation-specific Input value.
69
- /// - operationOutput: An operation-specific Output value.
70
- /// - underlyingError: The underlying error that caused the operation
71
- /// to fail.
72
- @available (
73
- * ,
74
- deprecated,
75
- renamed:
76
- " ServerError.init(operationID:request:requestBody:requestMetadata:operationInput:operationOutput:causeDescription:underlyingError:) " ,
77
- message: " Use the initializer with a causeDescription parameter. "
78
- ) public init (
79
- operationID: String ,
80
- request: HTTPRequest ,
81
- requestBody: HTTPBody ? ,
82
- requestMetadata: ServerRequestMetadata ,
83
- operationInput: ( any Sendable ) ? = nil ,
84
- operationOutput: ( any Sendable ) ? = nil ,
85
- underlyingError: any Error
86
- ) {
87
- self . init (
88
- operationID: operationID,
89
- request: request,
90
- requestBody: requestBody,
91
- requestMetadata: requestMetadata,
92
- operationInput: operationInput,
93
- operationOutput: operationOutput,
94
- causeDescription: " Legacy error without a causeDescription. " ,
95
- underlyingError: underlyingError
96
- )
97
- }
98
- }
99
-
100
- extension Converter {
101
- /// Returns an error to be thrown when an unexpected content type is
102
- /// received.
103
- /// - Parameter contentType: The content type that was received.
104
- /// - Returns: An error representing an unexpected content type.
105
- @available ( * , deprecated) public func makeUnexpectedContentTypeError( contentType: OpenAPIMIMEType ? ) -> any Error {
106
- RuntimeError . unexpectedContentTypeHeader ( contentType? . description ?? " " )
107
- }
108
-
109
- /// Checks whether a concrete content type matches an expected content type.
110
- ///
111
- /// The concrete content type can contain parameters, such as `charset`, but
112
- /// they are ignored in the equality comparison.
113
- ///
114
- /// The expected content type can contain wildcards, such as */* and text/*.
115
- /// - Parameters:
116
- /// - received: The concrete content type to validate against the other.
117
- /// - expectedRaw: The expected content type, can contain wildcards.
118
- /// - Throws: A `RuntimeError` when `expectedRaw` is not a valid content type.
119
- /// - Returns: A Boolean value representing whether the concrete content
120
- /// type matches the expected one.
121
- @available ( * , deprecated) public func isMatchingContentType( received: OpenAPIMIMEType ? , expectedRaw: String ) throws
122
- -> Bool
123
- {
124
- guard let received else { return false }
125
- guard case let . concrete( type: receivedType, subtype: receivedSubtype) = received. kind else { return false }
126
- guard let expectedContentType = OpenAPIMIMEType ( expectedRaw) else {
127
- throw RuntimeError . invalidExpectedContentType ( expectedRaw)
128
- }
129
- switch expectedContentType. kind {
130
- case . any: return true
131
- case . anySubtype( let expectedType) : return receivedType. lowercased ( ) == expectedType. lowercased ( )
132
- case . concrete( let expectedType, let expectedSubtype) :
133
- return receivedType. lowercased ( ) == expectedType. lowercased ( )
134
- && receivedSubtype. lowercased ( ) == expectedSubtype. lowercased ( )
135
- }
136
- }
137
- }
138
-
139
- extension DecodingError {
140
- /// Returns a decoding error used by the oneOf decoder when not a single
141
- /// child schema decodes the received payload.
142
- /// - Parameters:
143
- /// - type: The type representing the oneOf schema in which the decoding
144
- /// occurred.
145
- /// - codingPath: The coding path to the decoder that attempted to decode
146
- /// the type.
147
- /// - Returns: A decoding error.
148
- @_spi ( Generated) @available ( * , deprecated) public static func failedToDecodeOneOfSchema(
149
- type: Any . Type ,
150
- codingPath: [ any CodingKey ]
151
- ) -> Self {
152
- DecodingError . valueNotFound (
153
- type,
154
- DecodingError . Context. init (
155
- codingPath: codingPath,
156
- debugDescription: " The oneOf structure did not decode into any child schema. "
157
- )
158
- )
159
- }
160
-
161
- /// Returns a decoding error used by the anyOf decoder when not a single
162
- /// child schema decodes the received payload.
163
- /// - Parameters:
164
- /// - type: The type representing the anyOf schema in which the decoding
165
- /// occurred.
166
- /// - codingPath: The coding path to the decoder that attempted to decode
167
- /// the type.
168
- /// - Returns: A decoding error.
169
- @available ( * , deprecated) static func failedToDecodeAnySchema( type: Any . Type , codingPath: [ any CodingKey ] ) -> Self {
170
- DecodingError . valueNotFound (
171
- type,
172
- DecodingError . Context. init (
173
- codingPath: codingPath,
174
- debugDescription: " The anyOf structure did not decode into any child schema. "
175
- )
176
- )
177
- }
178
-
179
- /// Verifies that the anyOf decoder successfully decoded at least one
180
- /// child schema, and throws an error otherwise.
181
- /// - Parameters:
182
- /// - values: An array of optional values to check.
183
- /// - type: The type representing the anyOf schema in which the decoding
184
- /// occurred.
185
- /// - codingPath: The coding path to the decoder that attempted to decode
186
- /// the type.
187
- /// - Throws: An error of type `DecodingError.failedToDecodeAnySchema` if none of the child schemas were successfully decoded.
188
- @_spi ( Generated) @available ( * , deprecated) public static func verifyAtLeastOneSchemaIsNotNil(
189
- _ values: [ Any ? ] ,
190
- type: Any . Type ,
191
- codingPath: [ any CodingKey ]
192
- ) throws {
193
- guard values. contains ( where: { $0 != nil } ) else {
194
- throw DecodingError . failedToDecodeAnySchema ( type: type, codingPath: codingPath)
195
- }
196
- }
197
- }
198
-
199
- extension Configuration {
200
- /// Creates a new configuration with the specified values.
201
- ///
202
- /// - Parameter dateTranscoder: The transcoder to use when converting between date
203
- /// and string values.
204
- @available ( * , deprecated, renamed: " init(dateTranscoder:multipartBoundaryGenerator:) " ) @_disfavoredOverload
205
- public init ( dateTranscoder: any DateTranscoder ) {
206
- self . init ( dateTranscoder: dateTranscoder, multipartBoundaryGenerator: . random)
207
- }
208
- }
209
-
210
- extension HTTPBody {
211
- /// Describes how many times the provided sequence can be iterated.
212
- @available (
213
- * ,
214
- deprecated,
215
- renamed: " IterationBehavior " ,
216
- message: " Use the top level IterationBehavior directly instead of HTTPBody.IterationBehavior. "
217
- ) public typealias IterationBehavior = OpenAPIRuntime . IterationBehavior
218
- }
0 commit comments