Skip to content

Support for exploded params - self contained patch #1075

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

mirkokg
Copy link

@mirkokg mirkokg commented Jun 16, 2025

Create self contained patch to add support for exploded parameters for GET requests based on OpenAPI exploded property, default is exploded true, like defined in OpenAPI specification.


import Foundation
import Backbase

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing an import statement.

import ClientCommonGen2

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reviewing my PR, I added missing import

case .none:
break
case .json:
modifiedRequest = JSONDataEncoding.encode(modifiedRequest, with: bodyParameters)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can't call theencode function as such since is not static.

headers.forEach { modifiedRequest.setValue($0.value, forHTTPHeaderField: $0.key) }
Backbase.authClient().tokens().forEach { modifiedRequest.setValue($0.value, forHTTPHeaderField: $0.key) }

switch bodyType {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This switch statement is missing a default case

method: String,
queryParameters: [String: Any]?,
bodyParameters: [String: Any]?,
bodyType: BodyType,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which BodyType are you referring to here? If possible add the correct namespace

}

// MARK: - RequestBuilder Extension with Custom Encoding
public extension RequestBuilder {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public extension RequestBuilder {
public extension ClientCommonGen2.RequestBuilder {

"{{baseName}}": {{#isContainer}}params.{{paramName}}.{{#isExplode}}exploded{{/isExplode}}{{^isExplode}}commaSeparated{{/isExplode}}{{/isContainer}}{{^isContainer}}{{#isFreeFormObject}}(params.{{paramName}} as{{^required}}?{{/required}} String){{^required}}?{{/required}}.encodeToJSON(){{/isFreeFormObject}}{{^isFreeFormObject}}{{#isEnum}}params.{{paramName}}{{^required}}?{{/required}}.rawValue{{/isEnum}}{{^isEnum}}params.{{paramName}}{{^required}}?{{/required}}.{{#isDateTime}}encodeToJSONDateTime{{/isDateTime}}{{^isDateTime}}encodeToJSON{{/isDateTime}}(){{/isEnum}}{{/isFreeFormObject}}{{/isContainer}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a check for {{^required}}?{{/required}} to cater for optional parameters

}

// Helper extensions for easier ArrayParam creation
public extension Array {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's need to handle dictionaries as well.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants