Skip to content

Commit a201e43

Browse files
author
Jochen Diekenbrock
committed
fix: add handling for content type text in the templates
1 parent 2ae5ab0 commit a201e43

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

templates/base/http-clients/axios-http-client.ejs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,10 @@ export class HttpClient<SecurityDataType = unknown> {
115115
body = this.createFormData(body as Record<string, unknown>);
116116
}
117117

118+
if (type === ContentType.Text && body && body !== null && typeof body !== "string") {
119+
body = JSON.stringify(body);
120+
}
121+
118122
return this.instance.request({
119123
...requestParams,
120124
headers: {

templates/base/http-clients/fetch-http-client.ejs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ export class HttpClient<SecurityDataType = unknown> {
103103

104104
private contentFormatters: Record<ContentType, (input: any) => any> = {
105105
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
106+
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
106107
[ContentType.FormData]: (input: any) =>
107108
Object.keys(input || {}).reduce((formData, key) => {
108109
const property = input[key];

0 commit comments

Comments
 (0)