swagger-api / swagger-api/swagger-codegen

collectionFormat 'pipes' is not properly handled in generated code

Open
#10,963 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

The code is using 'pipe' to encode the array argument, while the corresponding COLLECTION_FORMAT constant is 'pipes'

content in base.ts:

export const COLLECTION_FORMATS = {
    csv: ",",
    ssv: " ",
    tsv: "\t",
    pipes: "|",
};

usage in code:

if (usernames) {
    localVarQueryParameter['usernames'] = usernames.join(COLLECTION_FORMATS.pipe);
}
Swagger-codegen version

3.0.25

Swagger declaration file content or url
    "/chat/client/list": {
      "get": {
        "tags": [
          "client-controller"
        ],
        "operationId": "findAllClients",
        "parameters": [
          {
            "name": "usernames",
            "in": "query",
            "required": false,
            "style": "pipeDelimited",
            "schema": {
              "type": "array",
              "items": {
                "type": "string"
              }
            }
          }
        ]
      }
    }
Command line used for generation

language=typescript-axios (generated with swagger-codgen-maven-plugin(v3)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the TypeScript Axios generator output and the base.ts content shown in the issue, then reproduce generation using the provided pipeDelimited array parameter. Trace where the collection format is selected and verify the generated code uses the matching constant for pipe-delimited values.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.