Skip to content

Commit fd101c3

Browse files
authored
[Runtime] Add headerFields and body to UndocumentedPayload (#90)
### Motivation The runtime changes for apple/swift-openapi-generator#299. ### Modifications Added `headerFields` and `body` properties to `UndocumentedPayload`, allowing adopters to access the full request information when an undocumented response is returned. ### Result Easier access to the raw payload when an undocumented response is returned. ### Test Plan These are just the runtime changes, tested together with generated changes.
1 parent bc1023f commit fd101c3

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

Sources/OpenAPIRuntime/Base/CommonOutputPayloads.swift renamed to Sources/OpenAPIRuntime/Base/UndocumentedPayload.swift

+17-2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
//
1313
//===----------------------------------------------------------------------===//
1414

15+
import HTTPTypes
16+
1517
/// A payload value used by undocumented operation responses.
1618
///
1719
/// Each operation's `Output` enum type needs to exhaustively
@@ -20,6 +22,19 @@
2022
/// `undocumented` enum case is used when such a status code is
2123
/// detected.
2224
public struct UndocumentedPayload: Sendable, Hashable {
23-
/// Creates a new payload.
24-
public init() {}
25+
26+
/// The header fields contained in the response.
27+
public var headerFields: HTTPFields
28+
29+
/// The body stream of this part, if present.
30+
public var body: HTTPBody?
31+
32+
/// Creates a new part.
33+
/// - Parameters:
34+
/// - headerFields: The header fields contained in the response.
35+
/// - body: The body stream of this part, if present.
36+
public init(headerFields: HTTPFields = [:], body: HTTPBody? = nil) {
37+
self.headerFields = headerFields
38+
self.body = body
39+
}
2540
}

Sources/OpenAPIRuntime/Deprecated/Deprecated.swift

+7
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,10 @@ import Foundation
1515
import HTTPTypes
1616

1717
// MARK: - Functionality to be removed in the future
18+
19+
extension UndocumentedPayload {
20+
/// Creates a new payload.
21+
@available(*, deprecated, renamed: "init(headerFields:body:)") @_disfavoredOverload public init() {
22+
self.init(headerFields: [:], body: nil)
23+
}
24+
}

0 commit comments

Comments
 (0)