Skip to content

Bug in auto generated client-side code [Swift]  #3858

@omerjanjua

Description

@omerjanjua
Description

There's an issue with the url path generated for one of the methods.

Swagger-codegen version
    public class func accountPaymentTokensWithRequestBuilder(accountId accountId: Int32) -> RequestBuilder<[PaymentToken]> {
        var path = "/accounts/{account-id}/payment-tokens"
        path = path.stringByReplacingOccurrencesOfString("{accountId}", withString: "\(accountId)", options: .LiteralSearch, range: nil)
        let URLString = SwaggerClientAPI.basePath + path
Swagger declaration file content or url
                "parameters": [
                    {
                        "name": "account-id",
                        "in": "path",
                        "required": true,
                        "type": "integer",
                        "format": "int32"
                    },
Steps to reproduce

Generate client-side Swift code from http://editor.swagger.io/#/

Suggest a Fix

In the method stringByReplacingOccurrencesOfString "{accountId}" should be the the value name from the JSON string account-id instead it pulls the value from the variable name accountId

The whole line should be path = path.stringByReplacingOccurrencesOfString("{account-id}", withString: "\(accountId)", options: .LiteralSearch, range: nil)

Or better yet, include the variable directly in the url and ditch the second line completley
var path = "/accounts/\(accountId)/payment-tokens"

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions