[REQ][typescript-fetch] Name downloaded files from Content-Disposition (return a File instead of an anonymous Blob)
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Accessibilité débutants
- 35/100
- Type d'issue
- Fonctionnalité
- Clarté
- Clairement spécifiée
- Activité
- À l'abandon
- Stack technique
- typescript
Piste de recherche
Commencez par examiner l’implémentation de BlobApiResponse dans typescript-fetch et la gestion existante des noms de fichiers dans typescript/http/http.mustache. Vérifiez comment les méthodes générées utilisent BlobApiResponse.value(), puis vérifiez que le comportement final préserve la compatibilité avec Blob, expose le nom de fichier demandé et gère les deux formes de filename de Content-Disposition.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
For an operation whose response is a file (isResponseFile), the typescript-fetch runtime returns the body through BlobApiResponse.value():
export class BlobApiResponse {
constructor(public raw: Response) {}
async value(): Promise<Blob> {
return await this.raw.blob();
};
}
The name the server advertises in Content-Disposition (attachment; filename="invoice-2026-09.pdf") is dropped. Any client that wants to save the download under its real name has to bypass the generated method, call the xxxRaw() variant, read raw.headers and parse the header itself, and every project ends up with its own copy of that parsing.
Every other runtime in this repository already does it for the user:
typescriptgenerator:ResponseContext.getBodyAsFile()returnsnew File([data], fileName, { type })withfileNameread fromcontent-disposition(typescript/http/http.mustache).- Java (
okhttp-gson,jersey2/3,apache-httpclient,feign,native,vertx):prepareDownloadFilenames the temp file fromContent-Disposition. - Python (
api_client.mustache,__deserialize_file): idem. - C# (
ClientUtils,FileParameter): idem.
typescript-fetch is the exception.
Describe the solution you'd like
Keep BlobApiResponse, make it return a File named after Content-Disposition (empty name when the header is absent, type taken from the blob):
async value(): Promise<File> {
const blob = await this.raw.blob();
return new File([blob], parseContentDispositionFilename(this.raw.headers) ?? '', { type: blob.type });
}
plus an exported parseContentDispositionFilename(headers) handling the RFC 5987 filename*=UTF-8''... form first and the plain filename= form otherwise.
Backward compatible: File extends Blob, so the generated methods still satisfy their declared Promise<Blob> return type and existing callers keep working; callers that want the name read file.name.
Describe alternatives you've considered
- A new
FileApiResponsenext toBlobApiResponse: forces a template change inapis.mustacheand a choice for the user, for no benefit since aFileis aBlob. - Exposing only the helper and leaving
value()unchanged: still leaves every user to call the raw variant. - Doing it in application code: that is what we do today, duplicated per project.
Additional context
File is a global in browsers and in Node.js 20+ (the CI matrix of the typescript-fetch samples runs Node 20).
PR: https://github.com/OpenAPITools/openapi-generator/pull/24957
- Langage dominant
- Java
- Étoiles
- 26.9k
- Forks
- 7.8k
- Merge moyen
- 2 j 10 h
- PR mergées (30 j)
- 180
Préparer son environnement
Lance le conteneur de développement du projet dans votre navigateur, avec votre propre compte GitHub.
- Fournit un Dockerfile ou un fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de OpenAPITools/openapi-generator
-
Issue: Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 80/100
OpenAPITools/openapi-generator#25643 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
OpenAPITools/openapi-generator#25640 ·
Les mainteneurs répondent en général sous 1 jour
-
[BUG][JAVA] Deprecated properties only get @Deprecated on the getter (base, feign, native, microprofile)Peut-être pris @Inf1mum l’a pris il y a 2 jours. OuverteIssue: Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
OpenAPITools/openapi-generator#25567 ·
Les mainteneurs répondent en général sous 1 jour
-
[BUG][KOTLIN-SERVER] typeInfoAnnotation.mustache uses As.PROPERTY → discriminator property serialized twicePeut-être pris @Inf1mum l’a pris il y a 9 jours. OuverteIssue: Bug
Difficulté 2/5 1-3 heures Accessibilité débutants 62/100
OpenAPITools/openapi-generator#25524 · 1 commentaire ·
Les mainteneurs répondent en général sous 1 jour
-
[REQ][JAVA][resteasy] Support for Jackson 3 / useJackson3Peut-être pris Une pull request liée à cette issue est ouverte ou déjà fusionnée. OuverteEnhancement: Feature
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
OpenAPITools/openapi-generator#25364 ·
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de OpenAPITools/openapi-generator
Issues similaires
-
bug emitter:client:csharp
Difficulté 2/5 1-3 heures Accessibilité débutants 84/100
microsoft/typespec#12572 · 1 commentaire · 1 réaction ·
Les mainteneurs répondent en général sous 1 jour
-
GCC 15.2: -Wcast-qual warning - cast discards const qualifier from pointer target type (H5trace.c)Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 73/100
Les mainteneurs répondent en général sous 1 jour
-
[Bug] RemotingHelper.connect swaps the socket send and receive buffer configurationPeut-être pris @amalsaidov l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
needs-area-label
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 2 jours
-
area/ai area/backend component/zeebe kind/task
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour