OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.58k stars 6.52k forks source link

[BUG] [typescript-node] Query parameters do not support `explode: false, style: form` #9003

Open evstinik opened 3 years ago

evstinik commented 3 years ago

Bug Report Checklist

Description

CSV array serialization for query parameter is not supported for OAS3. It seems that explode is ignored at all.

openapi-generator version

5.0.1

OpenAPI declaration file content or url

Pet Store API OAS3 with modified listPets that accepts query parameter tags (explode: false, style: form)

        - name: tags
          in: query
          description: Filter by tags
          required: false
          allowEmptyValue: true
          style: form
          explode: false
          schema:
            type: array
            items:
              type: string
Generation Details

Command:

npx @openapitools/openapi-generator-cli generate \
  -i ./petstore.yaml \
  -g typescript-node --generate-alias-as-model \
  -c ./codegen.config.json \
  -o ./generated/

Contents of codegen.config.json:

{
  "sortParamsByRequiredFlag": true,
  "ensureUniqueParams": true,
  "allowUnicodeIdentifiers": false,
  "modelPropertyNaming": "camelCase",
  "supportsES6": false,
  "snapshot": false,
  "typescriptThreePlus": true
}
Steps to reproduce
  1. Generate the code
  2. Add a debugging console.log statement to petsApi.ts:L208: console.log(localVarRequest(localVarRequestOptions).uri.query)
  3. Instantiate api and call the method
    
    import { PetsApi } from './generated/api'

const api = new PetsApi() api.listPets(10, ["dog", "cat"])


4. Output will be `limit=10&tags%5B0%5D=dog&tags%5B1%5D=cat`

Expected: `limit=10&tags=dog,cat`

##### Related issues/PRs

I think this issue is related: https://github.com/OpenAPITools/openapi-generator/issues/7973

##### Suggest a fix

Not able, but with few advices on which template variables to use and example implementation in other clients I might be able to fix it and send pull request.
tobq commented 9 months ago

Any updates here? I'm wanting the format limit=10&tag=dog&tag=cat