swagger-api / swagger-api/swagger-codegen
[Swift4] Accept and Content-type headers should be available as specified in swagger specs
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Accept headers should be validated with the allowed accept header in the produces section of the YAML specs
Content-type header should be set as the one from YAML
so that the request going out is well constructed per the specs set in the YAML file.
This is happening in the ObjC code generated from the same snapshot but not in the Swift code
Swagger-codegen version
2.3.0 latest snapshot 18th November
Swagger declaration file content or url
consumes:
- application/json;charset=UTF-8
produces:
- application/json
Command line used for generation
java -jar swagger-codegen-2.3.0.jar generate -c SwaggerConfig.json -i MySwagger.yaml -l swift4 -o /tmp/20-Nov-17
Steps to reproduce
set the above consumes and produces in the YAML file and generate Swift Swagger code or ObjC Swagger code then the request generated is never validated for the headers being set appropriately in the API.swift file
Related issues/PRs
Suggest a fix/enhancement
1, make public methods available that vend out this information as specified in the YAML eg.
at its simplest. This way the consuming client for this pod can use this in even when it is constructing the Datarequest in it's own way.
public func valueFor(headerName: String) -> String? {
let headers =
["Content-Type": "application/json;charset=UTF-8", //from the consumes section
"Accept": "application/json" //from produces section
]
return headers[headerName]
}
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 generated Swift API.swift from the documented swagger-codegen command and compare its Accept and Content-Type handling with the generated ObjC client. Trace how the YAML consumes and produces values reach the request, then verify that Swift requests use those values and expose the requested header information.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- api
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100