OpenAPITools / OpenAPITools/openapi-generator
[BUG][typescript-fetch] collectionFormat option is ignored for code generation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I have identified an issue with the typescript-fetch code generator. The collectionFormat option, which is used for specifying the format of array parameters, is not being respected during code generation. Regardless of the collectionFormat specified in the OpenAPI specification, the generated code consistently defaults to using the CSV format.
openapi-generator version
7.7.0
OpenAPI declaration file content or url
A complete reproduction of this issue can be found in the following Replit environment:
https://replit.com/@sherlockdoyle19/openapi-issue
Generation Details
The generated code is available in the provided Replit. To regenerate the files, one can execute the npm run build script within the Replit console.
Alternatively, the following command can be used:
openapi-generator-cli generate -i openapi.json -g typescript-fetch -o ./generated
Steps to reproduce
- Create an OpenAPI specification file containing a parameter of type array.
- Set various
collectionFormatoptions for different array parameters. - Generate the typescript-fetch code using the OpenAPI Generator.
- Examine the generated code, particularly focusing on how array parameters are handled.
In the provided Replit, I have defined three parameters, each with a different collectionFormat. However, in the generated code, all three parameters utilize runtime.COLLECTION_FORMATS["csv"], disregarding the specified formats.
Related issues/PRs
A potentially similar issue: https://github.com/OpenAPITools/openapi-generator/issues/18506
Suggest a fix
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the OpenAPI declaration and generated code in the linked Replit environment, then run the documented openapi-generator-cli command or npm run build. Compare the generated handling of the three array parameters and their collectionFormat values; done means typescript-fetch preserves each specified format instead of defaulting all parameters to csv.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100