Skip to content

[Swift] Operations with both query-based parameters & body-based parameters are not working #2483

@cjolif

Description

@cjolif

If in your operations you have something as follows:

             {
                        "name": "param1",
                        "in": "query",
                        "required": false,
                        "type": "string",
                        "enum": [
                            "true",
                            "false"
                        ]
                    },
                    {
                        "name": "param2",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/MyType"
                        }

The generated swift will contain something of the following form:

 public class func myOperationWithRequestBuilder(param2: MyType, param1: String?) -> RequestBuilder<> {
        var path = ...
        let URLString = SwaggerClientAPI.basePath + path

        let parameters = param2.encodeToJSON() as? [String:AnyObject]

        let requestBuilder: RequestBuilder<>.Type = SwaggerClientAPI.requestBuilderFactory.getBuilder()

        return requestBuilder.init(method: "PUT", URLString: URLString, parameters: parameters, isBody: false)

ignoring the query parameter (param1) and passing isBody false to the init.

The root limitation is that Alamofire either send parameters as query parameters or body but can't do both.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions