Skip to content

[BUG][Typescript-jquery] optional file upload does not compile - passing File interface to formParams.append() #21264

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
6 tasks
dgasparri opened this issue May 11, 2025 · 0 comments

Comments

@dgasparri
Copy link

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/c5e343f3e7d225284c087ba304678e44
Generation 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant