swagger-api / swagger-api/swagger-codegen
[Swift4] Update Alamofire implementations to remove deprecated use of '!' when downcasting error responses
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I would like the AlamofireImplementations.swift to be updated, removing the deprecated use of '!' when downcasting error responses.
Swagger-codegen version
Code gen v 2.4.0
Swagger declaration file content or url
AlamofireImplementations.swift: Line 127
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
AlamofireImplementations.swift: Line 329
ErrorResponse.error(stringResponse.response?.statusCode ?? 500, stringResponse.data, stringResponse.result.error as Error!)
Command line used for generation
swagger-codegen generate -i $mysource -l swift4 -o /path/to/output -c my-config.json
Steps to reproduce
- Install Swagger Code Gen v. 2.4.0
- Generate client for Swift 4
- Use generated client in project
- Build project
Suggest a fix/enhancement
Since the error is optional, consider making the error optional in the ErrorResponse defined in Models.swift
public enum ErrorResponse: Error {
case error(Int, Data?, Error?)
}
It's also recommended to update the dependency in the .podspec to Alamofire 4.7.1.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Swift 4 generation path and inspect the two reported locations in AlamofireImplementations.swift, lines 127 and 329, along with ErrorResponse in Models.swift. Regenerate a client with the shown command and confirm the generated code builds without the deprecated downcast usage; review the .podspec dependency reference as part of the result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100