Skip to content

Commit a50d0c1

Browse files
authored
Merge pull request #863 from acacode/revert-747-main
Revert "Fix contentFormatter for FormData returning an empty FormData object"
2 parents 2ab3512 + ebc9a3a commit a50d0c1

File tree

25 files changed

+320
-320
lines changed

25 files changed

+320
-320
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,9 @@ export class HttpClient<SecurityDataType = unknown> {
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,
106106
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
107-
[ContentType.FormData]: (input: FormData) =>
108-
(Array.from(input.keys()) || []).reduce((formData, key) => {
109-
const property = input.get(key);
107+
[ContentType.FormData]: (input: any) =>
108+
Object.keys(input || {}).reduce((formData, key) => {
109+
const property = input[key];
110110
formData.append(
111111
key,
112112
property instanceof Blob ?

tests/__snapshots__/extended.test.ts.snap

Lines changed: 126 additions & 126 deletions
Large diffs are not rendered by default.

tests/__snapshots__/simple.test.ts.snap

Lines changed: 126 additions & 126 deletions
Large diffs are not rendered by default.

tests/spec/another-query-params/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ export class HttpClient<SecurityDataType = unknown> {
138138
[ContentType.Json]: (input: any) =>
139139
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
140140
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
141-
[ContentType.FormData]: (input: FormData) =>
142-
(Array.from(input.keys()) || []).reduce((formData, key) => {
143-
const property = input.get(key);
141+
[ContentType.FormData]: (input: any) =>
142+
Object.keys(input || {}).reduce((formData, key) => {
143+
const property = input[key];
144144
formData.append(
145145
key,
146146
property instanceof Blob

tests/spec/custom-extensions/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
110110
[ContentType.Json]: (input: any) =>
111111
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
112112
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
113-
[ContentType.FormData]: (input: FormData) =>
114-
(Array.from(input.keys()) || []).reduce((formData, key) => {
115-
const property = input.get(key);
113+
[ContentType.FormData]: (input: any) =>
114+
Object.keys(input || {}).reduce((formData, key) => {
115+
const property = input[key];
116116
formData.append(
117117
key,
118118
property instanceof Blob

tests/spec/defaultAsSuccess/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ export class HttpClient<SecurityDataType = unknown> {
150150
[ContentType.Json]: (input: any) =>
151151
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
152152
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
153-
[ContentType.FormData]: (input: FormData) =>
154-
(Array.from(input.keys()) || []).reduce((formData, key) => {
155-
const property = input.get(key);
153+
[ContentType.FormData]: (input: any) =>
154+
Object.keys(input || {}).reduce((formData, key) => {
155+
const property = input[key];
156156
formData.append(
157157
key,
158158
property instanceof Blob

tests/spec/defaultResponse/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
110110
[ContentType.Json]: (input: any) =>
111111
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
112112
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
113-
[ContentType.FormData]: (input: FormData) =>
114-
(Array.from(input.keys()) || []).reduce((formData, key) => {
115-
const property = input.get(key);
113+
[ContentType.FormData]: (input: any) =>
114+
Object.keys(input || {}).reduce((formData, key) => {
115+
const property = input[key];
116116
formData.append(
117117
key,
118118
property instanceof Blob

tests/spec/deprecated/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
110110
[ContentType.Json]: (input: any) =>
111111
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
112112
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
113-
[ContentType.FormData]: (input: FormData) =>
114-
(Array.from(input.keys()) || []).reduce((formData, key) => {
115-
const property = input.get(key);
113+
[ContentType.FormData]: (input: any) =>
114+
Object.keys(input || {}).reduce((formData, key) => {
115+
const property = input[key];
116116
formData.append(
117117
key,
118118
property instanceof Blob

tests/spec/dot-path-params/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ export class HttpClient<SecurityDataType = unknown> {
112112
[ContentType.Json]: (input: any) =>
113113
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
114114
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
115-
[ContentType.FormData]: (input: FormData) =>
116-
(Array.from(input.keys()) || []).reduce((formData, key) => {
117-
const property = input.get(key);
115+
[ContentType.FormData]: (input: any) =>
116+
Object.keys(input || {}).reduce((formData, key) => {
117+
const property = input[key];
118118
formData.append(
119119
key,
120120
property instanceof Blob

tests/spec/enumNamesAsValues/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,9 @@ export class HttpClient<SecurityDataType = unknown> {
302302
[ContentType.Json]: (input: any) =>
303303
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
304304
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
305-
[ContentType.FormData]: (input: FormData) =>
306-
(Array.from(input.keys()) || []).reduce((formData, key) => {
307-
const property = input.get(key);
305+
[ContentType.FormData]: (input: any) =>
306+
Object.keys(input || {}).reduce((formData, key) => {
307+
const property = input[key];
308308
formData.append(
309309
key,
310310
property instanceof Blob

tests/spec/extractRequestBody/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ export class HttpClient<SecurityDataType = unknown> {
263263
[ContentType.Json]: (input: any) =>
264264
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
265265
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
266-
[ContentType.FormData]: (input: FormData) =>
267-
(Array.from(input.keys()) || []).reduce((formData, key) => {
268-
const property = input.get(key);
266+
[ContentType.FormData]: (input: any) =>
267+
Object.keys(input || {}).reduce((formData, key) => {
268+
const property = input[key];
269269
formData.append(
270270
key,
271271
property instanceof Blob

tests/spec/extractRequestParams/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,9 @@ export class HttpClient<SecurityDataType = unknown> {
185185
[ContentType.Json]: (input: any) =>
186186
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
187187
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
188-
[ContentType.FormData]: (input: FormData) =>
189-
(Array.from(input.keys()) || []).reduce((formData, key) => {
190-
const property = input.get(key);
188+
[ContentType.FormData]: (input: any) =>
189+
Object.keys(input || {}).reduce((formData, key) => {
190+
const property = input[key];
191191
formData.append(
192192
key,
193193
property instanceof Blob

tests/spec/extractResponseBody/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,9 +265,9 @@ export class HttpClient<SecurityDataType = unknown> {
265265
[ContentType.Json]: (input: any) =>
266266
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
267267
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
268-
[ContentType.FormData]: (input: FormData) =>
269-
(Array.from(input.keys()) || []).reduce((formData, key) => {
270-
const property = input.get(key);
268+
[ContentType.FormData]: (input: any) =>
269+
Object.keys(input || {}).reduce((formData, key) => {
270+
const property = input[key];
271271
formData.append(
272272
key,
273273
property instanceof Blob

tests/spec/extractResponseError/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,9 @@ export class HttpClient<SecurityDataType = unknown> {
260260
[ContentType.Json]: (input: any) =>
261261
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
262262
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
263-
[ContentType.FormData]: (input: FormData) =>
264-
(Array.from(input.keys()) || []).reduce((formData, key) => {
265-
const property = input.get(key);
263+
[ContentType.FormData]: (input: any) =>
264+
Object.keys(input || {}).reduce((formData, key) => {
265+
const property = input[key];
266266
formData.append(
267267
key,
268268
property instanceof Blob

tests/spec/jsAxios/__snapshots__/basic.test.ts.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ export class HttpClient {
6464
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
6565
[ContentType.Text]: (input) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
6666
[ContentType.FormData]: (input) =>
67-
(Array.from(input.keys()) || []).reduce((formData, key) => {
68-
const property = input.get(key);
67+
Object.keys(input || {}).reduce((formData, key) => {
68+
const property = input[key];
6969
formData.append(
7070
key,
7171
property instanceof Blob

tests/spec/moduleNameFirstTag/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ export class HttpClient<SecurityDataType = unknown> {
235235
[ContentType.Json]: (input: any) =>
236236
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
237237
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
238-
[ContentType.FormData]: (input: FormData) =>
239-
(Array.from(input.keys()) || []).reduce((formData, key) => {
240-
const property = input.get(key);
238+
[ContentType.FormData]: (input: any) =>
239+
Object.keys(input || {}).reduce((formData, key) => {
240+
const property = input[key];
241241
formData.append(
242242
key,
243243
property instanceof Blob

tests/spec/moduleNameIndex/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,9 @@ export class HttpClient<SecurityDataType = unknown> {
235235
[ContentType.Json]: (input: any) =>
236236
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
237237
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
238-
[ContentType.FormData]: (input: FormData) =>
239-
(Array.from(input.keys()) || []).reduce((formData, key) => {
240-
const property = input.get(key);
238+
[ContentType.FormData]: (input: any) =>
239+
Object.keys(input || {}).reduce((formData, key) => {
240+
const property = input[key];
241241
formData.append(
242242
key,
243243
property instanceof Blob

tests/spec/on-insert-path-param/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
110110
[ContentType.Json]: (input: any) =>
111111
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
112112
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
113-
[ContentType.FormData]: (input: FormData) =>
114-
(Array.from(input.keys()) || []).reduce((formData, key) => {
115-
const property = input.get(key);
113+
[ContentType.FormData]: (input: any) =>
114+
Object.keys(input || {}).reduce((formData, key) => {
115+
const property = input[key];
116116
formData.append(
117117
key,
118118
property instanceof Blob

tests/spec/patch/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
18671867
[ContentType.Json]: (input: any) =>
18681868
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
18691869
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
1870-
[ContentType.FormData]: (input: FormData) =>
1871-
(Array.from(input.keys()) || []).reduce((formData, key) => {
1872-
const property = input.get(key);
1870+
[ContentType.FormData]: (input: any) =>
1871+
Object.keys(input || {}).reduce((formData, key) => {
1872+
const property = input[key];
18731873
formData.append(
18741874
key,
18751875
property instanceof Blob

tests/spec/responses/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,9 @@ export class HttpClient<SecurityDataType = unknown> {
150150
[ContentType.Json]: (input: any) =>
151151
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
152152
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
153-
[ContentType.FormData]: (input: FormData) =>
154-
(Array.from(input.keys()) || []).reduce((formData, key) => {
155-
const property = input.get(key);
153+
[ContentType.FormData]: (input: any) =>
154+
Object.keys(input || {}).reduce((formData, key) => {
155+
const property = input[key];
156156
formData.append(
157157
key,
158158
property instanceof Blob

tests/spec/singleHttpClient/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
110110
[ContentType.Json]: (input: any) =>
111111
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
112112
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
113-
[ContentType.FormData]: (input: FormData) =>
114-
(Array.from(input.keys()) || []).reduce((formData, key) => {
115-
const property = input.get(key);
113+
[ContentType.FormData]: (input: any) =>
114+
Object.keys(input || {}).reduce((formData, key) => {
115+
const property = input[key];
116116
formData.append(
117117
key,
118118
property instanceof Blob

tests/spec/sortTypes-false/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
18671867
[ContentType.Json]: (input: any) =>
18681868
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
18691869
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
1870-
[ContentType.FormData]: (input: FormData) =>
1871-
(Array.from(input.keys()) || []).reduce((formData, key) => {
1872-
const property = input.get(key);
1870+
[ContentType.FormData]: (input: any) =>
1871+
Object.keys(input || {}).reduce((formData, key) => {
1872+
const property = input[key];
18731873
formData.append(
18741874
key,
18751875
property instanceof Blob

tests/spec/sortTypes/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
18671867
[ContentType.Json]: (input: any) =>
18681868
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
18691869
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
1870-
[ContentType.FormData]: (input: FormData) =>
1871-
(Array.from(input.keys()) || []).reduce((formData, key) => {
1872-
const property = input.get(key);
1870+
[ContentType.FormData]: (input: any) =>
1871+
Object.keys(input || {}).reduce((formData, key) => {
1872+
const property = input[key];
18731873
formData.append(
18741874
key,
18751875
property instanceof Blob

tests/spec/typeSuffixPrefix/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
18671867
[ContentType.Json]: (input: any) =>
18681868
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
18691869
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
1870-
[ContentType.FormData]: (input: FormData) =>
1871-
(Array.from(input.keys()) || []).reduce((formData, key) => {
1872-
const property = input.get(key);
1870+
[ContentType.FormData]: (input: any) =>
1871+
Object.keys(input || {}).reduce((formData, key) => {
1872+
const property = input[key];
18731873
formData.append(
18741874
key,
18751875
property instanceof Blob

tests/spec/unionEnums/__snapshots__/basic.test.ts.snap

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ export class HttpClient<SecurityDataType = unknown> {
122122
[ContentType.Json]: (input: any) =>
123123
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
124124
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
125-
[ContentType.FormData]: (input: FormData) =>
126-
(Array.from(input.keys()) || []).reduce((formData, key) => {
127-
const property = input.get(key);
125+
[ContentType.FormData]: (input: any) =>
126+
Object.keys(input || {}).reduce((formData, key) => {
127+
const property = input[key];
128128
formData.append(
129129
key,
130130
property instanceof Blob

0 commit comments

Comments
 (0)