swagger-api / swagger-api/swagger-codegen
[TYPESCRIPT-ANGULAR] Filename during upload
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
Modelling a rest service to upload a file using swagger 2.0 result in a default implementation in typescript with "Blob" type. This class does not specify a filename, so instead a File class must be used, because File extends Blob and specify a filename
Swagger-codegen version
2.3.1 ( I think current stable is behind https://editor.swagger.io too )
Swagger declaration file content or url
swagger: "2.0"
info:
version: "0.1"
title: "TEST UPLOAD"
basePath: "/rest"
schemes:
- "http"
host: localhost:8080
paths:
/file/xml:
post:
consumes:
- "multipart/form-data"
parameters:
- in: formData
name: upfile
type: file
required: true
produces:
- "application/json"
responses:
200:
description: file uploaded
schema:
type: string
Command line used for generation
Using https://editor.swagger.io/
Steps to reproduce
- go to https://editor.swagger.io/
- paste provided yaml
- generate-client -> typescript-angular
- unzip result
- go to /api folder
- open default.service.ts
- at row 65,66,67,68 generated methos are:
public fileXmlPost(upfile: Blob, observe?: 'body', reportProgress?: boolean): Observable<string>;
public fileXmlPost(upfile: Blob, observe?: 'response', reportProgress?: boolean): Observable<HttpResponse<string>>;
public fileXmlPost(upfile: Blob, observe?: 'events', reportProgress?: boolean): Observable<HttpEvent<string>>;
public fileXmlPost(upfile: Blob, observe: any = 'body', reportProgress: boolean = false ): Observable<any> {
- why upfile type is Blob instead of File ?
Related issues/PRs
No one found
Suggest a fix/enhancement
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
Reproduce the issue with the provided Swagger 2.0 definition using the typescript-angular generator, then inspect the generated /api/default.service.ts entry point. Trace the generator template or type mapping that produces the Blob parameter and verify the generated upload signature against the expected filename-carrying type.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angular, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100