swagger-api / swagger-api/swagger-codegen
SWIFT Error in generated source when using only 200 and 204 return status
Open
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
When using a response containing only 200 and 204 response status
swag:
"/api/something/{somethingID}/documents/{attachmentID}/ownership": {
...
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/EntityOwnership"
}
},
"204": {
"description": "No ownership currently taken for this entity."
}
}
Swift Result is
public var success: EntityOwnership? {
switch self {
case .status200(let response): return response
}
}
which fails compiling in swift as enum is not exhaustive, should be :
switch self {
case .status200(let response): return response
default: return nil // OR case .status204: return nil
}
If 204 is provided alone, it works, if 204 is with another code != 200 also works
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 from the generated Swift Result enum shown in the report and trace how response statuses are represented when both 200 and 204 are present. Reproduce the case with only those statuses, then verify that the generated switch handles every enum case and that the Swift source compiles.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100