From f86829ccc7a161f0222a410a245e7ec8154de87c Mon Sep 17 00:00:00 2001 From: George Nyakundi Date: Tue, 11 Mar 2025 16:08:52 +0100 Subject: [PATCH 1/3] Introduce `useMsdkSwift` to allow for automatic switching of Backbase and BackbaseSDK --- .../src/main/templates/boat-swift5/APIs.mustache | 10 ++++++++++ .../src/main/templates/boat-swift5/Podfile.mustache | 7 ++++++- .../src/main/templates/boat-swift5/Podspec.mustache | 5 +++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache b/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache index e15ba5032..90eb5c831 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache @@ -5,7 +5,12 @@ // import Foundation +{{#useMsdkSwift}} +import BackbaseSDK +{{/useMsdkSwift}} +{{^useMsdkSwift}} import Backbase +{{/useMsdkSwift}} import ClientCommonGen2 {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{moduleName}}Client: NSObject, DBSClient { @@ -42,7 +47,12 @@ import ClientCommonGen2 self.headers = headers addHeaders({{moduleName}}Client.customHeaders) + {{#useMsdkSwift}} + addHeaders(Backbase.authClient()?.tokens() ?? [:]) + {{/useMsdkSwift}} + {{^useMsdkSwift}} addHeaders(Backbase.authClient().tokens()) + {{/useMsdkSwift}} } {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func addHeaders(_ aHeaders:[String:String]) { diff --git a/boat-scaffold/src/main/templates/boat-swift5/Podfile.mustache b/boat-scaffold/src/main/templates/boat-swift5/Podfile.mustache index ffe9e26f7..5188fdcc4 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/Podfile.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/Podfile.mustache @@ -10,7 +10,12 @@ install! 'cocoapods', deterministic_uuids: false inhibit_all_warnings! def normal_pods - pod 'Backbase', '>= 9'{{#useRxSwift}} + {{#useMsdkSwift}} + pod 'BackbaseSDK' + {{/useMsdkSwift}} + {{^useMsdkSwift}} + pod 'Backbase', '>= 9' + {{/useMsdkSwift}}{{#useRxSwift}} pod 'RxSwift', '>= 5.0.0'{{/useRxSwift}}{{#useAlamofire}} pod 'Alamofire', '>= 4.9.1'{{/useAlamofire}}{{#usePromiseKit}} pod 'PromiseKit', '>= 6.12.0'{{/usePromiseKit}} diff --git a/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache b/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache index e5adfc9b9..5734c7ccf 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache @@ -21,7 +21,12 @@ Pod::Spec.new do |s| s.vendored_frameworks = '{{projectName}}.xcframework' # ――― Dependencies ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― # + {{#useMsdkSwift}} + s.dependency 'BackbaseSDK' + {{/useMsdkSwift}} + {{^useMsdkSwift}} s.dependency 'Backbase', '>= 9.0' + {{/useMsdkSwift}} s.dependency 'ClientCommonGen2', '>= 1.0' {{#usePromiseKit}} s.dependency 'PromiseKit/CorePromise', '>= 6.12.0' From 63aab9c0923fcb98dea964a0ac8af671a1c5dcff Mon Sep 17 00:00:00 2001 From: George Nyakundi Date: Thu, 13 Mar 2025 14:04:52 +0100 Subject: [PATCH 2/3] Accomodate ClientCommons Moving to BackbaseSDK --- .../main/templates/boat-swift5/APIs.mustache | 3 +- .../templates/boat-swift5/Podspec.mustache | 2 +- .../main/templates/boat-swift5/api.mustache | 36 ++++++++++++++++++- .../boat-swift5/api_parameters.mustache | 5 +++ .../main/templates/boat-swift5/model.mustache | 5 +++ 5 files changed, 48 insertions(+), 3 deletions(-) diff --git a/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache b/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache index 90eb5c831..8dc94f139 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/APIs.mustache @@ -10,8 +10,9 @@ import BackbaseSDK {{/useMsdkSwift}} {{^useMsdkSwift}} import Backbase -{{/useMsdkSwift}} import ClientCommonGen2 +{{/useMsdkSwift}} + {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} class {{moduleName}}Client: NSObject, DBSClient { {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} var dataProvider: DBSDataProvider? diff --git a/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache b/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache index 5734c7ccf..8eaffa101 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/Podspec.mustache @@ -26,8 +26,8 @@ Pod::Spec.new do |s| {{/useMsdkSwift}} {{^useMsdkSwift}} s.dependency 'Backbase', '>= 9.0' - {{/useMsdkSwift}} s.dependency 'ClientCommonGen2', '>= 1.0' + {{/useMsdkSwift}} {{#usePromiseKit}} s.dependency 'PromiseKit/CorePromise', '>= 6.12.0' {{/usePromiseKit}} diff --git a/boat-scaffold/src/main/templates/boat-swift5/api.mustache b/boat-scaffold/src/main/templates/boat-swift5/api.mustache index 219741eba..d3a00b321 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/api.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/api.mustache @@ -6,8 +6,14 @@ // import Foundation +{{#useMsdkSwift}} +import BackbaseSDK +{{/useMsdkSwift}} +{{^useMsdkSwift}} import Backbase -import ClientCommonGen2{{#usePromiseKit}} +import ClientCommonGen2 +{{/useMsdkSwift}} +{{#usePromiseKit}} import PromiseKit{{/usePromiseKit}}{{#useRxSwift}} import RxSwift{{/useRxSwift}}{{#useCombine}} import Combine{{/useCombine}} @@ -77,7 +83,12 @@ extension {{moduleName}}Client { {{#description}} /** {{description}} */{{/description}} {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}public{{/nonPublicApi}} class {{classname}}: NSObject, DBSClient, {{classname}}Protocol { + {{#useMsdkSwift}} + public var dataProvider: BackbaseSDK.DBSDataProvider? + {{/useMsdkSwift}} + {{^useMsdkSwift}} public var dataProvider: DBSDataProvider? + {{/useMsdkSwift}} public var baseURL: URL public override init() { @@ -284,12 +295,23 @@ extension {{moduleName}}Client { ] let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders){{/-last}}{{/headerParams}} guard let url = urlComponents?.url else { throw CallError.invalidUrl } + {{#useMsdkSwift}} + let request = try BackbaseSDK.RequestBuilder.createURLRequest(requestUrl: url, + method: "{{httpMethod}}", + queryParameters: {{#hasQueryParams}}queryParameters.compactMapValues({ $0 }){{/hasQueryParams}}{{^hasQueryParams}}nil{{/hasQueryParams}}, + bodyParameters: parameters, + bodyType: {{#hasBodyParam}}{{^isMultipart}}.json{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{#isMultipart}}.multipartForm{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{^isMultipart}}.none{{/isMultipart}}{{/hasBodyParam}}{{#headerParams}}{{#-first}}, + headers: headerParameters{{/-first}}{{/headerParams}}) + {{/useMsdkSwift}} + {{^useMsdkSwift}} let request = try ClientCommonGen2.RequestBuilder.createURLRequest(requestUrl: url, method: "{{httpMethod}}", queryParameters: {{#hasQueryParams}}queryParameters.compactMapValues({ $0 }){{/hasQueryParams}}{{^hasQueryParams}}nil{{/hasQueryParams}}, bodyParameters: parameters, bodyType: {{#hasBodyParam}}{{^isMultipart}}.json{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{#isMultipart}}.multipartForm{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{^isMultipart}}.none{{/isMultipart}}{{/hasBodyParam}}{{#headerParams}}{{#-first}}, headers: headerParameters{{/-first}}{{/headerParams}}) + {{/useMsdkSwift}} + return Call<{{#returnType}}{{#isResponseFile}}Data{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}NoResponse{{/returnType}}>(dataProvider: dataProvider, request: request) } {{/hasParams}} @@ -356,12 +378,24 @@ extension {{moduleName}}Client { ] let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders){{/-last}}{{/headerParams}} guard let url = urlComponents?.url else { throw CallError.invalidUrl } + + {{#useMsdkSwift}} + let request = try BackbaseSDK.RequestBuilder.createURLRequest(requestUrl: url, + method: "{{httpMethod}}", + queryParameters: {{#hasQueryParams}}queryParameters.compactMapValues({ $0 }){{/hasQueryParams}}{{^hasQueryParams}}nil{{/hasQueryParams}}, + bodyParameters: parameters, + bodyType: {{#hasBodyParam}}{{^isMultipart}}.json{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{#isMultipart}}.multipartForm{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{^isMultipart}}.none{{/isMultipart}}{{/hasBodyParam}}{{#headerParams}}{{#-first}}, + headers: headerParameters{{/-first}}{{/headerParams}}) + {{/useMsdkSwift}} + {{^useMsdkSwift}} let request = try ClientCommonGen2.RequestBuilder.createURLRequest(requestUrl: url, method: "{{httpMethod}}", queryParameters: {{#hasQueryParams}}queryParameters.compactMapValues({ $0 }){{/hasQueryParams}}{{^hasQueryParams}}nil{{/hasQueryParams}}, bodyParameters: parameters, bodyType: {{#hasBodyParam}}{{^isMultipart}}.json{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{#isMultipart}}.multipartForm{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{^isMultipart}}.none{{/isMultipart}}{{/hasBodyParam}}{{#headerParams}}{{#-first}}, headers: headerParameters{{/-first}}{{/headerParams}}) + {{/useMsdkSwift}} + return Call<{{#returnType}}{{#isResponseFile}}Data{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}NoResponse{{/returnType}}>(dataProvider: dataProvider, request: request) } {{/operation}} diff --git a/boat-scaffold/src/main/templates/boat-swift5/api_parameters.mustache b/boat-scaffold/src/main/templates/boat-swift5/api_parameters.mustache index 9a44eb60f..75a4b473b 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/api_parameters.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/api_parameters.mustache @@ -8,7 +8,12 @@ // https://openapi-generator.tech import Foundation +{{#useMsdkSwift}} +import BackbaseSDK +{{/useMsdkSwift}} +{{^useMsdkSwift}} import ClientCommonGen2 +{{/useMsdkSwift}} public extension {{classname}} { {{#operation}} diff --git a/boat-scaffold/src/main/templates/boat-swift5/model.mustache b/boat-scaffold/src/main/templates/boat-swift5/model.mustache index 183e63d8b..48264e135 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/model.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/model.mustache @@ -6,7 +6,12 @@ // import Foundation +{{#useMsdkSwift}} +import BackbaseSDK +{{/useMsdkSwift}} +{{^useMsdkSwift}} import ClientCommonGen2 +{{/useMsdkSwift}} {{#description}} /** {{description}} */{{/description}} From f889db07e01cfbbffe315b350783140ed70536ab Mon Sep 17 00:00:00 2001 From: George Nyakundi Date: Mon, 17 Mar 2025 15:58:50 +0100 Subject: [PATCH 3/3] Remove deprecated method --- .../main/templates/boat-swift5/api.mustache | 87 ------------------- 1 file changed, 87 deletions(-) diff --git a/boat-scaffold/src/main/templates/boat-swift5/api.mustache b/boat-scaffold/src/main/templates/boat-swift5/api.mustache index 1fa598ec6..52381839a 100644 --- a/boat-scaffold/src/main/templates/boat-swift5/api.mustache +++ b/boat-scaffold/src/main/templates/boat-swift5/api.mustache @@ -201,93 +201,6 @@ extension {{moduleName}}Client { } {{/useResult}} - {{#hasParams}} - /** - {{#summary}} - {{{summary}}} - {{/summary}} - - {{httpMethod}} {{{path}}}{{#notes}} - - {{{notes}}}{{/notes}}{{#subresourceOperation}} - - subresourceOperation: {{subresourceOperation}}{{/subresourceOperation}}{{#defaultResponse}} - - defaultResponse: {{defaultResponse}}{{/defaultResponse}} - {{#authMethods}} - - {{#isBasic}}BASIC{{/isBasic}}{{#isOAuth}}OAuth{{/isOAuth}}{{#isApiKey}}API Key{{/isApiKey}}: - - type: {{type}}{{#keyParamName}} {{keyParamName}} {{#isKeyInQuery}}(QUERY){{/isKeyInQuery}}{{#isKeyInHeaer}}(HEADER){{/isKeyInHeaer}}{{/keyParamName}} - - name: {{name}} - {{/authMethods}} - {{#hasResponseHeaders}} - - responseHeaders: [{{#responseHeaders}}{{{baseName}}}({{{dataType}}}){{^-last}}, {{/-last}}{{/responseHeaders}}] - {{/hasResponseHeaders}} - {{#externalDocs}} - - externalDocs: {{externalDocs}} - {{/externalDocs}} - {{#allParams}} - - parameter {{paramName}}: ({{#isFormParam}}form{{/isFormParam}}{{#isQueryParam}}query{{/isQueryParam}}{{#isPathParam}}path{{/isPathParam}}{{#isHeaderParam}}header{{/isHeaderParam}}{{#isBodyParam}}body{{/isBodyParam}}) {{description}} {{^required}}(optional{{#defaultValue}}, default to {{{.}}}{{/defaultValue}}){{/required}} - {{/allParams}} - - returns: Call<{{#returnType}}{{#isResponseFile}}Data{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}NoResponse{{/returnType}}> {{description}} - */ - @available(*, deprecated, message: "This method is deprecated in favor of the alternative method with {{classname}}.{{operationIdCamelCase}}RequestParams class.") - {{#nonPublicApi}}internal{{/nonPublicApi}}{{^nonPublicApi}}open{{/nonPublicApi}} func {{operationId}}Call({{#allParams}}{{paramName}}: {{#isEnum}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}{{{datatypeWithEnum}}}_{{operationId}}{{/isContainer}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{^required}}? = nil{{/required}}{{^-last}}, {{/-last}}{{/allParams}}) throws -> Call<{{#returnType}}{{#isResponseFile}}Data{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}NoResponse{{/returnType}}> { - guard let dataProvider = dataProvider else { throw CallError.missingDataProvider } - {{^pathParams}}let{{/pathParams}}{{#pathParams}}{{#-first}}var{{/-first}}{{/pathParams}} path = "{{{path}}}"{{#pathParams}} - let {{paramName}}PathItem = "\({{#isEnum}}{{paramName}}{{#isContainer}}{{{dataType}}}{{/isContainer}}{{^isContainer}}.rawValue{{/isContainer}}{{/isEnum}}{{^isEnum}}APIHelper.mapValueToPathItem({{paramName}}){{/isEnum}})" - path = path.replacingOccurrences(of: "{{=<% %>=}}{<%baseName%>}<%={{ }}=%>", with: {{paramName}}PathItem, options: .literal, range: nil){{/pathParams}} - {{#pathParams}}{{#-first}}path = path.addingPercentEncoding(withAllowedCharacters: .urlPathAllowed) ?? ""{{/-first}}{{/pathParams}} - {{#bodyParam}} - let parameters = JSONEncodingHelper.encodingParameters(forEncodableObject: {{paramName}}) - {{/bodyParam}} - {{^bodyParam}} - {{#hasFormParams}} - let formParams: [String: Any?] = [ - {{#formParams}} - {{#isModel}} - "{{paramName}}": JSONEncodingHelper.encodingParameters(forEncodableObject: {{paramName}}){{^-last}}, {{/-last}} - {{/isModel}} - {{^isModel}} - {{> _param_deprecated}}{{^-last}}, {{/-last}} - {{/isModel}} - {{/formParams}} - ] - - let nonNullParameters = APIHelper.rejectNil(formParams) - let parameters = APIHelper.convertBoolToString(nonNullParameters) - {{/hasFormParams}} - {{^hasFormParams}} - let parameters: [String: Any]? = nil - {{/hasFormParams}} - {{/bodyParam}}{{#hasQueryParams}} - let queryParameters: [String: Any?] = [ - {{#queryParams}} - {{> _param_deprecated}}{{^-last}}, {{/-last}} - {{/queryParams}} - ]{{/hasQueryParams}} - let urlComponents = URLComponents(url: baseURL.appendingPathComponent(path), resolvingAgainstBaseURL: false){{#headerParams}}{{#-first}} - let nillableHeaders: [String: Any?] = [{{/-first}} - {{> _param_deprecated}}{{^-last}}, {{/-last}}{{#-last}} - ] - let headerParameters = APIHelper.rejectNilHeaders(nillableHeaders){{/-last}}{{/headerParams}} - guard let url = urlComponents?.url else { throw CallError.invalidUrl } - {{#useMsdkSwift}} - let request = try BackbaseSDK.RequestBuilder.createURLRequest(requestUrl: url, - method: "{{httpMethod}}", - queryParameters: {{#hasQueryParams}}queryParameters.compactMapValues({ $0 }){{/hasQueryParams}}{{^hasQueryParams}}nil{{/hasQueryParams}}, - bodyParameters: parameters, - bodyType: {{#hasBodyParam}}{{^isMultipart}}.json{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{#isMultipart}}.multipartForm{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{^isMultipart}}.none{{/isMultipart}}{{/hasBodyParam}}{{#headerParams}}{{#-first}}, - headers: headerParameters{{/-first}}{{/headerParams}}) - {{/useMsdkSwift}} - {{^useMsdkSwift}} - let request = try ClientCommonGen2.RequestBuilder.createURLRequest(requestUrl: url, - method: "{{httpMethod}}", - queryParameters: {{#hasQueryParams}}queryParameters.compactMapValues({ $0 }){{/hasQueryParams}}{{^hasQueryParams}}nil{{/hasQueryParams}}, - bodyParameters: parameters, - bodyType: {{#hasBodyParam}}{{^isMultipart}}.json{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{#isMultipart}}.multipartForm{{/isMultipart}}{{/hasBodyParam}}{{^hasBodyParam}}{{^isMultipart}}.none{{/isMultipart}}{{/hasBodyParam}}{{#headerParams}}{{#-first}}, - headers: headerParameters{{/-first}}{{/headerParams}}) - {{/useMsdkSwift}} - - return Call<{{#returnType}}{{#isResponseFile}}Data{{/isResponseFile}}{{^isResponseFile}}{{{returnType}}}{{/isResponseFile}}{{/returnType}}{{^returnType}}NoResponse{{/returnType}}>(dataProvider: dataProvider, request: request) - } - {{/hasParams}} - /** {{#summary}} {{{summary}}}