Skip to content

Revert "Fix contentFormatter for FormData returning an empty FormData object" #863

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions templates/base/http-clients/fetch-http-client.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ export class HttpClient<SecurityDataType = unknown> {
private contentFormatters: Record<ContentType, (input: any) => any> = {
[ContentType.Json]: (input:any) => input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input:any) => input !== null && typeof input !== "string" ? JSON.stringify(input) : input,
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob ?
Expand Down
252 changes: 126 additions & 126 deletions tests/__snapshots__/extended.test.ts.snap

Large diffs are not rendered by default.

252 changes: 126 additions & 126 deletions tests/__snapshots__/simple.test.ts.snap

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/custom-extensions/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/defaultAsSuccess/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/defaultResponse/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/deprecated/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/dot-path-params/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/enumNamesAsValues/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -302,9 +302,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -265,9 +265,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
4 changes: 2 additions & 2 deletions tests/spec/jsAxios/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ export class HttpClient {
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/moduleNameIndex/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/patch/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/responses/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/singleHttpClient/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/sortTypes-false/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/sortTypes/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/typeSuffixPrefix/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1867,9 +1867,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down
6 changes: 3 additions & 3 deletions tests/spec/unionEnums/__snapshots__/basic.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,9 @@ export class HttpClient<SecurityDataType = unknown> {
[ContentType.Json]: (input: any) =>
input !== null && (typeof input === "object" || typeof input === "string") ? JSON.stringify(input) : input,
[ContentType.Text]: (input: any) => (input !== null && typeof input !== "string" ? JSON.stringify(input) : input),
[ContentType.FormData]: (input: FormData) =>
(Array.from(input.keys()) || []).reduce((formData, key) => {
const property = input.get(key);
[ContentType.FormData]: (input: any) =>
Object.keys(input || {}).reduce((formData, key) => {
const property = input[key];
formData.append(
key,
property instanceof Blob
Expand Down