OpenAPITools / OpenAPITools/openapi-generator
[BUG][Typescript-jquery] optional file upload does not compile - passing File interface to formParams.append()
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?
- 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
The api*Api.ts code for optinal file upload has the following two flaws and does not compile:
public *Post(..., file?: File, ...).. {
let reqHasFile = false;
// a few lines later...
reqHasFile = true; // WHY??? It should have checked and put the declaration in a if statement
formParams.append("file", file); // <- TS(2769) No overload matches this call. (name: string, value: string | Blob): void, we pass a File interface
if (!reqHasFile) {
headerParams['Content-Type'] = 'application/x-www-form-urlencoded';
}
}
openapi-generator version
openapi-generator-cli 7.14.0-SNAPSHOT
commit : 4cffd32
built : -999999999-01-01T00:00:00+18:00
source : https://github.com/openapitools/openapi-generator
docs : https://openapi-generator.tech/
Run via docker "docker run --rm -v .:/local openapitools/openapi-generator-cli"
OpenAPI declaration file content or url
https://gist.github.com/dgasparri/c5e343f3e7d225284c087ba304678e44Generation Details
docker run --rm -v .:/local openapitools/openapi-generator-cli generate -i /local/openapi-rust.current.yml -g typescript-jquery -o /local/out/typescript-jquery/ --additional-properties=importFileExtension='.js'
Steps to reproduce
The bug is in the compiled typescript+jquery code
Related issues/PRs
I searched for file, upload, label Client: typescript . I didn't find any other bug that could be related to this one.
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
Generate the typescript-jquery client with the Docker command in the issue and inspect the generated api*Api.ts code for the optional file upload. Compare the output with the reported reqHasFile logic and formParams.append call, then compile the generated TypeScript to verify that the upload and content-type handling are corrected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- docker, jquery, typescript
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 43/100