swagger-api / swagger-api/swagger-codegen
[typescript-angular] File arrays do not use FormData
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
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.
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
Start at the TypeScript Angular generator logic that determines whether a formData parameter is a file, using the generated service method and the provided Swagger declaration as the reproduction. Check the existing file-parameter condition against array items.type; done when an array of files causes useForm to use canConsumeForm without manual edits.
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
- 45/100