From 1b344597bf642108c95bf98ad8f9f44b7dd568e0 Mon Sep 17 00:00:00 2001 From: teddy-s-song <118232533+teddy-s-song@users.noreply.github.com> Date: Wed, 7 Dec 2022 18:20:22 +0900 Subject: [PATCH] [typescript-axios] add temination condition for flattening url parameters (#14018) --- .../src/main/resources/typescript-axios/common.mustache | 1 + .../petstore/typescript-axios/builds/composed-schemas/common.ts | 1 + .../client/petstore/typescript-axios/builds/default/common.ts | 1 + .../client/petstore/typescript-axios/builds/es6-target/common.ts | 1 + .../petstore/typescript-axios/builds/test-petstore/common.ts | 1 + .../typescript-axios/builds/with-complex-headers/common.ts | 1 + .../common.ts | 1 + .../petstore/typescript-axios/builds/with-interfaces/common.ts | 1 + .../petstore/typescript-axios/builds/with-node-imports/common.ts | 1 + .../with-npm-version-and-separate-models-and-api/common.ts | 1 + .../petstore/typescript-axios/builds/with-npm-version/common.ts | 1 + .../builds/with-single-request-parameters/common.ts | 1 + .../petstore/typescript-axios/builds/with-string-enums/common.ts | 1 + 13 files changed, 13 insertions(+) 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 2d1c8dc8e47..74e309f6a15 100755 --- a/modules/openapi-generator/src/main/resources/typescript-axios/common.mustache +++ b/modules/openapi-generator/src/main/resources/typescript-axios/common.mustache @@ -77,6 +77,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 3c485ae19ac..55e3222c11c 100644 --- a/samples/client/petstore/typescript-axios/builds/composed-schemas/common.ts +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/common.ts @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); diff --git a/samples/client/petstore/typescript-axios/builds/default/common.ts b/samples/client/petstore/typescript-axios/builds/default/common.ts index be9b7df6247..fee87ee2a1d 100644 --- a/samples/client/petstore/typescript-axios/builds/default/common.ts +++ b/samples/client/petstore/typescript-axios/builds/default/common.ts @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 be9b7df6247..fee87ee2a1d 100644 --- a/samples/client/petstore/typescript-axios/builds/es6-target/common.ts +++ b/samples/client/petstore/typescript-axios/builds/es6-target/common.ts @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 9e9ca0742f2..4d9401c2c99 100644 --- a/samples/client/petstore/typescript-axios/builds/test-petstore/common.ts +++ b/samples/client/petstore/typescript-axios/builds/test-petstore/common.ts @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 be9b7df6247..fee87ee2a1d 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 @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 9e9ca0742f2..4d9401c2c99 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 @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 be9b7df6247..fee87ee2a1d 100644 --- a/samples/client/petstore/typescript-axios/builds/with-interfaces/common.ts +++ b/samples/client/petstore/typescript-axios/builds/with-interfaces/common.ts @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 cbb8723f77c..7ced836b0f7 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 @@ -86,6 +86,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 be9b7df6247..fee87ee2a1d 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 @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 be9b7df6247..fee87ee2a1d 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 @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 be9b7df6247..fee87ee2a1d 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 @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key)); 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 be9b7df6247..fee87ee2a1d 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 @@ -85,6 +85,7 @@ export const setOAuthToObject = async function (object: any, name: string, scope } function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void { + if (parameter == null) return; if (typeof parameter === "object") { if (Array.isArray(parameter)) { (parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));