swagger-api / swagger-api/swagger-codegen

[Typescript-Angular] for upload multi file in blob array

Open
#10,902 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

was trying to upload file with blob array (Array<Blob>)
function is generate incomplete with codegen

first issues:
let formParams: { append(param: string, value: any): void; };
prompt error on formParams = formParams.append('request', <any>element) || formParams; during compile.

have to manually change void to any after generate

second issues:

const consumes: string[] = [
            'multipart/form-data'
        ];

consumes initial as array, with multipart/form-data
but useForm is false, (suppose assign useForm = canConsumeForm in this case)
change the code to useForm = canConsumeForm on my case

expecting result:
post with binary file, not [object file]

example bug code:

public test(request?: Array<Blob>, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
    const consumes: string[] = [
        'multipart/form-data'
     ];
    const canConsumeForm = this.canConsumeForm(consumes);
    let formParams: { append(param: string, value: any): void; };
    let useForm = false;
}

workable code:

public test(request?: Array<Blob>, observe: any = 'body', reportProgress: boolean = false): Observable<any> {
    const consumes: string[] = [
        'multipart/form-data'
     ];
    const canConsumeForm = this.canConsumeForm(consumes);
    let formParams: { append(param: string, value: any): any; };
    let useForm = canConsumeForm;
}
Swagger-codegen version

3.0.24

Swagger declaration file content or url

not suitable to share here, sorry

Command line used for generation

swagger-codegen generate -i <url> -l typescript-angular --additional-properties ngVersion=9.0.0

Related issues/PRs

yes, but no actual solution

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Run the shown swagger-codegen command for the typescript-angular generator using a minimal multipart/form-data definition that accepts Array, then compare the generated client with the reported snippets. Done means the generated TypeScript compiles without changing append’s return type and posts the files as binary multipart data.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.