Skip to content

Commit 336b77c

Browse files
authored
Remove deprecated code (#81)
### Motivation Preparing for 1.0.0-alpha.1, remove deprecated code. ### Modifications Removed deprecated code. ### Result No more deprecated code. ### Test Plan All tests pass, no warnings.
1 parent e5816cb commit 336b77c

File tree

3 files changed

+0
-227
lines changed

3 files changed

+0
-227
lines changed

Sources/OpenAPIRuntime/Base/Base64EncodedData.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,6 @@ public struct Base64EncodedData: Sendable, Hashable {
5454
/// A container of the raw bytes.
5555
public var data: ArraySlice<UInt8>
5656

57-
/// Initializes an instance of ``Base64EncodedData`` wrapping the provided slice of bytes.
58-
/// - Parameter data: The underlying bytes to wrap.
59-
@available(*, deprecated, renamed: "init(_:)")
60-
61-
public init(data: ArraySlice<UInt8>) { self.data = data }
62-
6357
/// Initializes an instance of ``Base64EncodedData`` wrapping the provided slice of bytes.
6458
/// - Parameter data: The underlying bytes to wrap.
6559
public init(_ data: ArraySlice<UInt8>) { self.data = data }

Sources/OpenAPIRuntime/Deprecated/Deprecated.swift

Lines changed: 0 additions & 201 deletions
Original file line numberDiff line numberDiff line change
@@ -15,204 +15,3 @@ import Foundation
1515
import HTTPTypes
1616

1717
// 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-
}

Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Common.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,6 @@ final class Test_CommonConverterExtensions: Test_Runtime {
2121

2222
// MARK: Miscs
2323

24-
@available(*, deprecated) func testContentTypeMatching() throws {
25-
let cases: [(received: String, expected: String, isMatch: Bool)] = [
26-
("application/json", "application/json", true), ("APPLICATION/JSON", "application/json", true),
27-
("application/json", "application/*", true), ("application/json", "*/*", true),
28-
("application/json", "text/*", false), ("application/json", "application/xml", false),
29-
("application/json", "text/plain", false),
30-
31-
("text/plain; charset=UTF-8", "text/plain", true), ("TEXT/PLAIN; CHARSET=UTF-8", "text/plain", true),
32-
("text/plain; charset=UTF-8", "text/*", true), ("text/plain; charset=UTF-8", "*/*", true),
33-
("text/plain; charset=UTF-8", "application/*", false), ("text/plain; charset=UTF-8", "text/html", false),
34-
]
35-
for testCase in cases {
36-
XCTAssertEqual(
37-
try converter.isMatchingContentType(received: .init(testCase.received), expectedRaw: testCase.expected),
38-
testCase.isMatch,
39-
"Wrong result for (\(testCase.received), \(testCase.expected), \(testCase.isMatch))"
40-
)
41-
}
42-
}
43-
4424
func testBestContentType() throws {
4525
func testCase(
4626
received: String?,

0 commit comments

Comments
 (0)