You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The swift5 generator with Alamofire library produces a Package.swift file that allows Alamofire version 5.10 that was released October 13, 2024.
Alamofire 5.10 changed the definition of the type ParameterEncoding so that it no longer is equivalent to [String: Any].
This causes the generated code to appear to be making a recursive call.
extension JSONDataEncoding: ParameterEncoding {
...
public func encode(_ urlRequest: URLRequestConvertible, with parameters: Parameters?) throws -> URLRequest {
let urlRequest = try urlRequest.asURLRequest()
return encode(urlRequest, with: parameters)
}
}
The content of the spec file doesn't affect this bug
Steps to reproduce
Generate using openapi-generator generate -g swift5 --library alamofire -i spec.yaml
Compile the swift code using swift build
Observe compile errors
/code/swift-api/AlamofireImplementations.swift:411:16: error: call can throw but is not marked with 'try'
409 | let urlRequest = try urlRequest.asURLRequest()
410 |
411 | return encode(urlRequest, with: parameters)
| |- error: call can throw but is not marked with 'try'
| |- note: did you mean to use 'try'?
| |- note: did you mean to handle error as optional value?
| `- note: did you mean to disable error propagation?
412 | }
413 | }
Related issues/PRs
Suggest a fix
I'll create a PR, but here are various options ( I prefer 1)
In modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache just specify the desired type as [String: Any]? in the function call.
In modules/openapi-generator/src/main/resources/swift5/JSONDataEncoding.mustache change the type of parameters: argument to conditionally be of type Parameters if alamofire library is selected
If alamofire library is selected Make JSONDataEncoding conform to ParameterEncoding protocol, which would require the Parameters type.
Limit Alamofire package dependency to version 5.9.1 at most.
The text was updated successfully, but these errors were encountered:
Description
The swift5 generator with Alamofire library produces a Package.swift file that allows Alamofire version 5.10 that was released October 13, 2024.
Alamofire 5.10 changed the definition of the type
ParameterEncoding
so that it no longer is equivalent to[String: Any]
.This causes the generated code to appear to be making a recursive call.
openapi-generator version
openapi-generator-maven-plugin 7.9.0
OpenAPI declaration file content or url
The content of the spec file doesn't affect this bug
Steps to reproduce
Generate using
openapi-generator generate -g swift5 --library alamofire -i spec.yaml
Compile the swift code using
swift build
Observe compile errors
Related issues/PRs
Suggest a fix
I'll create a PR, but here are various options ( I prefer 1)
In
modules/openapi-generator/src/main/resources/swift5/libraries/alamofire/AlamofireImplementations.mustache
just specify the desired typeas [String: Any]?
in the function call.In
modules/openapi-generator/src/main/resources/swift5/JSONDataEncoding.mustache
change the type of parameters: argument to conditionally be of typeParameters
if alamofire library is selectedIf alamofire library is selected Make JSONDataEncoding conform to
ParameterEncoding
protocol, which would require theParameters
type.Limit Alamofire package dependency to version 5.9.1 at most.
The text was updated successfully, but these errors were encountered: