swagger-codegen icon indicating copy to clipboard operation
swagger-codegen copied to clipboard

[typescript-angular] File arrays do not use FormData

Open markmblc opened this issue 6 years ago • 3 comments

Description

When a formData file parameter is an array, the generated code does not properly trigger the use of FormData. The generated code works properly be manually changing the below line in the generated service method:

let useForm = false;

to

let useForm = canConsumeForm;
Swagger declaration file content or url
post:
      operationId: UploadFiles
      tags:
        - Documents
      summary: Creates a new document with a single revision.
      consumes:
        - multipart/form-data
      parameters:
        - name: files
          in: formData
          type: array
          items:
            type: file
      responses:
        '201':
          description: Document created successfully
          schema:
            $ref: '#/definitions/DocumentSummaryResponse'
      produces:
        - application/json
Suggest a fix/enhancement

In addition to checking if the parameter is of type file, the code gen logic should also check if the items.type parameter is of type file. If so, set the isFile flag to true.

markmblc avatar Jan 18 '19 22:01 markmblc

Same problem here.

Onedy avatar Feb 19 '20 10:02 Onedy

Still an issue in 3.0.25

CR34L avatar Jul 19 '21 05:07 CR34L

same here. really annoying

KorsakVlad avatar Sep 13 '22 13:09 KorsakVlad