[BUG][typescript-fetch] cannot handle with application/x-www-form-urlencoded content
Created by: namaozi
Description
In OpenAPI Specification Media Type Object, it says requestBody->content
's key is media type (it includes 'application/x-www-form-urlencoded'
) or media type range.
like this:
paths:
/memo/{memoId}:
put:
summary: update Memo
tags:
- Memos
operationId: updateMemo
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
required:
- title
properties:
title:
...
It seems that the request body made through by the generated code however always make multipart/form-data
request.
like this (in src/apis/Memos.ts):
export class MemosApi extends runtime.BaseAPI {
async updateMemoRaw(requestParameters: UpdateMemoRequest) {
// ...
const headerParameters: runtime.HTTPHeaders = {};
// ...
const formData = new FormData();
if (requestParameters.title !== undefined) {
formData.append('title', requestParameters.title as any);
}
// and formData is set as body (`body: formData`)
}
}
It would be appreciated like this:
const headerParameters: runtime.HTTPHeaders = {};
headerParameters['Content-Type'] = 'application/x-www-form-urlencoded';
const bodyParams = new URLSearchParams();
if (requestParameters.title !== undefined) {
bodyParams.append('title', requestParameters.title as any);
}
// and bodyParams is set as body (`body: bodyParams`)
openapi-generator version
v4.1.1
Command line used for generation
openapi-generator generate -i bundle.yml -o ./lib --generator-name typescript-fetch