-
Notifications
You must be signed in to change notification settings - Fork 6k
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]
}