swagger-api / swagger-api/swagger-codegen

[Swift4] Update Alamofire implementations to remove deprecated use of '!' when downcasting error responses

Open
#8,006 1 comment 0 reactions 0 assignees View on GitHub

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
  1. Install Swagger Code Gen v. 2.4.0
  2. Generate client for Swift 4
  3. Use generated client in project
  4. 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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.