swagger-api / swagger-api/swagger-codegen-generators

"pipeDelimeted" query parameter format generates invalid node-fetch code

Open
#887 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
299
Forks
439
PR merge metrics
No merged PRs in 30d

Description

Hi,

setting the style parameter of a query parameter to pipeDelimited generates invalid typescript-fetch code.

Example Property
- name: searchIn
    in: query
    description: Ids of the columns to search in
    required: true
    style: pipeDelimited
    explode: false
    schema:
    type: array
    items:
        type: integer
api.ts(7404,87): error TS2551: Property 'pipe' does not exist on type '{ csv: string; ssv: string; tsv: string; pipes: string; }'. Did you mean 'pipes'?
Generated code

This is the generated COLLECTION_FORMATS object:

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

And this is the code that tries to access an invalid property of COLLECTION_FORMATS:

if (searchIn) {
    localVarQueryParameter['searchIn'] = searchIn.join(COLLECTION_FORMATS["pipe"]);
}

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

Locate the typescript-fetch generator templates responsible for COLLECTION_FORMATS and query serialization, then inspect how pipeDelimited is mapped and referenced. Generate code from the example schema and verify that the resulting TypeScript compiles without the invalid COLLECTION_FORMATS["pipe"] access.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.