From 36911c773ee365e97b23d9a43834f068d9a5fb48 Mon Sep 17 00:00:00 2001 From: Esteban Gehring Date: Mon, 22 Apr 2024 08:47:10 +0200 Subject: [PATCH] =?UTF-8?q?Revert=20"Fix:=20Incorrect=20serialisation=20of?= =?UTF-8?q?=20maps=20and=20sets=20in=20typescript-axios=20(#1=E2=80=A6"=20?= =?UTF-8?q?(#18452)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 815205250a734f9346c061f79279a190f1dc455e. --- .../typescript-axios/common.mustache | 42 +------------------ .../echo_api/typescript-axios/build/common.ts | 42 +------------------ .../common.ts | 42 +------------------ .../builds/composed-schemas/common.ts | 42 +------------------ .../typescript-axios/builds/default/common.ts | 42 +------------------ .../builds/es6-target/common.ts | 42 +------------------ .../builds/test-petstore/common.ts | 42 +------------------ .../builds/with-complex-headers/common.ts | 42 +------------------ .../common.ts | 42 +------------------ .../builds/with-interfaces/common.ts | 42 +------------------ .../builds/with-node-imports/common.ts | 42 +------------------ .../common.ts | 42 +------------------ .../builds/with-npm-version/common.ts | 42 +------------------ .../with-single-request-parameters/common.ts | 42 +------------------ .../builds/with-string-enums/common.ts | 42 +------------------ 15 files changed, 15 insertions(+), 615 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/typescript-axios/common.mustache b/modules/openapi-generator/src/main/resources/typescript-axios/common.mustache index 004fc11fdae8..aa594015c7f9 100755 --- a/modules/openapi-generator/src/main/resources/typescript-axios/common.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-axios/common.mustache @@ -118,50 +118,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/echo_api/typescript-axios/build/common.ts b/samples/client/echo_api/typescript-axios/build/common.ts index c4b85d352ca7..fc1881f27b35 100644 --- a/samples/client/echo_api/typescript-axios/build/common.ts +++ b/samples/client/echo_api/typescript-axios/build/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/common.ts b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/common.ts index 71ef49eebeb4..95d62a0dcddb 100644 --- a/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/common.ts +++ b/samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/common.ts b/samples/client/petstore/typescript-axios/builds/composed-schemas/common.ts index 259040a2b386..d629dec4427f 100644 --- a/samples/client/petstore/typescript-axios/builds/composed-schemas/common.ts +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/default/common.ts b/samples/client/petstore/typescript-axios/builds/default/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/default/common.ts +++ b/samples/client/petstore/typescript-axios/builds/default/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/es6-target/common.ts b/samples/client/petstore/typescript-axios/builds/es6-target/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/es6-target/common.ts +++ b/samples/client/petstore/typescript-axios/builds/es6-target/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/test-petstore/common.ts b/samples/client/petstore/typescript-axios/builds/test-petstore/common.ts index e1b019a31500..c0f62a7b6df1 100644 --- a/samples/client/petstore/typescript-axios/builds/test-petstore/common.ts +++ b/samples/client/petstore/typescript-axios/builds/test-petstore/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-complex-headers/common.ts b/samples/client/petstore/typescript-axios/builds/with-complex-headers/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/with-complex-headers/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-complex-headers/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts index e1b019a31500..c0f62a7b6df1 100644 --- a/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-interfaces/common.ts b/samples/client/petstore/typescript-axios/builds/with-interfaces/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/with-interfaces/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-interfaces/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-node-imports/common.ts b/samples/client/petstore/typescript-axios/builds/with-node-imports/common.ts index 25f8cc331dce..a88b97565783 100644 --- a/samples/client/petstore/typescript-axios/builds/with-node-imports/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-node-imports/common.ts @@ -127,50 +127,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/common.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-npm-version/common.ts b/samples/client/petstore/typescript-axios/builds/with-npm-version/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/with-npm-version/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-npm-version/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-single-request-parameters/common.ts b/samples/client/petstore/typescript-axios/builds/with-single-request-parameters/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/with-single-request-parameters/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-single-request-parameters/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export diff --git a/samples/client/petstore/typescript-axios/builds/with-string-enums/common.ts b/samples/client/petstore/typescript-axios/builds/with-string-enums/common.ts index c58729d6aaf5..d5b9e4718aea 100644 --- a/samples/client/petstore/typescript-axios/builds/with-string-enums/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-string-enums/common.ts @@ -126,50 +126,10 @@ export const serializeDataIfNeeded = function (value: any, requestOptions: any, ? configuration.isJsonMime(requestOptions.headers['Content-Type']) : nonString; return needsSerialization - ? JSON.stringify(value !== undefined ? convertMapsAndSetsToPlain(value) : {}) + ? JSON.stringify(value !== undefined ? value : {}) : (value || ""); } -function convertMapsAndSetsToPlain(value: any): any { - if (typeof Set === "undefined") return value; - if (typeof Map === "undefined") return value; - if (typeof value !== "object" || !value) { - return value; - } - if (value instanceof Set) { - return Array.from(value).map(item => convertMapsAndSetsToPlain(item)); - } - if (value instanceof Map) { - const entries: Array<[string, any]> = []; - value.forEach((value: any, key: any) => { - entries.push([key, convertMapsAndSetsToPlain(value)]) - }); - return objectFromEntries(entries); - } - if (Array.isArray(value)) { - return value.map(it => convertMapsAndSetsToPlain(it)); - } - return objectFromEntries(objectEntries(value) - .map(([k, v]) => [k, convertMapsAndSetsToPlain(v)])); -} - -/** - * Ponyfill for Object.entries - */ -function objectEntries(object: Record): Array<[string, any]> { - return Object.keys(object).map(key => [key, object[key]]); -} - -/** - * Ponyfill for Object.fromEntries - */ -function objectFromEntries(entries: any): Record { - return [...entries].reduce((object, [key, val]) => { - object[key] = val; - return object; - }, {}); -} - /** * * @export