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 004fc11fdae..aa594015c7f 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 c4b85d352ca..fc1881f27b3 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 71ef49eebeb..95d62a0dcdd 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 259040a2b38..d629dec4427 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 c58729d6aaf..d5b9e4718ae 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 c58729d6aaf..d5b9e4718ae 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 e1b019a3150..c0f62a7b6df 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 c58729d6aaf..d5b9e4718ae 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 e1b019a3150..c0f62a7b6df 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 c58729d6aaf..d5b9e4718ae 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 25f8cc331dc..a88b9756578 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 c58729d6aaf..d5b9e4718ae 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 c58729d6aaf..d5b9e4718ae 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 c58729d6aaf..d5b9e4718ae 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 c58729d6aaf..d5b9e4718ae 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