Skip to content

Commit 47ec7d1

Browse files
committed
Deprecated: mark asDecodedServerSentEventsWithJSONData as deprecated
1 parent 68d8d9c commit 47ec7d1

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Sources/OpenAPIRuntime/Deprecated/Deprecated.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,4 +69,22 @@ extension AsyncSequence where Element == ArraySlice<UInt8>, Self: Sendable {
6969
@_disfavoredOverload public func asDecodedServerSentEvents() -> ServerSentEventsDeserializationSequence<
7070
ServerSentEventsLineDeserializationSequence<Self>
7171
> { asDecodedServerSentEvents(while: { _ in true }) }
72+
73+
/// Returns another sequence that decodes each event's data as the provided type using the provided decoder.
74+
///
75+
/// Use this method if the event's `data` field is JSON.
76+
/// - Parameters:
77+
/// - dataType: The type to decode the JSON data into.
78+
/// - decoder: The JSON decoder to use.
79+
/// - Returns: A sequence that provides the events with the decoded JSON data.
80+
@available(*, deprecated, renamed: "asDecodedServerSentEventsWithJSONData(of:decoder:while:)")
81+
@_disfavoredOverload public func asDecodedServerSentEventsWithJSONData<JSONDataType: Decodable>(
82+
of dataType: JSONDataType.Type = JSONDataType.self,
83+
decoder: JSONDecoder = .init()
84+
) -> AsyncThrowingMapSequence<
85+
ServerSentEventsDeserializationSequence<ServerSentEventsLineDeserializationSequence<Self>>,
86+
ServerSentEventWithJSONData<JSONDataType>
87+
> {
88+
asDecodedServerSentEventsWithJSONData(of: dataType, decoder: decoder, while: { _ in true })
89+
}
7290
}

0 commit comments

Comments
 (0)