-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Milestone
Description
Description
Hi
I am struggling with primitive parameters used in the request body of POST requests.
The problem is that primitive parametertypes, such as "string", are forced to be JSON encoded, because all body-parameters are being JSON encoded.
Thats part of the problem. Another problem is that all parameters are being casted to a [String:AnyObject] dictionary, although a plain string will never succeed in doing so.
This is the code that swagger-codegen generated:
open class func myRequestWithRequestBuilder(xyz: String) -> RequestBuilder<ABC> {
let path = ...
let URLString = ...
let parameters = xyz.encodeToJSON() as? [String:AnyObject] //<- this will always fail for primitives
let url = NSURLComponents(string: URLString)
let requestBuilder..
return requestBuilder.init(method: "POST", URLString: (url?.string ?? URLString), parameters: parameters, isBody: true)
}
Swagger-codegen version
2.2.2
Swagger declaration file content or url
post:
tags:
- "MyApp"
description: "description"
consumes:
- "text/plain"
produces:
- "application/json"
parameters:
- in: "body"
name: "xyz"
required: true
schema:
type: "string"
Command line used for generation
java -jar swagger-codegen-cli.jar generate -i /path/to/my.yaml -l swift3 -o swaggeroutput/