-
Notifications
You must be signed in to change notification settings - Fork 27
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
base: main
Are you sure you want to change the base?
Conversation
|
||
import Foundation | ||
import Backbase | ||
|
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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}} |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
|
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.