Skip to content

[typescript-angular2] Arrays in query params not using preferred format #4531

@RichiWIP

Description

@RichiWIP
Description

I am currently developing a middleware API and I generate my angular2 client using codegen. I have one call that expects a short array of strings as a query parameter. The current generator will create a call like this:
http://www.foo.bar/somthing?array=value1,value2,value3

My middleware doesn't understand this format and as far as I have researched, it is preferred to use the following format:
http://www.foo.bar/somthing?array=value1&array=value2&array=value3

Swagger-codegen version

2.0.17

Suggest a Fix

I suggest replacing the current template for queryParams with this code:

{{#queryParams}}
        if ({{paramName}} !== undefined) {
            {{#isListContainer}}
                if({{paramName}}){
                    {{paramName}}.forEach((element) => {
                        queryParameters.append('{{baseName}}', <any>element);
                    })
                }
            {{/isListContainer}}
            {{^isListContainer}}
                queryParameters.set('{{baseName}}', <any>{{paramName}});
            {{/isListContainer}}
        }
{{/queryParams}}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions