Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add the option for the generate-spec command to rename models #624

Merged
merged 9 commits into from
Jan 17, 2025
2 changes: 1 addition & 1 deletion Scripts/generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ rm -rf ./Sources/StreamVideo/OpenApi/generated/Models/*
# cd in API repo, generate new spec and then generate code from it
(
cd $SOURCE_PATH &&
go run ./cmd/chat-manager openapi generate-spec -products video -version v1 -clientside -output releases/video-openapi-clientside &&
go run ./cmd/chat-manager openapi generate-spec -products video -version v1 -clientside -output releases/video-openapi-clientside -renamed-models ../stream-video-swift/Scripts/renamed-models.json &&
go run ./cmd/chat-manager openapi generate-client --language swift --spec ./releases/video-openapi-clientside.yaml --output ../stream-video-swift/Sources/StreamVideo/OpenApi/generated/
)

Expand Down
23 changes: 23 additions & 0 deletions Scripts/renamed-models.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"QueryCallMembersResponse": "QueryMembersResponse",
"QueryCallMembersRequest": "QueryMembersRequest",
"Response": "ModelResponse",
"SendCallEventRequest": "SendEventRequest",
"SendCallEventResponse": "SendEventResponse",
"AudioSettingsResponse": "AudioSettings",
"SortParam": "SortParamRequest",
"WSAuthMessage": "WSAuthMessageRequest",
"TranscriptionSettingsResponse": "TranscriptionSettings",
"SendCallEvent": "SendEvent",
"BackstageSettingsResponse": "BackstageSettings",
"GeofenceSettingsResponse": "GeofenceSettings",
"LayoutSettingsRequest": "LayoutSettings",
"RingSettingsResponse": "RingSettings",
"ScreensharingSettingsResponse": "ScreensharingSettings",
"ThumbnailsSettingsResponse": "ThumbnailsSettings",
"VideoSettingsResponse": "VideoSettings",
"TimeStats": "Stats",
"NoiseCancellationSettings": "NoiseCancellationSettingsRequest",
"VideoDimension": "VideoResolution",
"DeviceResponse": "Device"
}
25 changes: 19 additions & 6 deletions Sources/StreamVideo/Call.swift
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,15 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
/// Stops an ongoing live call.
@discardableResult
public func stopLive() async throws -> StopLiveResponse {
try await coordinatorClient.stopLive(type: callType, id: callId)
try await stopLive(request: .init())
}

public func stopLive(request: StopLiveRequest) async throws -> StopLiveResponse {
try await coordinatorClient.stopLive(
type: callType,
id: callId,
stopLiveRequest: request
)
}

// MARK: - Recording
Expand Down Expand Up @@ -786,7 +794,7 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {
/// - Throws: An error if the sending fails.
@discardableResult
public func sendCustomEvent(_ data: [String: RawJSON]) async throws -> SendEventResponse {
try await coordinatorClient.sendEvent(
try await coordinatorClient.sendCallEvent(
type: callType,
id: callId,
sendEventRequest: SendEventRequest(custom: data)
Expand Down Expand Up @@ -1087,14 +1095,19 @@ public class Call: @unchecked Sendable, WSEventsSubscriber {

/// Stops a conversation from being transcribed and returns whether the stop request was successful
/// or not.
///
/// - Returns: A StopTranscriptionResponse indicating whether the stop request was successful
/// - Parameter stopClosedCaptions: A boolean value indicating whether to stop closed captions.
/// - Returns: A StopTranscriptionResponse indicating whether the stop request was successful.
/// or not.
@discardableResult
public func stopTranscription() async throws -> StopTranscriptionResponse {
public func stopTranscription(
stopClosedCaptions: Bool? = nil
) async throws -> StopTranscriptionResponse {
try await coordinatorClient.stopTranscription(
type: callType,
id: callId
id: callId,
stopTranscriptionRequest: StopTranscriptionRequest(
stopClosedCaptions: stopClosedCaptions
)
)
}

Expand Down
64 changes: 50 additions & 14 deletions Sources/StreamVideo/OpenApi/generated/APIs/DefaultAPI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
}
}

open func sendEvent(type: String, id: String, sendEventRequest: SendEventRequest) async throws -> SendEventResponse {
open func sendCallEvent(type: String, id: String, sendEventRequest: SendEventRequest) async throws -> SendEventResponse {
var path = "/video/call/{type}/{id}/event"

let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
Expand Down Expand Up @@ -665,7 +665,11 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
}
}

open func startClosedCaptions(type: String, id: String) async throws -> StartClosedCaptionsResponse {
open func startClosedCaptions(
type: String,
id: String,
startClosedCaptionsRequest: StartClosedCaptionsRequest
) async throws -> StartClosedCaptionsResponse {
var path = "/video/call/{type}/{id}/start_closed_captions"

let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
Expand All @@ -677,7 +681,8 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {

let urlRequest = try makeRequest(
uriPath: path,
httpMethod: "POST"
httpMethod: "POST",
request: startClosedCaptionsRequest
)
return try await send(request: urlRequest) {
try self.jsonDecoder.decode(StartClosedCaptionsResponse.self, from: $0)
Expand Down Expand Up @@ -778,7 +783,11 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
}
}

open func stopClosedCaptions(type: String, id: String) async throws -> StopClosedCaptionsResponse {
open func stopClosedCaptions(
type: String,
id: String,
stopClosedCaptionsRequest: StopClosedCaptionsRequest
) async throws -> StopClosedCaptionsResponse {
var path = "/video/call/{type}/{id}/stop_closed_captions"

let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
Expand All @@ -790,14 +799,15 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {

let urlRequest = try makeRequest(
uriPath: path,
httpMethod: "POST"
httpMethod: "POST",
request: stopClosedCaptionsRequest
)
return try await send(request: urlRequest) {
try self.jsonDecoder.decode(StopClosedCaptionsResponse.self, from: $0)
}
}

open func stopLive(type: String, id: String) async throws -> StopLiveResponse {
open func stopLive(type: String, id: String, stopLiveRequest: StopLiveRequest) async throws -> StopLiveResponse {
var path = "/video/call/{type}/{id}/stop_live"

let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
Expand All @@ -809,7 +819,8 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {

let urlRequest = try makeRequest(
uriPath: path,
httpMethod: "POST"
httpMethod: "POST",
request: stopLiveRequest
)
return try await send(request: urlRequest) {
try self.jsonDecoder.decode(StopLiveResponse.self, from: $0)
Expand All @@ -835,7 +846,11 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
}
}

open func stopTranscription(type: String, id: String) async throws -> StopTranscriptionResponse {
open func stopTranscription(
type: String,
id: String,
stopTranscriptionRequest: StopTranscriptionRequest
) async throws -> StopTranscriptionResponse {
var path = "/video/call/{type}/{id}/stop_transcription"

let typePreEscape = "\(APIHelper.mapValueToPathItem(type))"
Expand All @@ -847,7 +862,8 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {

let urlRequest = try makeRequest(
uriPath: path,
httpMethod: "POST"
httpMethod: "POST",
request: stopTranscriptionRequest
)
return try await send(request: urlRequest) {
try self.jsonDecoder.decode(StopTranscriptionResponse.self, from: $0)
Expand Down Expand Up @@ -1104,6 +1120,20 @@ open class DefaultAPI: DefaultAPIEndpoints, @unchecked Sendable {
try self.jsonDecoder.decode(EmptyResponse.self, from: $0)
}
}

open func queryAggregateCallStats(queryAggregateCallStatsRequest: QueryAggregateCallStatsRequest) async throws
-> QueryAggregateCallStatsResponse {
let path = "/video/stats"

let urlRequest = try makeRequest(
uriPath: path,
httpMethod: "POST",
request: queryAggregateCallStatsRequest
)
return try await send(request: urlRequest) {
try self.jsonDecoder.decode(QueryAggregateCallStatsResponse.self, from: $0)
}
}
}

protocol DefaultAPIEndpoints {
Expand All @@ -1125,7 +1155,7 @@ protocol DefaultAPIEndpoints {

func deleteCall(type: String, id: String, deleteCallRequest: DeleteCallRequest) async throws -> DeleteCallResponse

func sendEvent(type: String, id: String, sendEventRequest: SendEventRequest) async throws -> SendEventResponse
func sendCallEvent(type: String, id: String, sendEventRequest: SendEventRequest) async throws -> SendEventResponse

func collectUserFeedback(
type: String,
Expand Down Expand Up @@ -1165,7 +1195,8 @@ protocol DefaultAPIEndpoints {

func startHLSBroadcasting(type: String, id: String) async throws -> StartHLSBroadcastingResponse

func startClosedCaptions(type: String, id: String) async throws -> StartClosedCaptionsResponse
func startClosedCaptions(type: String, id: String, startClosedCaptionsRequest: StartClosedCaptionsRequest) async throws
-> StartClosedCaptionsResponse

func startRecording(type: String, id: String, startRecordingRequest: StartRecordingRequest) async throws
-> StartRecordingResponse
Expand All @@ -1177,13 +1208,15 @@ protocol DefaultAPIEndpoints {

func stopHLSBroadcasting(type: String, id: String) async throws -> StopHLSBroadcastingResponse

func stopClosedCaptions(type: String, id: String) async throws -> StopClosedCaptionsResponse
func stopClosedCaptions(type: String, id: String, stopClosedCaptionsRequest: StopClosedCaptionsRequest) async throws
-> StopClosedCaptionsResponse

func stopLive(type: String, id: String) async throws -> StopLiveResponse
func stopLive(type: String, id: String, stopLiveRequest: StopLiveRequest) async throws -> StopLiveResponse

func stopRecording(type: String, id: String) async throws -> StopRecordingResponse

func stopTranscription(type: String, id: String) async throws -> StopTranscriptionResponse
func stopTranscription(type: String, id: String, stopTranscriptionRequest: StopTranscriptionRequest) async throws
-> StopTranscriptionResponse

func listTranscriptions(type: String, id: String) async throws -> ListTranscriptionsResponse

Expand Down Expand Up @@ -1212,4 +1245,7 @@ protocol DefaultAPIEndpoints {
func createGuest(createGuestRequest: CreateGuestRequest) async throws -> CreateGuestResponse

func videoConnect() async throws -> Void

func queryAggregateCallStats(queryAggregateCallStatsRequest: QueryAggregateCallStatsRequest) async throws
-> QueryAggregateCallStatsResponse
}
31 changes: 31 additions & 0 deletions Sources/StreamVideo/OpenApi/generated/Models/Bound.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
//
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

import Foundation

public final class Bound: @unchecked Sendable, Codable, JSONEncodable, Hashable {

public var inclusive: Bool
public var value: Float

public init(inclusive: Bool, value: Float) {
self.inclusive = inclusive
self.value = value
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case inclusive
case value
}

public static func == (lhs: Bound, rhs: Bound) -> Bool {
lhs.inclusive == rhs.inclusive &&
lhs.value == rhs.value
}

public func hash(into hasher: inout Hasher) {
hasher.combine(inclusive)
hasher.combine(value)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ public final class CallClosedCaption: @unchecked Sendable, Codable, JSONEncodabl
public var speakerId: String
public var startTime: Date
public var text: String
public var user: UserResponse?
public var user: UserResponse

public init(endTime: Date, speakerId: String, startTime: Date, text: String, user: UserResponse? = nil) {
public init(endTime: Date, speakerId: String, startTime: Date, text: String, user: UserResponse) {
self.endTime = endTime
self.speakerId = speakerId
self.startTime = startTime
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

import Foundation

public final class CallDurationReport: @unchecked Sendable, Codable, JSONEncodable, Hashable {

public var histogram: [ReportByHistogramBucket]
ipavlidakis marked this conversation as resolved.
Show resolved Hide resolved

public init(histogram: [ReportByHistogramBucket]) {
self.histogram = histogram
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case histogram
}

public static func == (lhs: CallDurationReport, rhs: CallDurationReport) -> Bool {
lhs.histogram == rhs.histogram
}

public func hash(into hasher: inout Hasher) {
hasher.combine(histogram)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

import Foundation

public final class CallDurationReportResponse: @unchecked Sendable, Codable, JSONEncodable, Hashable {

public var daily: [DailyAggregateCallDurationReportResponse]

public init(daily: [DailyAggregateCallDurationReportResponse]) {
self.daily = daily
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case daily
}

public static func == (lhs: CallDurationReportResponse, rhs: CallDurationReportResponse) -> Bool {
lhs.daily == rhs.daily
}

public func hash(into hasher: inout Hasher) {
hasher.combine(daily)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public final class CallEvent: @unchecked Sendable, Codable, JSONEncodable, Hasha
public var description: String
public var endTimestamp: Int
public var issueTags: [String]?
public var kind: String?
public var kind: String
public var severity: Int
public var timestamp: Int
public var type: String
Expand All @@ -24,7 +24,7 @@ public final class CallEvent: @unchecked Sendable, Codable, JSONEncodable, Hasha
description: String,
endTimestamp: Int,
issueTags: [String]? = nil,
kind: String? = nil,
kind: String,
severity: Int,
timestamp: Int,
type: String
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// Copyright © 2025 Stream.io Inc. All rights reserved.
//

import Foundation

public final class CallParticipantCountReport: @unchecked Sendable, Codable, JSONEncodable, Hashable {

public var histogram: [ReportByHistogramBucket]

public init(histogram: [ReportByHistogramBucket]) {
self.histogram = histogram
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case histogram
}

public static func == (lhs: CallParticipantCountReport, rhs: CallParticipantCountReport) -> Bool {
lhs.histogram == rhs.histogram
}

public func hash(into hasher: inout Hasher) {
hasher.combine(histogram)
}
}
Loading
Loading