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
47 changes: 33 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 @@ -1125,7 +1141,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 +1181,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 +1194,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
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
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
Expand Up @@ -8,7 +8,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha

public var backstage: Bool
public var blockedUserIds: [String]
public var captioning: Bool?
public var captioning: Bool
public var cid: String
public var createdAt: Date
public var createdBy: UserResponse
Expand All @@ -32,7 +32,7 @@ public final class CallResponse: @unchecked Sendable, Codable, JSONEncodable, Ha
public init(
backstage: Bool,
blockedUserIds: [String],
captioning: Bool? = nil,
captioning: Bool,
cid: String,
createdAt: Date,
createdBy: UserResponse,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,23 @@ public final class CallSessionParticipantLeftEvent: @unchecked Sendable, Event,

public var callCid: String
public var createdAt: Date
public var durationSeconds: Int
public var participant: CallParticipantResponse
public var sessionId: String
public var type: String = "call.session_participant_left"

public init(callCid: String, createdAt: Date, participant: CallParticipantResponse, sessionId: String) {
public init(callCid: String, createdAt: Date, durationSeconds: Int, participant: CallParticipantResponse, sessionId: String) {
self.callCid = callCid
self.createdAt = createdAt
self.durationSeconds = durationSeconds
self.participant = participant
self.sessionId = sessionId
}

public enum CodingKeys: String, CodingKey, CaseIterable {
case callCid = "call_cid"
case createdAt = "created_at"
case durationSeconds = "duration_seconds"
case participant
case sessionId = "session_id"
case type
Expand All @@ -30,6 +33,7 @@ public final class CallSessionParticipantLeftEvent: @unchecked Sendable, Event,
public static func == (lhs: CallSessionParticipantLeftEvent, rhs: CallSessionParticipantLeftEvent) -> Bool {
lhs.callCid == rhs.callCid &&
lhs.createdAt == rhs.createdAt &&
lhs.durationSeconds == rhs.durationSeconds &&
lhs.participant == rhs.participant &&
lhs.sessionId == rhs.sessionId &&
lhs.type == rhs.type
Expand All @@ -38,6 +42,7 @@ public final class CallSessionParticipantLeftEvent: @unchecked Sendable, Event,
public func hash(into hasher: inout Hasher) {
hasher.combine(callCid)
hasher.combine(createdAt)
hasher.combine(durationSeconds)
hasher.combine(participant)
hasher.combine(sessionId)
hasher.combine(type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public final class CallSettingsRequest: @unchecked Sendable, Codable, JSONEncoda
public var recording: RecordSettingsRequest?
public var ring: RingSettingsRequest?
public var screensharing: ScreensharingSettingsRequest?
public var session: SessionSettingsRequest?
public var thumbnails: ThumbnailsSettingsRequest?
public var transcription: TranscriptionSettingsRequest?
public var video: VideoSettingsRequest?
Expand All @@ -27,6 +28,7 @@ public final class CallSettingsRequest: @unchecked Sendable, Codable, JSONEncoda
recording: RecordSettingsRequest? = nil,
ring: RingSettingsRequest? = nil,
screensharing: ScreensharingSettingsRequest? = nil,
session: SessionSettingsRequest? = nil,
thumbnails: ThumbnailsSettingsRequest? = nil,
transcription: TranscriptionSettingsRequest? = nil,
video: VideoSettingsRequest? = nil
Expand All @@ -39,6 +41,7 @@ public final class CallSettingsRequest: @unchecked Sendable, Codable, JSONEncoda
self.recording = recording
self.ring = ring
self.screensharing = screensharing
self.session = session
self.thumbnails = thumbnails
self.transcription = transcription
self.video = video
Expand All @@ -53,6 +56,7 @@ public final class CallSettingsRequest: @unchecked Sendable, Codable, JSONEncoda
case recording
case ring
case screensharing
case session
case thumbnails
case transcription
case video
Expand All @@ -67,6 +71,7 @@ public final class CallSettingsRequest: @unchecked Sendable, Codable, JSONEncoda
lhs.recording == rhs.recording &&
lhs.ring == rhs.ring &&
lhs.screensharing == rhs.screensharing &&
lhs.session == rhs.session &&
lhs.thumbnails == rhs.thumbnails &&
lhs.transcription == rhs.transcription &&
lhs.video == rhs.video
Expand All @@ -81,6 +86,7 @@ public final class CallSettingsRequest: @unchecked Sendable, Codable, JSONEncoda
hasher.combine(recording)
hasher.combine(ring)
hasher.combine(screensharing)
hasher.combine(session)
hasher.combine(thumbnails)
hasher.combine(transcription)
hasher.combine(video)
Expand Down
Loading