diff --git a/Sources/OpenAPIRuntime/Base/Base64EncodedData.swift b/Sources/OpenAPIRuntime/Base/Base64EncodedData.swift index 408e9f90..7af50f72 100644 --- a/Sources/OpenAPIRuntime/Base/Base64EncodedData.swift +++ b/Sources/OpenAPIRuntime/Base/Base64EncodedData.swift @@ -54,12 +54,6 @@ public struct Base64EncodedData: Sendable, Hashable { /// A container of the raw bytes. public var data: ArraySlice - /// Initializes an instance of ``Base64EncodedData`` wrapping the provided slice of bytes. - /// - Parameter data: The underlying bytes to wrap. - @available(*, deprecated, renamed: "init(_:)") - - public init(data: ArraySlice) { self.data = data } - /// Initializes an instance of ``Base64EncodedData`` wrapping the provided slice of bytes. /// - Parameter data: The underlying bytes to wrap. public init(_ data: ArraySlice) { self.data = data } diff --git a/Sources/OpenAPIRuntime/Deprecated/Deprecated.swift b/Sources/OpenAPIRuntime/Deprecated/Deprecated.swift index 5dfee0b0..39cd0951 100644 --- a/Sources/OpenAPIRuntime/Deprecated/Deprecated.swift +++ b/Sources/OpenAPIRuntime/Deprecated/Deprecated.swift @@ -15,204 +15,3 @@ import Foundation import HTTPTypes // MARK: - Functionality to be removed in the future - -extension ClientError { - /// Creates a new error. - /// - Parameters: - /// - operationID: The OpenAPI operation identifier. - /// - operationInput: The operation-specific Input value. - /// - request: The HTTP request created during the operation. - /// - requestBody: The HTTP request body created during the operation. - /// - baseURL: The base URL for HTTP requests. - /// - response: The HTTP response received during the operation. - /// - responseBody: The HTTP response body received during the operation. - /// - underlyingError: The underlying error that caused the operation - /// to fail. - @available( - *, - deprecated, - renamed: - "ClientError.init(operationID:operationInput:request:requestBody:baseURL:response:responseBody:causeDescription:underlyingError:)", - message: "Use the initializer with a causeDescription parameter." - ) public init( - operationID: String, - operationInput: any Sendable, - request: HTTPRequest? = nil, - requestBody: HTTPBody? = nil, - baseURL: URL? = nil, - response: HTTPResponse? = nil, - responseBody: HTTPBody? = nil, - underlyingError: any Error - ) { - self.init( - operationID: operationID, - operationInput: operationInput, - request: request, - requestBody: requestBody, - baseURL: baseURL, - response: response, - responseBody: responseBody, - causeDescription: "Legacy error without a causeDescription.", - underlyingError: underlyingError - ) - } -} - -extension ServerError { - /// Creates a new error. - /// - Parameters: - /// - operationID: The OpenAPI operation identifier. - /// - request: The HTTP request provided to the server. - /// - requestBody: The HTTP request body provided to the server. - /// - requestMetadata: The request metadata extracted by the server. - /// - operationInput: An operation-specific Input value. - /// - operationOutput: An operation-specific Output value. - /// - underlyingError: The underlying error that caused the operation - /// to fail. - @available( - *, - deprecated, - renamed: - "ServerError.init(operationID:request:requestBody:requestMetadata:operationInput:operationOutput:causeDescription:underlyingError:)", - message: "Use the initializer with a causeDescription parameter." - ) public init( - operationID: String, - request: HTTPRequest, - requestBody: HTTPBody?, - requestMetadata: ServerRequestMetadata, - operationInput: (any Sendable)? = nil, - operationOutput: (any Sendable)? = nil, - underlyingError: any Error - ) { - self.init( - operationID: operationID, - request: request, - requestBody: requestBody, - requestMetadata: requestMetadata, - operationInput: operationInput, - operationOutput: operationOutput, - causeDescription: "Legacy error without a causeDescription.", - underlyingError: underlyingError - ) - } -} - -extension Converter { - /// Returns an error to be thrown when an unexpected content type is - /// received. - /// - Parameter contentType: The content type that was received. - /// - Returns: An error representing an unexpected content type. - @available(*, deprecated) public func makeUnexpectedContentTypeError(contentType: OpenAPIMIMEType?) -> any Error { - RuntimeError.unexpectedContentTypeHeader(contentType?.description ?? "") - } - - /// Checks whether a concrete content type matches an expected content type. - /// - /// The concrete content type can contain parameters, such as `charset`, but - /// they are ignored in the equality comparison. - /// - /// The expected content type can contain wildcards, such as */* and text/*. - /// - Parameters: - /// - received: The concrete content type to validate against the other. - /// - expectedRaw: The expected content type, can contain wildcards. - /// - Throws: A `RuntimeError` when `expectedRaw` is not a valid content type. - /// - Returns: A Boolean value representing whether the concrete content - /// type matches the expected one. - @available(*, deprecated) public func isMatchingContentType(received: OpenAPIMIMEType?, expectedRaw: String) throws - -> Bool - { - guard let received else { return false } - guard case let .concrete(type: receivedType, subtype: receivedSubtype) = received.kind else { return false } - guard let expectedContentType = OpenAPIMIMEType(expectedRaw) else { - throw RuntimeError.invalidExpectedContentType(expectedRaw) - } - switch expectedContentType.kind { - case .any: return true - case .anySubtype(let expectedType): return receivedType.lowercased() == expectedType.lowercased() - case .concrete(let expectedType, let expectedSubtype): - return receivedType.lowercased() == expectedType.lowercased() - && receivedSubtype.lowercased() == expectedSubtype.lowercased() - } - } -} - -extension DecodingError { - /// Returns a decoding error used by the oneOf decoder when not a single - /// child schema decodes the received payload. - /// - Parameters: - /// - type: The type representing the oneOf schema in which the decoding - /// occurred. - /// - codingPath: The coding path to the decoder that attempted to decode - /// the type. - /// - Returns: A decoding error. - @_spi(Generated) @available(*, deprecated) public static func failedToDecodeOneOfSchema( - type: Any.Type, - codingPath: [any CodingKey] - ) -> Self { - DecodingError.valueNotFound( - type, - DecodingError.Context.init( - codingPath: codingPath, - debugDescription: "The oneOf structure did not decode into any child schema." - ) - ) - } - - /// Returns a decoding error used by the anyOf decoder when not a single - /// child schema decodes the received payload. - /// - Parameters: - /// - type: The type representing the anyOf schema in which the decoding - /// occurred. - /// - codingPath: The coding path to the decoder that attempted to decode - /// the type. - /// - Returns: A decoding error. - @available(*, deprecated) static func failedToDecodeAnySchema(type: Any.Type, codingPath: [any CodingKey]) -> Self { - DecodingError.valueNotFound( - type, - DecodingError.Context.init( - codingPath: codingPath, - debugDescription: "The anyOf structure did not decode into any child schema." - ) - ) - } - - /// Verifies that the anyOf decoder successfully decoded at least one - /// child schema, and throws an error otherwise. - /// - Parameters: - /// - values: An array of optional values to check. - /// - type: The type representing the anyOf schema in which the decoding - /// occurred. - /// - codingPath: The coding path to the decoder that attempted to decode - /// the type. - /// - Throws: An error of type `DecodingError.failedToDecodeAnySchema` if none of the child schemas were successfully decoded. - @_spi(Generated) @available(*, deprecated) public static func verifyAtLeastOneSchemaIsNotNil( - _ values: [Any?], - type: Any.Type, - codingPath: [any CodingKey] - ) throws { - guard values.contains(where: { $0 != nil }) else { - throw DecodingError.failedToDecodeAnySchema(type: type, codingPath: codingPath) - } - } -} - -extension Configuration { - /// Creates a new configuration with the specified values. - /// - /// - Parameter dateTranscoder: The transcoder to use when converting between date - /// and string values. - @available(*, deprecated, renamed: "init(dateTranscoder:multipartBoundaryGenerator:)") @_disfavoredOverload - public init(dateTranscoder: any DateTranscoder) { - self.init(dateTranscoder: dateTranscoder, multipartBoundaryGenerator: .random) - } -} - -extension HTTPBody { - /// Describes how many times the provided sequence can be iterated. - @available( - *, - deprecated, - renamed: "IterationBehavior", - message: "Use the top level IterationBehavior directly instead of HTTPBody.IterationBehavior." - ) public typealias IterationBehavior = OpenAPIRuntime.IterationBehavior -} diff --git a/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Common.swift b/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Common.swift index bca29837..925ebf4f 100644 --- a/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Common.swift +++ b/Tests/OpenAPIRuntimeTests/Conversion/Test_Converter+Common.swift @@ -21,26 +21,6 @@ final class Test_CommonConverterExtensions: Test_Runtime { // MARK: Miscs - @available(*, deprecated) func testContentTypeMatching() throws { - let cases: [(received: String, expected: String, isMatch: Bool)] = [ - ("application/json", "application/json", true), ("APPLICATION/JSON", "application/json", true), - ("application/json", "application/*", true), ("application/json", "*/*", true), - ("application/json", "text/*", false), ("application/json", "application/xml", false), - ("application/json", "text/plain", false), - - ("text/plain; charset=UTF-8", "text/plain", true), ("TEXT/PLAIN; CHARSET=UTF-8", "text/plain", true), - ("text/plain; charset=UTF-8", "text/*", true), ("text/plain; charset=UTF-8", "*/*", true), - ("text/plain; charset=UTF-8", "application/*", false), ("text/plain; charset=UTF-8", "text/html", false), - ] - for testCase in cases { - XCTAssertEqual( - try converter.isMatchingContentType(received: .init(testCase.received), expectedRaw: testCase.expected), - testCase.isMatch, - "Wrong result for (\(testCase.received), \(testCase.expected), \(testCase.isMatch))" - ) - } - } - func testBestContentType() throws { func testCase( received: String?,