Open emadelwany opened 5 years ago
👍 Thanks for opening this issue! 🏷 I have applied any labels matching special text in your issue.
The team will review the labels and make any necessary changes.
Can this be closed? I believe this is fixed since we use formdata bodies and the genereated fetch client code looks like this:
const consumes: runtime.Consume[] = [
{ contentType: 'multipart/form-data' },
];
const canConsumeForm = runtime.canConsumeForm(consumes);
let formParams: { append(param: string, value: any): any };
let useForm = false;
useForm = canConsumeForm;
if (useForm) {
formParams = new FormData();
} else {
formParams = new URLSearchParams();
}
if (requestParameters.file !== undefined) {
formParams.append('file', requestParameters.file as any);
}
if (requestParameters.documentType !== undefined) {
formParams.append('document_type', requestParameters.documentType as any);
}
const response = await this.request({
path: `/users/{userId}/document`.replace(`{${"userId"}}`, encodeURIComponent(String(requestParameters.userId))),
method: 'POST',
headers: headerParameters,
query: queryParameters,
body: formParams,
});
Bug Report Checklist
Description
Generated TypeScript code doesn't properly handle FormData, the definition below generates:
When it should generate
openapi-generator version
3.3.4
(for JSON code), so it becomes more readable. If it is longer than about ten lines, please create a Gist (https://gist.github.com) or upload it somewhere else and link it here. -->
Command line used for generation
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli:v3.3.4 generate \ -i "http://host.docker.internal/swagger/v1/swagger.json" \ -g typescript-fetch \ --type-mappings Date=string \ -o /local/src/swagger
Steps to reproduce
Related issues/PRs
Suggest a fix